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
2024008667
types/key: add MachinePrecomputedSharedKey.Open
...
Follow-up to cfdb862673
Updates tailscale/corp#1709
Change-Id: I7af931a2cb55f9006e1029381663ac21d1794242
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-22 12:05:29 -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
Brad Fitzpatrick
9bd3b5b89c
types/key: add ControlPrivate.Shared wrapper too
...
Follow-up to cfdb862673
.
Change-Id: Iab610d761f1e6d88e8bcb584d9c02cafe48fc377
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-19 14:49:01 -07:00
Brad Fitzpatrick
cfdb862673
types/key: add naclbox shared key wrapper type + Seal method
...
So the control plane can stop doing precomputations on each naclbox
message.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-07-19 14:18:12 -07:00
Brad Fitzpatrick
a1e429f7c3
control/controlclient, types/netmap: remove unused LocalPort field
...
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-19 17:22:00 -07:00
Melanie Warrick
3a182d5dd6
ipn/ipnstate: add ExitNodeStatus to share the exit node if it is in use, the IP, ID and whether its online. ( #4761 )
...
-
Updates #4619
Signed-off-by: nyghtowl <warrick@tailscale.com>
2022-06-07 12:31:10 -07:00
Brad Fitzpatrick
4d85cf586b
cmd/tailscale, ipn/ipnlocal: add "peerapi" ping type
...
For debugging when stuff like #4750 isn't working.
RELNOTE=tailscale ping -peerapi
Change-Id: I9c52c90fb046e3ab7d2b121387073319fbf27b99
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-05-28 13:47:12 -07:00
Tom
ec4c49a338
types/key: make NodePublic implement Shardable ( #4698 )
...
Needed for an experiment in Control.
Signed-off-by: Tom DNetto <tom@tailscale.com>
2022-05-17 10:37:25 -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
9f3ad40707
tailcfg: use cmd/viewer instead of cmd/cloner.
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-06 10:58:10 -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
e409e59a54
cmd/cloner,util/codegen: refactor cloner internals to allow reuse
...
Also run go generate again for Copyright updates.
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-05-06 10:58:10 -07:00
Brad Fitzpatrick
cc575fe4d6
net/dns: schedule DoH upgrade explicitly, fix Resolver.Addr confusion
...
Two changes in one:
* make DoH upgrades an explicitly scheduled send earlier, when we come
up with the resolvers-and-delay send plan. Previously we were
getting e.g. four Google DNS IPs and then spreading them out in
time (for back when we only did UDP) but then later we added DoH
upgrading at the UDP packet layer, which resulted in sometimes
multiple DoH queries to the same provider running (each doing happy
eyeballs dialing to 4x IPs themselves) for each of the 4 source IPs.
Instead, take those 4 Google/Cloudflare IPs and schedule 5 things:
first the DoH query (which can use all 4 IPs), and then each of the
4 IPs as UDP later.
* clean up the dnstype.Resolver.Addr confusion; half the code was
using it as an IP string (as documented) as half was using it as
an IP:port (from some prior type we used), primarily for tests.
Instead, document it was being primarily an IP string but also
accepting an IP:port for tests, then add an accessor method on it
to get the IPPort and use that consistently everywhere.
Change-Id: Ifdd72b9e45433a5b9c029194d50db2b9f9217b53
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-04-19 12:00:22 -07:00
Joe Tsai
01adcfa688
tailcfg: add omitempty to all fields of Hostinfo ( #4360 )
...
This reduces the noise when marshaling only a subset of this type.
Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2022-04-05 13:25:14 -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
Josh Bleecher Snyder
0868329936
all: use any instead of interface{}
...
My favorite part of generics.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2022-03-17 11:35:09 -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
Brad Fitzpatrick
61ee72940c
all: use Go 1.18's strings.Cut
...
More remain.
Change-Id: I6ec562cc1f687600758deae1c9d7dbd0d04004cb
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-03-16 14:53:59 -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
Josh Bleecher Snyder
66f5aa6814
types/logger: add more reserved top level field names
...
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2022-02-18 15:21:35 -08:00
Brad Fitzpatrick
84138450a4
types/logger, logtail: add mechanism to do structured JSON logs
...
e.g. the change to ipnlocal in this commit ultimately logs out:
{"logtail":{"client_time":"2022-02-17T20:40:30.511381153-08:00","server_time":"2022-02-18T04:40:31.057771504Z"},"type":"Hostinfo","val":{"GoArch":"amd64","Hostname":"tsdev","IPNVersion":"1.21.0-date.20220107","OS":"linux","OSVersion":"Debian 11.2 (bullseye); kernel=5.10.0-10-amd64"},"v":1}
Change-Id: I668646b19aeae4a2fed05170d7b279456829c844
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-02-18 12:42:06 -08:00
Maisem Ali
72d8672ef7
tailcfg: make Node.Hostinfo a HostinfoView
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-02-16 12:55:57 -08:00
Maisem Ali
53998e26a6
tailcfg: introduce HostinfoView
...
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-02-16 12:55:57 -08:00
Brad Fitzpatrick
57115e923e
tailcfg: add start of SSH policy to be sent from control plane to nodes
...
Updates #3802
Change-Id: Iec58f35d445aaa267d0f7e7e2f30c049c1df4c0e
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-02-15 16:05:42 -08:00
Brad Fitzpatrick
857cd6c0d7
ipn/ipnstate: add TailnetName to status
...
RELNOTE=tailscale status --json | jq .TailnetName
Fixes tailscale/corp#3665
Change-Id: I85de027ba2781eb31ee1e0c5ab913b0dfa5b4c86
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-01-26 10:08:39 -08:00
Brad Fitzpatrick
41fd4eab5c
envknob: add new package for all the strconv.ParseBool(os.Getenv(..))
...
A new package can also later record/report which knobs are checked and
set. It also makes the code cleaner & easier to grep for env knobs.
Change-Id: Id8a123ab7539f1fadbd27e0cbeac79c2e4f09751
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-01-24 11:51:23 -08:00
Josh Bleecher Snyder
deb2f5e793
types/logger: add Context and related helpers
...
We often need both a log function and a context.
We can do this by adding the log function as a context value.
This commit adds helper glue to make that easy.
It is designed to allow incremental adoption.
Updates tailscale/corp#3138
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-11-30 15:18:21 -08:00
David Anderson
293431aaea
control/noise: use key.Machine{Public,Private} as appropriate.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-11-10 12:13:54 -08:00
David Anderson
0532eb30db
all: replace tailcfg.DiscoKey with key.DiscoPublic.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-11-03 14:00:16 -07:00
David Anderson
17b5782b3a
types/key: delete legacy NodeKey type.
...
Fixes #3206
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-11-02 14:14:32 -07:00
David Anderson
7e6a1ef4f1
tailcfg: use key.NodePublic in wire protocol types.
...
Updates #3206 .
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-11-02 09:11:43 -07:00
David Anderson
d6e7cec6a7
types/netmap: use key.NodePublic instead of tailcfg.NodeKey.
...
Update #3206
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-11-01 17:07:40 -07:00
David Anderson
84c3a09a8d
types/key: export constants for key size, not a method.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 17:39:04 -07:00
David Anderson
ff16e58d23
tailcfg: move NodeKey type to types/key.
...
This leaves behind a type alias and associated constructor, to allow
for gradual switchover.
Updates #3206 .
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 16:04:45 -07:00
David Anderson
b43362852c
types/key: delete legacy undifferentiated key types.
...
Updates #3206
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 15:01:12 -07:00
David Anderson
743293d473
types/key: remove node key AsPublic/AsPrivate compat shims.
...
Updates #3206 .
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 14:48:36 -07:00
David Anderson
ef241f782e
wgengine/magicsock: remove uses of tailcfg.DiscoKey.
...
Updates #3206
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 14:31:44 -07:00
David Anderson
073a3ec416
types/key: correct ShortString representation of DiscoPublic.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 14:31:44 -07:00
David Anderson
06dccea416
types/key: fix license header on disco files.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 13:45:49 -07:00
David Anderson
05cc2f510b
types/key: new types for disco keys.
...
Needed for #3206 to remove final uses of key.{Public,Private}.
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-29 13:44:02 -07:00
David Anderson
15376f975b
types/wgkey: delete, no longer used.
...
Updates #3206
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-28 14:53:38 -07:00
Josh Bleecher Snyder
94fb42d4b2
all: use testingutil.MinAllocsPerRun
...
There are a few remaining uses of testing.AllocsPerRun:
Two in which we only log the number of allocations,
and one in which dynamically calculate the allocations
target based on a different AllocsPerRun run.
This also allows us to tighten the "no allocs"
test in wgengine/filter.
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-10-28 12:48:37 -07:00
David Anderson
6e5175373e
types/netmap: use new node key type.
...
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-10-28 10:44:34 -07:00