Brad Fitzpatrick
261cc498d3
types/views: add LenIter method to slice view types
...
This is basically https://github.com/bradfitz/iter which was
a joke but now that Go's adding range over int soonish, might
as well. It simplies our code elsewher that uses slice views.
Updates #8948
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-18 08:21:52 -07:00
Brad Fitzpatrick
e8551d6b40
all: use Go 1.21 slices, maps instead of x/exp/{slices,maps}
...
Updates #8419
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-17 08:42:35 -07:00
Maisem Ali
2e19790f61
types/views: add JSON marshal/unmarshal and AsMap to Map
...
This allows cloning a Map as well as marshaling the Map
as JSON.
Updates tailscale/corp#12754
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-06-29 10:12:26 -07:00
Brad Fitzpatrick
a2153afeeb
types/views: add Slice methods on Slice views
...
Updates #cleanup for change elsewhere.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-06-20 20:19:39 -07:00
Will Norris
71029cea2d
all: update copyright and license headers
...
This updates all source files to use a new standard header for copyright
and license declaration. Notably, copyright no longer includes a date,
and we now use the standard SPDX-License-Identifier header.
This commit was done almost entirely mechanically with perl, and then
some minimal manual fixes.
Updates #6865
Signed-off-by: Will Norris <will@tailscale.com>
2023-01-27 15:36:29 -08:00
Will Norris
3becf82dd3
types/views: add SliceEqualAnyOrder func
...
This is based on the tagsEqual func from corp/control/control.go, moved
here so that it can be reused in other places.
Signed-off-by: Will Norris <will@tailscale.com>
2023-01-11 15:18:40 -08:00
Brad Fitzpatrick
1598cd0361
net/tsaddr: remove ContainsFunc helpers (they're now in x/exp/slices)
...
x/exp/slices now has ContainsFunc (golang/go#53983 ) so we can delete
our versions.
Change-Id: I5157a403bfc1b30e243bf31c8b611da25e995078
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-12-05 18:50:24 -08:00
Maisem Ali
20324eeebc
ipn/prefs: add views
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-10-24 15:57:00 -07:00
Sonia Appasamy
5363a90272
types/view: add ContainsNonExitSubnetRoutes func
...
Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
2022-10-12 15:19:36 -05:00
Maisem Ali
51c3d74095
types/views: add BenchmarkSliceIteration
...
```
goos: darwin
goarch: arm64
pkg: tailscale.com/types/views
BenchmarkSliceIteration/Len-10 340093 3212 ns/op 0 B/op 0 allocs/op
BenchmarkSliceIteration/Cached-Len-10 366727 3211 ns/op 0 B/op 0 allocs/op
BenchmarkSliceIteration/direct-10 361561 3290 ns/op 0 B/op 0 allocs/op
PASS
ok tailscale.com/types/views 3.662s
```
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-07-26 21:25:26 -07:00
Brad Fitzpatrick
a12aad6b47
all: convert more code to use net/netip directly
...
perl -i -npe 's,netaddr.IPPrefixFrom,netip.PrefixFrom,' $(git grep -l -F netaddr.)
perl -i -npe 's,netaddr.IPPortFrom,netip.AddrPortFrom,' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPrefix,netip.Prefix,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPPort,netip.AddrPort,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IP\b,netip.Addr,g' $(git grep -l -F netaddr. )
perl -i -npe 's,netaddr.IPv6Raw\b,netip.AddrFrom16,g' $(git grep -l -F netaddr. )
goimports -w .
Then delete some stuff from the net/netaddr shim package which is no
longer neeed.
Updates #5162
Change-Id: Ia7a86893fe21c7e3ee1ec823e8aba288d4566cd8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-25 21:53:49 -07:00
Brad Fitzpatrick
6a396731eb
all: use various net/netip parse funcs directly
...
Mechanical change with perl+goimports.
Changed {Must,}Parse{IP,IPPrefix,IPPort} to their netip variants, then
goimports -d .
Finally, removed the net/netaddr wrappers, to prevent future use.
Updates #5162
Change-Id: I59c0e38b5fbca5a935d701645789cddf3d7863ad
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-25 21:12:28 -07:00
Brad Fitzpatrick
7eaf5e509f
net/netaddr: start migrating to net/netip via new netaddr adapter package
...
Updates #5162
Change-Id: Id7bdec303b25471f69d542f8ce43805328d56c12
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-25 16:20:43 -07:00
Brad Fitzpatrick
43f3a969ca
types/views: add SliceContains, View.ContainsFunc, View.IndexFunc
...
We were starting to write these elsewhere as little unexported copies
in misc places.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-21 08:28:43 -07:00
Maisem Ali
6dae9e47f9
types/views: remove alloc in hot path
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-10 11:20:00 -07:00
Maisem Ali
395cb588b6
types/views: make SliceOf/MapOf panic if they see a pointer
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-09 19:49:31 -07:00
Maisem Ali
d04afc697c
cmd/viewer,types/views: add support for views of maps
...
Updates #4635
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-09 19:49:31 -07:00
Maisem Ali
c4e9739251
cmd/viewer: add codegen tool for Views
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-06 10:58:10 -07:00
Maisem Ali
bd073b8dd6
types/views: rename Generic to Unwrap
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-03-17 14:41:57 -07:00
Maisem Ali
6b9d938c1a
types/views: add generic Slice[T] and remove StringSlice
...
Also make IPPrefixSliceOf use Slice[netaddr.IPPrefix] as it also
provides additional functions besides the standard ones provided by
Slice[T].
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-03-16 22:13:16 -07:00
Maisem Ali
c85694fac4
types/views: add ContainsExitRoutes to IPPrefixSlice
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-03-04 09:08:42 -08:00
Maisem Ali
c7a8f0992d
ipn/ipnlocal: use views for Peer.PrimaryRoutes and Peer.Tags
...
RELNOTE=`tailscale status --json` now shows Tags and PrimaryRoutes
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-02-22 10:09:02 -08:00
Maisem Ali
53998e26a6
tailcfg: introduce HostinfoView
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-02-16 12:55:57 -08:00