summaryrefslogtreecommitdiffhomepage
path: root/cmd
AgeCommit message (Collapse)AuthorFilesLines
2021-05-17cmd/tailscale{,d}: combine into a single binaryonebinaryDenton Gentry19-4/+20
To reduce size, combine tailscaled and tailscale into a single binary which will figure out what it should do based on argv[0]. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2021-05-16all: adapt to opaque netaddr typesJosh Bleecher Snyder4-13/+13
This commit is a mishmash of automated edits using gofmt: gofmt -r 'netaddr.IPPort{IP: a, Port: b} -> netaddr.IPPortFrom(a, b)' -w . gofmt -r 'netaddr.IPPrefix{IP: a, Port: b} -> netaddr.IPPrefixFrom(a, b)' -w . gofmt -r 'a.IP.Is4 -> a.IP().Is4' -w . gofmt -r 'a.IP.As16 -> a.IP().As16' -w . gofmt -r 'a.IP.Is6 -> a.IP().Is6' -w . gofmt -r 'a.IP.As4 -> a.IP().As4' -w . gofmt -r 'a.IP.String -> a.IP().String' -w . And regexps: \w*(.*)\.Port = (.*) -> $1 = $1.WithPort($2) \w*(.*)\.IP = (.*) -> $1 = $1.WithIP($2) And lots of manual fixups. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-13cmd/tailscale: make ping --until-direct require direct connection to exit 0Josh Bleecher Snyder1-0/+3
If --until-direct is set, the goal is to make a direct connection. If we failed at that, say so, and exit with an error. RELNOTE=tailscale ping --until-direct (the default) now exits with a non-zero exit code if no direct connection was established. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-11internal/deephash: rename from deepprintBrad Fitzpatrick1-1/+1
Yes, it printed, but that was an implementation detail for hashing. And coming optimization will make it print even less. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-10wf: implement windows firewall using inet.af/wf.Maisem Ali1-1/+1
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2021-05-07cmd/tailscale: rewrite the "up" checker, fix bugsBrad Fitzpatrick2-358/+375
The old way was way too fragile and had felt like it had more special cases than normal cases. (see #1874, #1860, #1834, etc) It became very obvious the old algorithm didn't work when we made the output be pretty and try to show the user the command they need to run in 5ecc7c7200bda43f02f9a04fb684ad4f3614c48a for #1746) The new algorithm is to map the prefs (current and new) back to flags and then compare flags. This nicely handles the OS-specific flags and the n:1 and 1:n flag:pref cases. No change in the existing already-massive test suite, except some ordering differences (the missing items are now sorted), but some new tests are added for behavior that was broken before. In particular, it now: * preserves non-pref boolean flags set to false, and preserves exit node IPs (mapping them back from the ExitNodeID pref, as well as ExitNodeIP), * doesn't ignore --advertise-exit-node when doing an EditPrefs call (#1880) * doesn't lose the --operator on the non-EditPrefs paths (e.g. with --force-reauth, or when the backend was not in state Running). Fixes #1880 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-06cmd/tailscale: fix another up warning with exit nodesBrad Fitzpatrick2-147/+124
The --advertise-routes and --advertise-exit-node flags both mutating one pref is the gift that keeps on giving. I need to rewrite the this up warning code to first map prefs back to flag values and then just compare flags instead of comparing prefs, but this is the minimal fix for now. This also includes work on the tests, to make them easier to write (and more accurate), by letting you write the flag args directly and have that parse into the upArgs/MaskedPrefs directly, the same as the code, rather than them being possibly out of sync being written by hand. Fixes https://twitter.com/EXPbits/status/1390418145047887877 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-05cmd/tailscale: fix tailscale up --advertise-exit-node validationBrad Fitzpatrick2-6/+117
Fixes #1859 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-04cmd/tailscale: gofmtBrad Fitzpatrick1-2/+2
From 6d10655dc3887f1a161015514a8555c175802b4d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-04ipnlocal: accept a new opts.UpdatePrefs field.Avery Pennarun1-2/+1
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-04all: use lower-case letters at the start of error messageJosh Bleecher Snyder1-2/+2
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-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-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-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 Fitzpatrick2-19/+38
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-30types/logger: rate limited: more hysteresis, better messages.Avery Pennarun2-2/+2
- 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 Snyder1-1/+1
Fixes #1786 Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-29net/interfaces: return all Tailscale addresses from Tailscale().David Anderson1-2/+9
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-28wgengine/magicsock: unify initial bind and rebindJosh Bleecher Snyder1-0/+1
We had two separate code paths for the initial UDP listener bind and any subsequent rebinds. IPv6 got left out of the rebind code. Rather than duplicate it there, unify the two code paths. Then improve the resulting code: * Rebind had nested listen attempts to try the user-specified port first, and then fall back to :0 if that failed. Convert that into a loop. * Initial bind tried only the user-specified port. Rebind tried the user-specified port and 0. But there are actually three ports of interest: The one the user specified, the most recent port in use, and 0. We now try all three in order, as appropriate. * In the extremely rare case in which binding to port 0 fails, use a dummy net.PacketConn whose reads block until close. This will keep the wireguard-go receive func goroutine alive. As a pleasant side-effect of this, if we decide that we need to resuscitate #1796, it will now be much easier. Fixes #1799 Co-authored-by: David Anderson <danderson@tailscale.com> Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-28wgengine/magicsock: remove DefaultPort constJosh Bleecher Snyder2-3/+2
Assume it'll stay at 0 forever, so hard-code it and delete code conditional on it being non-0. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-28cmd/tailscale: improve file cp error message in macOS GUI versionBrad Fitzpatrick1-0/+4
Fixes tailscale/corp#1684 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-27cmd/tailscale: add 'tailscale file get' subcommandBrad Fitzpatrick2-2/+141
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-27cmd/tailscale/cli: rename 'tailscale push' to 'tailscale file cp'Brad Fitzpatrick3-229/+276
And reverse order, require final colon, and support multiple files. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-27cmd/tailscale: fix typo in error message (#1807)Ross Zurowski1-1/+1
Signed-off-by: Ross Zurowski <ross@rosszurowski.com>
2021-04-26cmd/tailscale: make the new 'up' errors prettier and more helpfulBrad Fitzpatrick3-19/+127
Fixes #1746 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-26cmd/tailscale/cli: don't do a simple up when in state NeedsLoginBrad Fitzpatrick1-1/+4
Fixes #1780 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-23net/dns: don't use NM+resolved for NM >=1.26.6.David Anderson1-0/+1
NetworkManager fixed the bug that forced us to use NetworkManager if it's programming systemd-resolved, and in the same release also made NetworkManager ignore DNS settings provided for unmanaged interfaces... Which breaks what we used to do. So, with versions 1.26.6 and above, we MUST NOT use NetworkManager to indirectly program systemd-resolved, but thankfully we can talk to resolved directly and get the right outcome. Fixes #1788 Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-23ipn/ipnlocal: add file sharing to windows shellAleksandar Pesic3-1/+12
Updates: tailscale/winmin#33 Signed-off-by: Aleksandar Pesic <peske.nis@gmail.com>
2021-04-23cmd/tailscale/cli: add test for already-submitted #1777Brad Fitzpatrick1-0/+16
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-22cmd/tailscale/cli: don't force an interactive login on --reset.David Anderson1-1/+3
Fixes #1778 Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-22cmd/tailscale/cli: fix typo in ExitNodeID mapping.David Anderson1-1/+1
Prevented turning off exit nodes. Fixes #1777 Signed-off-by: David Anderson <danderson@tailscale.com>
2021-04-22cmd/tailscale: only send file basename in pushBrad Fitzpatrick1-1/+2
Fixes #1640 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-22cmd/tailscale: don't print out old authURL on up --force-reauthBrad Fitzpatrick1-1/+18
Fixes #1671 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-21cmd/tailscale: don't print auth URL when using a --authkeyBrad Fitzpatrick1-1/+1
Fixes #1755 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-21cmd/tailscale/cli: make 'tailscale up' protect --advertise-exit-node removalBrad Fitzpatrick2-0/+118
The new "tailscale up" checks previously didn't protect against --advertise-exit-node being omitted in the case that --advertise-routes was also provided. It wasn't done before because there is no corresponding pref for "--advertise-exit-node"; it's a helper flag that augments --advertise-routes. But that's an implementation detail and we can still help users. We just have to special case that pref and look whether the current routes include both the v4 and v6 /0 routes. Fixes #1767 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-21cmd/tailscale/cli: show online/offline status in push --file-targetsBrad Fitzpatrick1-15/+24
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-21cmd/tailscale/cli: don't require explicit --operator if it matches $USERBrad Fitzpatrick2-3/+41
This doesn't make --operator implicit (which we might do in the future), but it at least doesn't require repeating it in the future when it already matches $USER. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-20cmd/tailscaled: don't block ipnserver startup behind engine init on WindowsBrad Fitzpatrick1-47/+67
With this change, the ipnserver's safesocket.Listen (the localhost tcp.Listen) happens right away, before any synchronous TUN/DNS/Engine/etc setup work, which might be slow, especially on early boot on Windows. Because the safesocket.Listen starts up early, that means localhost TCP dials (the safesocket.Connect from the GUI) complete successfully and thus the GUI avoids the MessageBox error. (I verified that pacifies it, even without a Listener.Accept; I'd feared that Windows localhost was maybe special and avoided the normal listener backlog). Once the GUI can then connect immediately without errors, the various timeouts then matter less, because the backend is no longer trying to race against the GUI's timeout. So keep retrying on errors for a minute, or 10 minutes if the system just booted in the past 10 minutes. This should fix the problem with Windows 10 desktops auto-logging in and starting the Tailscale frontend which was then showing a MessageBox error about failing to connect to tailscaled, which was slow coming up because the Windows networking stack wasn't up yet. Fingers crossed. Fixes #1313 (previously #1187, etc) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-20cmd/tailscaled: add subcommands to install and remove tailscaled Windows serviceAlex Brainman2-1/+121
This change implements Windows version of install-system-daemon and uninstall-system-daemon subcommands. When running the commands the user will install or remove Tailscale Windows service. Updates #1232 Signed-off-by: Alex Brainman <alex.brainman@gmail.com>
2021-04-20ipn: don't Logout when Windows GUI disconnectsBrad Fitzpatrick1-1/+1
Logout used to be a no-op, so the ipnserver previously synthensized a Logout on disconnect. Now that Logout actually invalidates the node key that was forcing all GUI closes to log people out. Instead, add a method to LocalBackend to specifically mean "the Windows GUI closed, please forget all the state". Fixes tailscale/corp#1591 (ignoring the notification issues, tracked elsewhere) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-20cmd/tailscale/cli: relax & improve the running-as-CLI check for macOSBrad Fitzpatrick1-5/+28
On macOS, we link the CLI into the GUI executable so it can be included in the Mac App Store build. You then need to run it like: /Applications/Tailscale.app/Contents/MacOS/Tailscale <command> But our old detection of whether you're running that Tailscale binary in CLI mode wasn't accurate and often bit people. For instance, when they made a typo, it then launched in GUI mode and broke their existing GUI connection (starting a new IPNExtension) and took down their network. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-19ipn, cmd/tailscale/cli: add pref to configure sudo-free operator userBrad Fitzpatrick1-1/+8
From discussion with @danderson. Fixes #1684 (in a different way) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-18ipn{,/ipnlocal}, cmd/tailscale/cli: don't check pref reverts on initial upBrad Fitzpatrick2-0/+45
The ipn.NewPrefs func returns a populated ipn.Prefs for historical reasons. It's not used or as important as it once was, but it hasn't yet been removed. Meanwhile, it contains some default values that are used on some platforms. Notably, for this bug (#1725), Windows/Mac use its Prefs.RouteAll true value (to accept subnets), but Linux users have always gotten a "false" value for that, because that's what cmd/tailscale's CLI default flag is _for all operating systems_. That meant that "tailscale up" was rightfully reporting that the user was changing an implicit setting: RouteAll was changing from true with false with the user explicitly saying so. An obvious fix might be to change ipn.NewPrefs to return Prefs.RouteAll == false on some platforms, but the logic is complicated by darwin: we want RouteAll true on windows, android, ios, and the GUI mac app, but not the CLI tailscaled-on-macOS mode. But even if we used build tags (e.g. the "redo" build tag) to determine what the default is, that then means we have duplicated and differing "defaults" between both the CLI up flags and ipn.NewPrefs. Furthering that complication didn't seem like a good idea. So, changing the NewPrefs defaults is too invasive at this stage of the release, as is removing the NewPrefs func entirely. Instead, tweak slightly the semantics of the ipn.Prefs.ControlURL field. This now defines that a ControlURL of the empty string means both "we're uninitialized" and also "just use the default". Then, once we have the "empty-string-means-unintialized" semantics, use that to suppress "tailscale up"'s recent implicit-setting-revert checking safety net, if we've never initialized Tailscale yet. And update/add tests. Fixes #1725 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-18ipn: add DefaultControlURL const, replace few literals with itBrad Fitzpatrick2-2/+2
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-04-17cmd/tailscale/cli: pull out prefsFromUpArgs for testability, add testsBrad Fitzpatrick2-41/+224
Will add more tests later but this locks in all the existing warnings and errors at least, and some of the existing non-error behavior. Mostly I want this to exist before I actually fix #1725. Updates #1725 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>