Make ipn.Options.Prefs a pointer.

This is a prelude to making it truly optional, once state
management has moved into the backend. For now though, it's
still required. This change is just isolating the bubbling-up
of the pointerification into other layers.

Signed-Off-By: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-02-03 15:58:40 -08:00
committed by Dave Anderson
parent f6f154193f
commit 21280ca2d1
8 changed files with 17 additions and 9 deletions

View File

@@ -53,7 +53,6 @@ type LocalBackend struct {
}
func NewLocalBackend(logf logger.Logf, logid string, e wgengine.Engine) (*LocalBackend, error) {
if e == nil {
panic("ipn.NewLocalBackend: wgengine must not be nil")
}
@@ -114,6 +113,10 @@ func (b *LocalBackend) SetCmpDiff(cmpDiff func(x, y interface{}) string) {
}
func (b *LocalBackend) Start(opts Options) error {
if opts.Prefs == nil {
panic("Prefs can't be nil yet")
}
if b.c != nil {
// TODO(apenwarr): avoid the need to reinit controlclient.
// This will trigger a full relogin/reconfigure cycle every
@@ -136,7 +139,9 @@ func (b *LocalBackend) Start(opts Options) error {
b.hiCache = hi
b.state = NoState
b.serverURL = opts.ServerURL
b.prefs = opts.Prefs
if opts.Prefs != nil {
b.prefs = *opts.Prefs
}
b.notify = opts.Notify
b.netMapCache = nil
b.mu.Unlock()