ipn/ipnserver: move more connection acceptance logic to LocalBackend

Follow-up to #6467 and #6506.

LocalBackend knows the server-mode state, so move more auth checking
there, removing some bookkeeping from ipnserver.Server.

Updates #6417
Updates tailscale/corp#8051

Change-Id: Ic5d14a077bf0dccc92a3621bd2646bab2cc5b837
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-11-23 11:18:18 -08:00
committed by Brad Fitzpatrick
parent 5ea7c7d603
commit 0a842f353c
4 changed files with 42 additions and 12 deletions
+10 -1
View File
@@ -44,7 +44,16 @@ type ConnIdentity struct {
user *user.User
}
func (ci *ConnIdentity) UserID() string { return ci.userID }
// UserID returns the local machine's userid of the connection.
//
// It's suitable for passing to LookupUserFromID (os/user.LookupId) on any
// operating system.
//
// TODO(bradfitz): it currently returns an empty string on everything
// but Windows. We should make it return the actual uid also on all supported
// peercred platforms from the creds if non-nil.
func (ci *ConnIdentity) UserID() string { return ci.userID }
func (ci *ConnIdentity) User() *user.User { return ci.user }
func (ci *ConnIdentity) Pid() int { return ci.pid }
func (ci *ConnIdentity) IsUnixSock() bool { return ci.isUnixSock }