summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)AuthorFilesLines
2021-05-04WIP log rate limiting testbradfitz/log_rate_testBrad Fitzpatrick3-6/+34
2021-05-04cmd/tailscale: gofmtBrad Fitzpatrick1-2/+2
From 6d10655dc3887f1a161015514a8555c175802b4d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-04workflows: run staticcheck on more platformsJosh Bleecher Snyder1-3/+15
To prevent issues like #1786, run staticcheck on the primary GOOSes: linux, mac, and windows. Windows also has a fair amount of GOARCH-specific code. If we ever have GOARCH staticcheck failures on other GOOSes, we can expand the test matrix further. This requires installing the staticcheck binary so that we can execute it with different GOOSes. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04ipnlocal: accept a new opts.UpdatePrefs field.Avery Pennarun4-3/+45
This is needed because the original opts.Prefs field was at some point subverted for use in frontend->backend state migration for backward compatibility on some platforms. We still need that feature, but we also need the feature of providing the full set of prefs from `tailscale up`, *not* including overwriting the prefs.Persist keys, so we can't use the original field from `tailscale up`. `tailscale up` had attempted to compensate for that by doing SetPrefs() before Start(), but that violates the ipn.Backend contract, which says you should call Start() before anything else (that's why it's called Start()). As a result, doing SetPrefs({ControlURL=..., WantRunning=true}) would cause a connection to the *previous* control server (because WantRunning=true), and then connect to the *new* control server only after running Start(). This problem may have been avoided before, but only by pure luck. It turned out to be relatively harmless since the connection to the old control server was immediately closed and replaced anyway, but it created a race condition that could have caused spurious notifications or rejected keys if the server responded quickly. As already covered by existing TODOs, a better fix would be to have Start() get out of the business of state migration altogether. But we're approaching a release so I want to make the minimum possible fix. Fixes #1840. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-05-04cmd/tailscale/cli: fix running from XcodeJosh Bleecher Snyder1-0/+8
We were over-eager in running tailscale in GUI mode. f42ded7acf63e2f3711f6512b701ddeac0e2d7a6 fixed that by checking for a variety of shell-ish env vars and using those to force us into CLI mode. However, for reasons I don't understand, those shell env vars are present when Xcode runs Tailscale.app on my machine. (I've changed no configs, modified nothing on a brand new machine.) Work around that by adding an additional "only in GUI mode" check. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04ipn/ipnlocal: update peerapi logging of received PUTsBrad Fitzpatrick1-1/+3
Clarify direction and add duration. (per chat with Avery) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-04syncs: stop running TestWatchMultipleValues on CIJosh Bleecher Snyder1-3/+2
It's flaky, and not just on Windows. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04ipn/ipnlocal: redact more errorsBrad Fitzpatrick1-7/+12
Updates tailscale/corp#1636 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-04wgengine/router: use net.IP.Equal instead of bytes.Equal to compare IPsJosh Bleecher Snyder1-2/+2
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04safesocket: delete unused functionJosh Bleecher Snyder1-4/+0
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04wgengine/router: remove unused fieldJosh Bleecher Snyder1-9/+0
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04portlist: suppress staticcheck errorJosh Bleecher Snyder1-1/+1
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04net/tstun: remove unnecessary break statementJosh Bleecher Snyder1-1/+0
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04logtail/filch: add staticcheck annotationJosh Bleecher Snyder1-0/+1
To work around a staticcheck bug when running with GOOS=windows. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04all: use lower-case letters at the start of error messageJosh Bleecher Snyder2-3/+3
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-04cmd/tailscale: fail if tailscaled closes the IPN connectionBrad Fitzpatrick3-7/+18
I was going to write a test for this using the tstest/integration test stuff, but the testcontrol implementation isn't quite there yet (it always registers nodes and doesn't provide AuthURLs). So, manually tested for now. Fixes #1843 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-03tstest/integration: misc cleanupsBrad Fitzpatrick1-28/+51
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-03tstest/integration: add testNode.AwaitListening, DERP+STUN, improve proxy trapBrad Fitzpatrick2-27/+132
Updates #1840
2021-05-03cmd/tailscale/cli: don't report outdated auth URL to web UIDavid Crawshaw1-6/+40
This brings the web 'up' logic into line with 'tailscale up'. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2021-05-03cmd/tailscale/cli: skip new tab on web loginDavid Crawshaw1-125/+118
It doesn't work properly. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2021-05-03paths: add synology socket pathDavid Crawshaw1-0/+7
Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2021-05-03wgenengine/magicsock: delete cursed testsJosh Bleecher Snyder1-152/+0
Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-03cmd/tailscale: make 'file cp' have better error messages on bad targetsBrad Fitzpatrick2-3/+29
Say when target isn't owned by current user, and when target doesn't exist in netmap. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-03ipn/ipnlocal: switch from testify to quicktestJosh Bleecher Snyder3-144/+138
Per discussion, we want to have only one test assertion library, and we want to start by exploring quicktest. This was a mostly mechanical translation. I think we could make this nicer by defining a few helper closures at the beginning of the test. Later. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-05-03cmd/tailscale: make pref-revert checks ignore OS-irrelevant prefsBrad Fitzpatrick2-9/+63
This fixes #1833 in two ways: * stop setting NoSNAT on non-Linux. It only matters on Linux and the flag is hidden on non-Linux, but the code was still setting it. Because of that, the new pref-reverting safety checks were failing when it was changing. * Ignore the two Linux-only prefs changing on non-Linux. Fixes #1833 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-03cmd/tailscale: pull out, parameterize up FlagSet creation for testsBrad Fitzpatrick3-21/+44
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-30tstest/integration: start factoring test types out to clean things upBrad Fitzpatrick1-41/+136
To enable easy multi-node testing (including inter-node traffic) later. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-30cmd/tailscale/cli: add test to catch ipn.Pref additionsBrad Fitzpatrick1-0/+24
2021-04-30cmd/tailscale/cli/up: "LoggedOut" pref is implicit.Avery Pennarun2-0/+27
There's no need to warn that it was not provided on the command line after doing a sequence of up; logout; up --args. If you're asking for tailscale to be up, you always mean that you prefer LoggedOut to become false. Fixes #1828 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30wgengine/wglog: improve wireguard-go logging rate limitingJosh Bleecher Snyder2-34/+54
Prior to wireguard-go using printf-style logging, all wireguard-go logging occurred using format string "%s". We fixed that but continued to use %s when we rewrote peer identifiers into Tailscale style. This commit removes that %sl, which makes rate limiting work correctly. As a happy side-benefit, it should generate less garbage. Instead of replacing all wireguard-go peer identifiers that might occur anywhere in a fully formatted log string, assume that they only come from args. Check all args for things that look like *device.Peers and replace them with appropriately reformatted strings. There is a variety of ways that this could go wrong (unusual format verbs or modifiers, peer identifiers occurring as part of a larger printed object, future API changes), but none of them occur now, are likely to be added, or would be hard to work around if they did. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-30wgengine/wglog: delay formattingJosh Bleecher Snyder1-5/+4
The "stop phrases" we use all occur in wireguard-go in the format string. We can avoid doing a bunch of fmt.Sprintf work when they appear. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-30ipn/ipnlocal: remove NewLocalBackendWithClientGenBrad Fitzpatrick2-21/+35
This removes the NewLocalBackendWithClientGen constructor added in b4d04a065fd384ca7f57891a2bb87e1ff5205fb6 and instead adds LocalBackend.SetControlClientGetterForTesting, mirroring LocalBackend.SetHTTPTestClient. NewLocalBackendWithClientGen was weird in being exported but taking an unexported type. This was noted during code review: https://github.com/tailscale/tailscale/pull/1818#discussion_r623155669 which ended in: "I'll leave it for y'all to clean up if you find some way to do it elegantly." This is more idiomatic. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-30ipnlocal: don't pause the controlclient until we get at least one netmap.apenwarr/statefixAvery Pennarun3-4/+10
Without this, macOS would fail to display its menu state correctly if you started it while !WantRunning. It relies on the netmap in order to show the logged-in username. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30ipn: !WantRunning + !LoggedOut should not be idle on startup.Avery Pennarun2-21/+26
There was logic that would make a "down" tailscale backend (ie. !WantRunning) refuse to do any network activity. Unfortunately, this makes the macOS and iOS UI unable to render correctly if they start while !WantRunning. Now that we have Prefs.LoggedOut, use that instead. So `tailscale down` will still allow the controlclient to connect its authroutine, but pause the maproutine. `tailscale logout` will entirely stop all activity. This new behaviour is not obviously correct; it's a bit annoying that `tailsale down` doesn't terminate all activity like you might expect. Maybe we should redesign the UI code to render differently when disconnected, and then revert this change. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30ipnlocal: setting WantRunning with EditPrefs was special.Avery Pennarun2-31/+38
EditPrefs should be just a wrapper around the action of changing prefs, but someone had added a side effect of calling Login() sometimes. The side effect happened *after* running the state machine, which would sometimes result in us going into NeedsLogin immediately before calling cc.Login(). This manifested as the macOS app not being able to Connect if you launched it with LoggedOut=false and WantRunning=false. Trying to Connect() would sent us to the NeedsLogin state instead. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30Add prefs.LoggedOut to fix several state machine bugs.Avery Pennarun5-68/+118
Fixes: tailscale/corp#1660 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30ipn/ipnlocal: some state_test cleanups.Avery Pennarun1-12/+38
This doesn't change the actual functionality. Just some additional comments and fine tuning. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30ipnlocal: fix deadlock when calling Shutdown() from Start().Avery Pennarun1-0/+2
Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30Revert "ipn/ipnlocal: be authoritative for the entire MagicDNS record tree."Avery Pennarun1-6/+0
Unfortunately this broke MagicDNS almost entirely. Updates: tailscale/corp#1706 This reverts commit 1d7e7b49eb8e16c31e41420deff527671a87dc0c.
2021-04-29tstest/integration/testcontrol: add start of test control serverBrad Fitzpatrick2-9/+573
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-30types/logger: rate limited: more hysteresis, better messages.Avery Pennarun5-41/+144
- Switch to our own simpler token bucket, since x/time/rate is missing necessary stuff (can't provide your own time func; can't check the current bucket contents) and it's overkill anyway. - Add tests that actually include advancing time. - Don't remove the rate limit on a message until there's enough room to print at least two more of them. When we do, we'll also print how many we dropped, as a contextual reminder that some were previously lost. (This is more like how the Linux kernel does it.) - Reformat the [RATE LIMITED] messages to be shorter, and to not corrupt original message. Instead, we print the message, then print its format string. - Use %q instead of \"%s\", for more accurate parsing later, if the format string contained quotes. Fixes #1772 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-29net/dns: add GOOS build tagsJosh Bleecher Snyder6-1/+11
Fixes #1786 Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-30ipn: mock controlclient.Client; big ipn.Backend state machine test.apenwarr/statetestAvery Pennarun4-41/+834
A very long unit test that verifies the way the controlclient and ipn.Backend interact. This is a giant sequential test of the state machine. The test passes, but only because it's asserting all the wrong behaviour. I marked all the behaviour I think is wrong with BUG comments, and several additional test opportunities with TODO. Note: the new test supercedes TestStartsInNeedsLoginState, which was checking for incorrect behaviour (although the new test still checks for the same incorrect behaviour) and assumed .Start() would converge before returning, which it happens to do, but only for this very specific case, for the current implementation. You're supposed to wait for the notifications. Updates: tailscale/corp#1660 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-30controlclient: extract a Client interface and rename Client->Auto.Avery Pennarun6-59/+152
This will let us create a mock or fake Client implementation for use with ipn.Backend. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-29controlclient: extract State and Status stuff into its own file.Avery Pennarun2-73/+88
No changes other than moving stuff around. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-04-29tstest/integration: use go binary from runtime.GOROOTBrad Fitzpatrick1-1/+22
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-29go.mod: update wireguard-go.David Anderson2-40/+4
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-29ipn/ipnlocal: be authoritative for the entire MagicDNS record tree.David Anderson1-0/+6
With this change, shared node names resolve correctly on split DNS-supporting operating systems. Fixes tailscale/corp#1706 Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-29tstest/integration: set an HTTP_PROXY to catch bogus requestsBrad Fitzpatrick1-1/+19
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-29testing: add start of an integration testBrad Fitzpatrick1-0/+175
Only minimal tailscale + tailscaled for now. And a super minimal in-memory logcatcher. No control ... yet. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>