diff --git a/wgengine/router_darwin_support.go b/wgengine/router_darwin_support.go new file mode 100644 index 000000000..9032d401d --- /dev/null +++ b/wgengine/router_darwin_support.go @@ -0,0 +1,25 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build linux darwin + +package wgengine + +// SetRoutesFunc applies the given route settings to the OS network +// stack. +// +// This is logically part of the router_darwin.go implementation, and +// should not be used on other platforms. +// +// The code to reconfigure the network stack on MacOS and iOS is in +// the non-open `ipn-go-bridge` package, which bridges between the Go +// and Swift pieces of the application. The ipn-go-bridge sets +// SetRoutesFunc at startup. +// +// So why isn't this in router_darwin.go? Because in the non-oss +// repository, we build ipn-go-bridge when developing on Linux as well +// as MacOS, so that we don't have to wait until the Mac CI to +// discover that we broke it. So this one definition needs to exist in +// both the darwin and linux builds. Hence this file and build tag. +var SetRoutesFunc func(rs RouteSettings) error diff --git a/wgengine/wgengine.go b/wgengine/wgengine.go index f395dcc33..e431bdf41 100644 --- a/wgengine/wgengine.go +++ b/wgengine/wgengine.go @@ -36,10 +36,6 @@ type RouteSettings struct { Cfg wgcfg.Config } -// Only used on darwin for now -// TODO(apenwarr): This probably belongs in the darwinRouter struct. -var SetRoutesFunc func(rs RouteSettings) error - func (rs *RouteSettings) OnlyRelevantParts() string { var peers [][]wgcfg.CIDR for _, p := range rs.Cfg.Peers {