ipn/ipnlocal: drop LocalBackend.inServerMode

Signed-off-by: Maisem Ali <maisem@tailscale.com>
pull/6515/head
Maisem Ali 2 years ago committed by Maisem Ali
parent 7e016c1d90
commit 699b39dec1

@ -157,7 +157,6 @@ type LocalBackend struct {
notify func(ipn.Notify) notify func(ipn.Notify)
cc controlclient.Client cc controlclient.Client
ccAuto *controlclient.Auto // if cc is of type *controlclient.Auto ccAuto *controlclient.Auto // if cc is of type *controlclient.Auto
inServerMode bool
machinePrivKey key.MachinePrivate machinePrivKey key.MachinePrivate
tka *tkaState tka *tkaState
state ipn.State state ipn.State
@ -1207,10 +1206,9 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
loggedOut := prefs.LoggedOut() loggedOut := prefs.LoggedOut()
b.inServerMode = prefs.ForceDaemon()
serverURL := prefs.ControlURLOrDefault() serverURL := prefs.ControlURLOrDefault()
if b.inServerMode || runtime.GOOS == "windows" { if inServerMode := prefs.ForceDaemon(); inServerMode || runtime.GOOS == "windows" {
b.logf("Start: serverMode=%v", b.inServerMode) b.logf("Start: serverMode=%v", inServerMode)
} }
b.applyPrefsToHostinfoLocked(hostinfo, prefs) b.applyPrefsToHostinfoLocked(hostinfo, prefs)
@ -2027,7 +2025,7 @@ func (b *LocalBackend) State() ipn.State {
func (b *LocalBackend) InServerMode() bool { func (b *LocalBackend) InServerMode() bool {
b.mu.Lock() b.mu.Lock()
defer b.mu.Unlock() defer b.mu.Unlock()
return b.inServerMode return b.pm.CurrentPrefs().ForceDaemon()
} }
// CheckIPNConnectionAllowed returns an error if the identity in ci should not // CheckIPNConnectionAllowed returns an error if the identity in ci should not
@ -2045,7 +2043,7 @@ func (b *LocalBackend) CheckIPNConnectionAllowed(ci *ipnauth.ConnIdentity) error
// running as one. // running as one.
return nil return nil
} }
if !b.inServerMode { if !b.pm.CurrentPrefs().ForceDaemon() {
return nil return nil
} }
uid := ci.UserID() uid := ci.UserID()
@ -2431,7 +2429,6 @@ func (b *LocalBackend) setPrefsLockedOnEntry(caller string, newp *ipn.Prefs) ipn
// anyway. No-op if no exit node resolution is needed. // anyway. No-op if no exit node resolution is needed.
findExitNodeIDLocked(newp, netMap) findExitNodeIDLocked(newp, netMap)
// We do this to avoid holding the lock while doing everything else. // We do this to avoid holding the lock while doing everything else.
b.inServerMode = newp.ForceDaemon
oldHi := b.hostinfo oldHi := b.hostinfo
newHi := oldHi.Clone() newHi := oldHi.Clone()

@ -6,8 +6,8 @@ package ipnlocal
import ( import (
"bytes" "bytes"
"crypto/rand"
"context" "context"
"crypto/rand"
"encoding/binary" "encoding/binary"
"encoding/json" "encoding/json"
"errors" "errors"

@ -30,8 +30,8 @@ type profileManager struct {
currentUserID string // only used on Windows currentUserID string // only used on Windows
knownProfiles map[ipn.ProfileID]*ipn.LoginProfile knownProfiles map[ipn.ProfileID]*ipn.LoginProfile
currentProfile *ipn.LoginProfile currentProfile *ipn.LoginProfile // always non-nil
prefs ipn.PrefsView prefs ipn.PrefsView // always Valid.
// isNewProfile is a sentinel value that indicates that the // isNewProfile is a sentinel value that indicates that the
// current profile is new and has not been saved to disk yet. // current profile is new and has not been saved to disk yet.
@ -407,6 +407,7 @@ func (pm *profileManager) Store() ipn.StateStore {
} }
// CurrentPrefs returns a read-only view of the current prefs. // CurrentPrefs returns a read-only view of the current prefs.
// The returned view is always valid.
func (pm *profileManager) CurrentPrefs() ipn.PrefsView { func (pm *profileManager) CurrentPrefs() ipn.PrefsView {
return pm.prefs return pm.prefs
} }

Loading…
Cancel
Save