You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/ipn/ipnlocal
Nick Khyl 9b32ba7f54 ipn/ipn{local,server}: move "staying alive in server mode" from ipnserver to LocalBackend
Currently, we disconnect Tailscale and reset LocalBackend on Windows when the last LocalAPI client
disconnects, unless Unattended Mode is enabled for the current profile. And the implementation
is somewhat racy since the current profile could theoretically change after
(*ipnserver.Server).addActiveHTTPRequest checks (*LocalBackend).InServerMode() and before it calls
(*LocalBackend).SetCurrentUser(nil) (or, previously, (*LocalBackend).ResetForClientDisconnect).

Additionally, we might want to keep Tailscale running and connected while a user is logged in
rather than tying it to whether a LocalAPI client is connected (i.e., while the GUI is running),
even when Unattended Mode is disabled for a profile. This includes scenarios where the new
AlwaysOn mode is enabled, as well as when Tailscale is used on headless Windows editions,
such as Windows Server Core, where the GUI is not supported. It may also be desirable to switch
to the "background" profile when a user logs off from their device or implement other similar
features.

To facilitate these improvements, we move the logic from ipnserver.Server to ipnlocal.LocalBackend,
where it determines whether to keep Tailscale running when the current user disconnects.
We also update the logic that determines whether a connection should be allowed to better reflect
the fact that, currently, LocalAPI connections are not allowed unless:
 - the current UID is "", meaning that either we are not on a multi-user system or Tailscale is idle;
 - the LocalAPI client belongs to the current user (their UIDs are the same);
 - the LocalAPI client is Local System (special case; Local System is always allowed).
Whether Unattended Mode is enabled only affects the error message returned to the Local API client
when the connection is denied.

Updates #14823

Signed-off-by: Nick Khyl <nickk@tailscale.com>
11 months ago
..
testdata
autoupdate.go
autoupdate_disabled.go
breaktcp_darwin.go
breaktcp_linux.go
bus.go
bus_test.go
c2n.go feature/*: make Wake-on-LAN conditional, start supporting modular features 11 months ago
c2n_pprof.go
c2n_test.go
cert.go tempfork/acme: add new package for x/crypto package acme fork, move 11 months ago
cert_js.go
cert_test.go ipn/ipnlocal: add debug envknob for ACME directory URL (#14771) 11 months ago
dnsconfig_test.go
drive.go cmd/viewer,types/views,various: avoid allocations in pointer field getters whenever possible 12 months ago
expiry.go all: add Node.HomeDERP int, phase out "127.3.3.40:$region" hack [capver 111] 12 months ago
expiry_test.go cmd/viewer,types/views,various: avoid allocations in pointer field getters whenever possible 12 months ago
local.go ipn/ipn{local,server}: move "staying alive in server mode" from ipnserver to LocalBackend 11 months ago
local_test.go types/netmap,*: pass around UserProfiles as views (pointers) instead 11 months ago
loglines_test.go
network-lock.go ipn: generate LoginProfileView and use it instead of *LoginProfile where appropriate 11 months ago
network-lock_test.go ipn: generate LoginProfileView and use it instead of *LoginProfile where appropriate 11 months ago
peerapi.go appc,ipn/ipnlocal: log DNS parsing errors in app connectors (#14607) 11 months ago
peerapi_h2c.go
peerapi_macios_ext.go
peerapi_test.go
profiles.go ipn/ipn{local,server}: move "staying alive in server mode" from ipnserver to LocalBackend 11 months ago
profiles_notwindows.go
profiles_test.go ipn/ipnlocal: fix (*profileManager).DefaultUserProfileID for users other than current 11 months ago
profiles_windows.go
serve.go ipn: generate LoginProfileView and use it instead of *LoginProfile where appropriate 11 months ago
serve_test.go types/netmap,*: pass around UserProfiles as views (pointers) instead 11 months ago
ssh.go ssh,tempfork/gliderlabs/ssh: replace github.com/tailscale/golang-x-crypto/ssh with golang.org/x/crypto/ssh 11 months ago
ssh_stub.go
ssh_test.go
state_test.go types/persist: remove Persist.LegacyFrontendPrivateMachineKey 11 months ago
taildrop.go
web_client.go all: use new LocalAPI client package location 11 months ago
web_client_stub.go all: use new LocalAPI client package location 11 months ago