wgengine: don't pass nil router.Config objects.

These are hard for swift to decode in the iOS app.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
pull/427/head
Avery Pennarun 5 years ago
parent 5114df415e
commit f0b6ba78e8

@ -868,7 +868,7 @@ func (b *LocalBackend) enterState(newState State) {
b.blockEngineUpdates(true) b.blockEngineUpdates(true)
fallthrough fallthrough
case Stopped: case Stopped:
err := b.e.Reconfig(&wgcfg.Config{}, nil) err := b.e.Reconfig(&wgcfg.Config{}, &router.Config{})
if err != nil { if err != nil {
b.logf("Reconfig(down): %v", err) 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. // a status update that predates the "I've shut down" update.
func (b *LocalBackend) stopEngineAndWait() { func (b *LocalBackend) stopEngineAndWait() {
b.logf("stopEngineAndWait...") b.logf("stopEngineAndWait...")
b.e.Reconfig(&wgcfg.Config{}, nil) b.e.Reconfig(&wgcfg.Config{}, &router.Config{})
b.requestEngineStatusAndWait() b.requestEngineStatusAndWait()
b.logf("stopEngineAndWait: done.") b.logf("stopEngineAndWait: done.")
} }

@ -11,6 +11,7 @@ import (
) )
type darwinRouter struct { type darwinRouter struct {
logf logger.Logf
tunname string tunname string
} }
@ -19,7 +20,10 @@ func newUserspaceRouter(logf logger.Logf, _ *device.Device, tundev tun.Device) (
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &darwinRouter{tunname: tunname}, nil return &darwinRouter{
logf: logf,
tunname: tunname,
}, nil
} }
func (r *darwinRouter) Up() error { func (r *darwinRouter) Up() error {

@ -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 { func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config) error {
if routerCfg == nil {
panic("routerCfg must not be nil")
}
e.wgLock.Lock() e.wgLock.Lock()
defer e.wgLock.Unlock() defer e.wgLock.Unlock()

Loading…
Cancel
Save