summaryrefslogtreecommitdiffhomepage
path: root/ipn/ipnserver
AgeCommit message (Collapse)AuthorFilesLines
2021-01-15ipn, ipnserver: only require sudo on Linux for mutable CLI actionsBrad Fitzpatrick3-4/+84
This partially reverts d6e9fb1df0fd6, which modified the permissions on the tailscaled Unix socket and thus required "sudo tailscale" even for "tailscale status". Instead, open the permissions back up (on Linux only) but have the server look at the peer creds and only permit read-only actions unless you're root. In the future we'll also have a group that can do mutable actions. On OpenBSD and FreeBSD, the permissions on the socket remain locked down to 0600 from d6e9fb1df0fd6. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-01-11cmd/tailscaled, wgengine/netstack: add start of gvisor userspace netstack workBrad Fitzpatrick1-1/+1
Not usefully functional yet (mostly a proof of concept), but getting it submitted for some work @namansood is going to do atop this. Updates #707 Updates #634 Updates #48 Updates #835
2020-12-21all: annotate log verbosity levels on most egregiously spammy log printsBrad Fitzpatrick1-2/+4
Fixes #924 Fixes #282 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-12-15ipn/ipnserver: enable systemd-notify supportChristine Dodrill1-0/+2
Addresses #964 Still to be done: - Figure out the correct logging lines in util/systemd - Figure out if we need to slip the systemd.Status function anywhere else - Log util/systemd errors? (most of the errors are of the "you cannot do anything about this, but it might be a bad idea to crash the program if it errors" kind) Assistance in getting this over the finish line would help a lot. Signed-off-by: Christine Dodrill <me@christine.website> util/systemd: rename the nonlinux file to appease the magic Signed-off-by: Christine Dodrill <me@christine.website> util/systemd: fix package name Signed-off-by: Christine Dodrill <me@christine.website> util/systemd: fix review feedback from @mdlayher Signed-off-by: Christine Dodrill <me@christine.website> cmd/tailscale{,d}: update depaware manifests Signed-off-by: Christine Dodrill <me@christine.website> util/systemd: use sync.Once instead of func init Signed-off-by: Christine Dodrill <me@christine.website> control/controlclient: minor review feedback fixes Signed-off-by: Christine Dodrill <me@christine.website> {control,ipn,systemd}: fix review feedback Signed-off-by: Christine Dodrill <me@christine.website> review feedback fixes Signed-off-by: Christine Dodrill <me@christine.website> ipn: fix sprintf call Signed-off-by: Christine Dodrill <me@christine.website> ipn: make staticcheck less sad Signed-off-by: Christine Dodrill <me@christine.website> ipn: print IP address in connected status Signed-off-by: Christine Dodrill <me@christine.website> ipn: review feedback Signed-off-by: Christine Dodrill <me@christine.website> final fixups Signed-off-by: Christine Dodrill <me@christine.website>
2020-11-17ipn/ipnserver: add knob to disable babysitterBrad Fitzpatrick1-0/+4
2020-11-02ipn: only use Prefs, not computed stateKey, to determine server modeBrad Fitzpatrick1-1/+1
When the service was running without a client (e.g. after a reboot) and then the owner logs in and the GUI attaches, the computed state key changed to "" (driven by frontend prefs), and then it was falling out of server mode, despite the GUI-provided prefs still saying it wanted server mode. Also add some logging. And remove a scary "Access denied" from a user-visible error, making the two possible already-in-use error messages consistent with each other.
2020-11-02ipn, ipn/ipnserver: add IPN state for server in use, handle explicitlyBrad Fitzpatrick1-24/+113
On Windows, we were previously treating a server used by different users as a fatal error, which meant the second user (upon starting Tailscale, explicitly or via Start Up programs) got an invasive error message dialog. Instead, give it its own IPN state and change the Notify.ErrMessage to be details in that state. Then the Windows GUI can be less aggresive about that happening. Also, * wait to close the IPN connection until the server ownership state changes so the GUI doesn't need to repeatedly reconnect to discover changes. * fix a bug discovered during testing: on system reboot, the ipnserver's serverModeUser was getting cleared while the state transitioned from Unknown to Running. Instead, track 'inServerMode' explicitly and remove the old accessor method which was error prone. * fix a rare bug where the client could start up and set the server mode prefs in its Start call and we wouldn't persist that to the StateStore storage's prefs start key. (Previously it was only via a prefs toggle at runtime)
2020-11-02ipn/ipnserver: remove "Server mode" from a user-visible error messageBrad Fitzpatrick1-1/+1
That's an internal nickname.
2020-10-29ipn/ipnserver: move Windows local disk logging up to the parent processBrad Fitzpatrick1-0/+14
To capture panics, log.Printf writes to os.Stderr, etc. Fixes #726
2020-10-29ipn/ipnserver: work around os/user.LookupId failure on WindowsBrad Fitzpatrick1-3/+19
If we can't find the mapping from SID ("user ID") -> username, don't treat that as a fatal. Apparently that happens in the wild for Reasons. Ignore it for now. It's just a nice-to-have for error messages in the rare multi-user case. Updates #869 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-10-28version: use OSS repo's version when building.David Anderson1-1/+1
When building with redo, also include the git commit hash from the proprietary repo, so that we have a precise commit that identifies all build info (including Go toolchain version). Add a top-level build script demonstrating to downstream distros how to burn the right information into builds. Adjust `tailscale version` to print commit hashes when available. Fixes #841. Signed-off-by: David Anderson <danderson@tailscale.com>
2020-10-12ipn, ipnserver, cmd/tailscale: add "server mode" support on WindowsBrad Fitzpatrick1-12/+114
This partially (but not yet fully) migrates Windows to tailscaled's StateStore storage system. This adds a new bool Pref, ForceDaemon, defined as: // ForceDaemon specifies whether a platform that normally // operates in "client mode" (that is, requires an active user // logged in with the GUI app running) should keep running after the // GUI ends and/or the user logs out. // // The only current applicable platform is Windows. This // forced Windows to go into "server mode" where Tailscale is // running even with no users logged in. This might also be // used for macOS in the future. This setting has no effect // for Linux/etc, which always operate in daemon mode. Then, when ForceDaemon becomes true, we now write use the StateStore to track which user started it in server mode, and store their prefs under that key. The ipnserver validates the connections/identities and informs that LocalBackend which userid is currently in charge. The GUI can then enable/disable server mode at runtime, without using the CLI. But the "tailscale up" CLI was also fixed, so Windows users can use authkeys or ACL tags, etc. Updates #275
2020-10-09ipn/ipnserver: prevent use by multiple Windows users, add HTML status pageBrad Fitzpatrick1-54/+150
It was previously possible for two different Windows users to connect to the IPN server at once, but it didn't really work. They mostly stepped on each other's toes and caused chaos. Now only one can control it, but it can be active for everybody else. Necessary dependency step for Windows server/headless mode (#275) While here, finish wiring up the HTTP status page on Windows, now that all the dependent pieces are available.
2020-10-02all: use testing.T.TempDirJosh Bleecher Snyder1-7/+1
Bit of Friday cleanup. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-09-11ipn/ipnserver: make ipnserver also be an HTTP server for localhost clientsBrad Fitzpatrick1-1/+99
For now it just says hello to show auth works. More later.
2020-08-09backoff: update to Go style, document a bit, make 30s explicitBrad Fitzpatrick1-2/+2
Also, bit of behavior change: on non-nil err but expired context, don't reset the consecutive failure count. I don't think the old behavior was intentional. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-29ipn/ipnserver: fix bug in earlier commit where conn can be strandedBrad Fitzpatrick1-5/+15
If a connection causes getEngine to transition from broken to fixed, that connection was getting lost.
2020-07-29ipn/ipnserver: staticcheck is not wrongBrad Fitzpatrick1-2/+3
shamecube.gif
2020-07-29ipn/ipnserver: make Engine argument a func that tries again for each connectionBrad Fitzpatrick2-11/+23
So a backend in server-an-error state (as used by Windows) can try to create a new Engine again each time somebody re-connects, relaunching the GUI app. (The proper fix is actually fixing Windows issues, but this makes things better in the short term) Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-15ipn/ipnserver: support simultaneous connectionsv0.100.0-107Brad Fitzpatrick1-68/+96
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-07-13cmd/tailscaled: graceful shutdown (#534)Dmytro Shynkevych1-0/+1
Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
2020-07-08ipn, ipn/ipnserver: add support for serving in error-message-only modeBrad Fitzpatrick1-5/+35
So Windows service failures can be propagated to the Windows UI client.
2020-07-02smallzstd: new package that constructs zstd small encoders/decoders.David Anderson1-5/+2
It's just a config wrapper that passes "use less memory at the expense of compression" parameters by default, so that we don't accidentally construct resource-hungry (de)compressors. Also includes a benchmark that measures the memory cost of the small variants vs. the stock variants. The savings are significant on both compressors (~8x less memory) and decompressors (~1.4x less, not including the savings from the significantly smaller window on the compression side - with those savings included it's more like ~140x smaller). BenchmarkSmallEncoder-8 56174 19354 ns/op 31 B/op 0 allocs/op BenchmarkSmallEncoderWithBuild-8 2900 382940 ns/op 1746547 B/op 36 allocs/op BenchmarkStockEncoder-8 48921 25761 ns/op 286 B/op 0 allocs/op BenchmarkStockEncoderWithBuild-8 426 2630241 ns/op 13843842 B/op 124 allocs/op BenchmarkSmallDecoder-8 123814 9344 ns/op 0 B/op 0 allocs/op BenchmarkSmallDecoderWithBuild-8 41547 27455 ns/op 27694 B/op 31 allocs/op BenchmarkStockDecoder-8 129832 9417 ns/op 1 B/op 0 allocs/op BenchmarkStockDecoderWithBuild-8 25561 51751 ns/op 39607 B/op 92 allocs/op Signed-off-by: David Anderson <danderson@tailscale.com>
2020-06-03ipn/ipnserver: revert decoder memory limit.David Anderson1-1/+0
The zstd library treats that limit as a hard cap on decompressed size, in the mode we're using it, rather than a window size. Signed-off-by: David Anderson <danderson@tailscale.com>
2020-05-20ipnserver and logpolicy: configure zstd with low-memory settings.Avery Pennarun1-1/+5
The compressed blobs we send back and forth are small and infrequent, which doesn't justify the 8MB * GOMAXPROCS memory that was being allocated. This was the overwhelming majority of memory use in tailscaled. On my system it goes from ~100M RSS to ~15M RSS (which is still suspiciously high, but we can worry about that more later). Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-15wgengine: log node IDs when peers are added/removed (#381)Wendi Yu1-5/+1
Also stop logging data sent/received from nodes we're not connected to (ie all those `x`s being logged in the `peers: ` line) Signed-off-by: Wendi <wendi.yu@yahoo.ca>
2020-05-13Add tstest.PanicOnLog(), and fix various problems detected by this.Avery Pennarun1-2/+2
If a test calls log.Printf, 'go test' horrifyingly rearranges the output to no longer be in chronological order, which makes debugging virtually impossible. Let's stop that from happening by making log.Printf panic if called from any module, no matter how deep, during tests. This required us to change the default error handler in at least one http.Server, as well as plumbing a bunch of logf functions around, especially in magicsock and wgengine, but also in logtail and backoff. To add insult to injury, 'go test' also rearranges the output when a parent test has multiple sub-tests (all the sub-test's t.Logf is always printed after all the parent tests t.Logf), so we need to screw around with a special Logf that can point at the "current" t (current_t.Logf) in some places. Probably our entire way of using subtests is wrong, since 'go test' would probably like to run them all in parallel if you called t.Parallel(), but it definitely can't because the're all manipulating the shared state created by the parent test. They should probably all be separate toplevel tests instead, with common setup/teardown logic. But that's a job for another time. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-08Implement rate limiting on log messages (#356)Wendi Yu1-1/+5
Implement rate limiting on log messages Addresses issue #317, where logs can get spammed with the same message nonstop. Created a rate limiting closure on logging functions, which limits the number of messages being logged per second based on format string. To keep memory usage as constant as possible, the previous cache purging at periodic time intervals has been replaced by an LRU that discards the oldest string when the capacity of the cache is reached. Signed-off-by: Wendi Yu <wendi.yu@yahoo.ca>
2020-04-11all: remove unnecessary trailing newlines in format patterns for consistencyBrad Fitzpatrick1-13/+12
And document on logger.Logf that it's unnecessary.
2020-03-27cmd/tailscale: add status subcommandBrad Fitzpatrick1-100/+4
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-03-26cmd/tailscaled, wgengine, ipn: add /debug/ipn handler with world stateBrad Fitzpatrick1-0/+110
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-03-12controlclient/netmap: write our own b.ConciseDiffFrom(a) function.Avery Pennarun1-2/+0
This removes the need for go-cmp, which is extremely bloaty so we had to leave it out of iOS. As a result, we had also left it out of macOS, and so we didn't print netmap diffs at all on darwin-based platforms. Oops. As a bonus, the output format of the new function is way better. Minor oddity: because I used the dumbest possible diff algorithm, the sort order is a bit dumb. We print all "removed" lines and then print all "added" lines, rather than doing the usual diff-like thing of interspersing them. This probably doesn't matter (maybe it's an improvement).
2020-03-03ipn/ipnserver: remove unnecessary closure parameterBrad Fitzpatrick1-2/+2
2020-03-03ipn/ipnserver: document potential race, start on test for itBrad Fitzpatrick2-1/+78
2020-02-25types/logger: add WithPrefix, use it in two placesBrad Fitzpatrick1-5/+2
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-25ipn: misc cleanupBrad Fitzpatrick1-11/+17
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-20ipn: temporary support for loading legacy relaynode configs.David Anderson1-1/+11
Signed-off-by: David Anderson <dave@natulte.net>
2020-02-19ipn: move Options.ServerURL into Prefs.David Anderson1-10/+1
We can't rely on a frontend to provide a control server URL, so this naturally belongs in server-persisted state. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-18safesocket: simplify API.David Anderson1-1/+7
On unix, we want to provide a full path to the desired unix socket. On windows, currently we want to provide a TCP port, but someday we'll also provide a "path-ish" object for a named pipe. For now, simplify the API down to exactly a path and a TCP port. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-17cmd/tailscaled: run off internal state autonomously.David Anderson1-8/+37
With this change, tailscaled can be restarted and reconnect without interaction from `tailscale`, and `tailscale` is merely there to provide login assistance and adjust preferences. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-14Move "logger" package to under types, now that we have it.Brad Fitzpatrick1-1/+1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2020-02-14ipn/ipnserver: remove Options.AllowQuit.David Anderson1-6/+2
It was previously used by the MacOS client, but it now does something different. ipnserver should never obey a client's request to exit. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-13Introduce a state store to LocalBackend.David Anderson1-1/+12
The store is passed-in by callers of NewLocalBackend and ipnserver.Run, but currently all callers are hardcoded to an in-memory store. The store is unused. Signed-Off-By: David Anderson <dave@natulte.net>
2020-02-11ipnserver: ignore lint error for unused context.David Anderson1-0/+4
The linter is strictly correct, but the code is structured this way to avoid variable shadowing problems in the following for loop. The context doesn't leak. Staticcheck is correctly pointing out that this code is hard to follow. However, this chunk of code is in service of enforcing one frontend <> one backend, and we want to remove that limitation. So, we'll just ignore the lint warning until this entire piece of code goes away. Signed-off-by: David Anderson <dave@natulte.net>
2020-02-09Move Linux client & common packages into a public repo.Earl Lee1-0/+253