From f0b6ba78e84bccfe99821c1bbc0da55fbafc3385 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Sun, 31 May 2020 02:36:57 -0400 Subject: [PATCH] wgengine: don't pass nil router.Config objects. These are hard for swift to decode in the iOS app. Signed-off-by: Avery Pennarun --- ipn/local.go | 4 ++-- wgengine/router/router_darwin.go | 6 +++++- wgengine/userspace.go | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ipn/local.go b/ipn/local.go index 9303be87f..35a121461 100644 --- a/ipn/local.go +++ b/ipn/local.go @@ -868,7 +868,7 @@ func (b *LocalBackend) enterState(newState State) { b.blockEngineUpdates(true) fallthrough case Stopped: - err := b.e.Reconfig(&wgcfg.Config{}, nil) + err := b.e.Reconfig(&wgcfg.Config{}, &router.Config{}) if err != nil { b.logf("Reconfig(down): %v", err) } @@ -958,7 +958,7 @@ func (b *LocalBackend) stateMachine() { // a status update that predates the "I've shut down" update. func (b *LocalBackend) stopEngineAndWait() { b.logf("stopEngineAndWait...") - b.e.Reconfig(&wgcfg.Config{}, nil) + b.e.Reconfig(&wgcfg.Config{}, &router.Config{}) b.requestEngineStatusAndWait() b.logf("stopEngineAndWait: done.") } diff --git a/wgengine/router/router_darwin.go b/wgengine/router/router_darwin.go index ac937ad7f..36b718248 100644 --- a/wgengine/router/router_darwin.go +++ b/wgengine/router/router_darwin.go @@ -11,6 +11,7 @@ ) type darwinRouter struct { + logf logger.Logf tunname string } @@ -19,7 +20,10 @@ func newUserspaceRouter(logf logger.Logf, _ *device.Device, tundev tun.Device) ( if err != nil { return nil, err } - return &darwinRouter{tunname: tunname}, nil + return &darwinRouter{ + logf: logf, + tunname: tunname, + }, nil } func (r *darwinRouter) Up() error { diff --git a/wgengine/userspace.go b/wgengine/userspace.go index a19ca15e5..e160ccc4e 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -370,6 +370,10 @@ func configSignature(cfg *wgcfg.Config, routerCfg *router.Config) (string, error } func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config) error { + if routerCfg == nil { + panic("routerCfg must not be nil") + } + e.wgLock.Lock() defer e.wgLock.Unlock()