ipn/ipnlocal: stop storing serverURL in LocalBackend

It's only read in a couple of places and we can read from Prefs directly.

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali 2022-11-22 16:27:05 +05:00 committed by Maisem Ali
parent aeac4bc8e2
commit 8d84178884

View File

@ -134,7 +134,6 @@ type LocalBackend struct {
portpoll *portlist.Poller // may be nil portpoll *portlist.Poller // may be nil
portpollOnce sync.Once // guards starting readPoller portpollOnce sync.Once // guards starting readPoller
gotPortPollRes chan struct{} // closed upon first readPoller result gotPortPollRes chan struct{} // closed upon first readPoller result
serverURL string // tailcontrol URL
newDecompressor func() (controlclient.Decompressor, error) newDecompressor func() (controlclient.Decompressor, error)
varRoot string // or empty if SetVarRoot never called varRoot string // or empty if SetVarRoot never called
sshAtomicBool atomic.Bool sshAtomicBool atomic.Bool
@ -1206,7 +1205,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
loggedOut := prefs.LoggedOut() loggedOut := prefs.LoggedOut()
b.inServerMode = prefs.ForceDaemon() b.inServerMode = prefs.ForceDaemon()
b.serverURL = prefs.ControlURLOrDefault() serverURL := prefs.ControlURLOrDefault()
if b.inServerMode || runtime.GOOS == "windows" { if b.inServerMode || runtime.GOOS == "windows" {
b.logf("Start: serverMode=%v", b.inServerMode) b.logf("Start: serverMode=%v", b.inServerMode)
} }
@ -1259,7 +1258,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
GetMachinePrivateKey: b.createGetMachinePrivateKeyFunc(), GetMachinePrivateKey: b.createGetMachinePrivateKeyFunc(),
Logf: logger.WithPrefix(b.logf, "control: "), Logf: logger.WithPrefix(b.logf, "control: "),
Persist: *persistv, Persist: *persistv,
ServerURL: b.serverURL, ServerURL: serverURL,
AuthKey: opts.AuthKey, AuthKey: opts.AuthKey,
Hostinfo: hostinfo, Hostinfo: hostinfo,
KeepAlive: true, KeepAlive: true,
@ -1768,9 +1767,7 @@ func (b *LocalBackend) validPopBrowserURL(urlStr string) bool {
case "https": case "https":
return true return true
case "http": case "http":
b.mu.Lock() serverURL := b.Prefs().ControlURLOrDefault()
serverURL := b.serverURL
b.mu.Unlock()
// If the control server is using plain HTTP (likely a dev server), // If the control server is using plain HTTP (likely a dev server),
// then permit http://. // then permit http://.
return strings.HasPrefix(serverURL, "http://") return strings.HasPrefix(serverURL, "http://")