From 0a84aaca0a4bf2f39552a2f3f7fb36a76a425cfc Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 26 Mar 2021 19:22:35 -0700 Subject: [PATCH] wgengine/router: remove unused wireguard *Device argument. Signed-off-by: David Anderson --- wgengine/router/router.go | 5 ++--- wgengine/router/router_darwin.go | 5 ++--- wgengine/router/router_default.go | 5 ++--- wgengine/router/router_fake.go | 3 +-- wgengine/router/router_freebsd.go | 5 ++--- wgengine/router/router_linux.go | 3 +-- wgengine/router/router_linux_test.go | 2 +- wgengine/router/router_openbsd.go | 3 +-- wgengine/router/router_userspace_bsd.go | 3 +-- wgengine/router/router_windows.go | 5 +---- wgengine/userspace.go | 4 ++-- 11 files changed, 16 insertions(+), 27 deletions(-) diff --git a/wgengine/router/router.go b/wgengine/router/router.go index 5f459c6d6..2e53363cf 100644 --- a/wgengine/router/router.go +++ b/wgengine/router/router.go @@ -7,7 +7,6 @@ package router import ( - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "inet.af/netaddr" "tailscale.com/net/dns" @@ -33,9 +32,9 @@ type Router interface { // New returns a new Router for the current platform, using the // provided tun device. -func New(logf logger.Logf, wgdev *device.Device, tundev tun.Device) (Router, error) { +func New(logf logger.Logf, tundev tun.Device) (Router, error) { logf = logger.WithPrefix(logf, "router: ") - return newUserspaceRouter(logf, wgdev, tundev) + return newUserspaceRouter(logf, tundev) } // Cleanup restores the system network configuration to its original state diff --git a/wgengine/router/router_darwin.go b/wgengine/router/router_darwin.go index 26b689355..58ba8e6d3 100644 --- a/wgengine/router/router_darwin.go +++ b/wgengine/router/router_darwin.go @@ -5,13 +5,12 @@ package router import ( - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "tailscale.com/types/logger" ) -func newUserspaceRouter(logf logger.Logf, wgdev *device.Device, tundev tun.Device) (Router, error) { - return newUserspaceBSDRouter(logf, wgdev, tundev) +func newUserspaceRouter(logf logger.Logf, tundev tun.Device) (Router, error) { + return newUserspaceBSDRouter(logf, tundev) } func cleanup(logger.Logf, string) { diff --git a/wgengine/router/router_default.go b/wgengine/router/router_default.go index 4d7365e04..7f05da42f 100644 --- a/wgengine/router/router_default.go +++ b/wgengine/router/router_default.go @@ -7,13 +7,12 @@ package router import ( - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "tailscale.com/types/logger" ) -func newUserspaceRouter(logf logger.Logf, tunname string, dev *device.Device, tunDev tun.Device, netChanged func()) Router { - return NewFakeRouter(logf, tunname, dev, tunDev, netChanged) +func newUserspaceRouter(logf logger.Logf, tunname string, tunDev tun.Device, netChanged func()) Router { + return NewFakeRouter(logf, tunname, tunDev, netChanged) } func cleanup(logf logger.Logf, interfaceName string) { diff --git a/wgengine/router/router_fake.go b/wgengine/router/router_fake.go index 0d14e5000..cb9bd6b19 100644 --- a/wgengine/router/router_fake.go +++ b/wgengine/router/router_fake.go @@ -5,14 +5,13 @@ package router import ( - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "tailscale.com/types/logger" ) // NewFakeRouter returns a Router that does nothing when called and // always returns nil errors. -func NewFake(logf logger.Logf, _ *device.Device, _ tun.Device) (Router, error) { +func NewFake(logf logger.Logf, _ tun.Device) (Router, error) { return fakeRouter{logf: logf}, nil } diff --git a/wgengine/router/router_freebsd.go b/wgengine/router/router_freebsd.go index e56e3f82d..6e9380299 100644 --- a/wgengine/router/router_freebsd.go +++ b/wgengine/router/router_freebsd.go @@ -5,7 +5,6 @@ package router import ( - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "tailscale.com/types/logger" ) @@ -15,8 +14,8 @@ import ( // Work is currently underway for an in-kernel FreeBSD implementation of wireguard // https://svnweb.freebsd.org/base?view=revision&revision=357986 -func newUserspaceRouter(logf logger.Logf, _ *device.Device, tundev tun.Device) (Router, error) { - return newUserspaceBSDRouter(logf, nil, tundev) +func newUserspaceRouter(logf logger.Logf, tundev tun.Device) (Router, error) { + return newUserspaceBSDRouter(logf, tundev) } func cleanup(logf logger.Logf, interfaceName string) { diff --git a/wgengine/router/router_linux.go b/wgengine/router/router_linux.go index 081f7c434..311681ab0 100644 --- a/wgengine/router/router_linux.go +++ b/wgengine/router/router_linux.go @@ -16,7 +16,6 @@ import ( "github.com/coreos/go-iptables/iptables" "github.com/go-multierror/multierror" - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "inet.af/netaddr" "tailscale.com/net/dns" @@ -110,7 +109,7 @@ type linuxRouter struct { cmd commandRunner } -func newUserspaceRouter(logf logger.Logf, _ *device.Device, tunDev tun.Device) (Router, error) { +func newUserspaceRouter(logf logger.Logf, tunDev tun.Device) (Router, error) { tunname, err := tunDev.Name() if err != nil { return nil, err diff --git a/wgengine/router/router_linux_test.go b/wgengine/router/router_linux_test.go index 7bacb2e2f..45109d35c 100644 --- a/wgengine/router/router_linux_test.go +++ b/wgengine/router/router_linux_test.go @@ -627,7 +627,7 @@ func TestDelRouteIdempotent(t *testing.T) { } } - r, err := newUserspaceRouter(logf, nil, tun) + r, err := newUserspaceRouter(logf, tun) if err != nil { t.Fatal(err) } diff --git a/wgengine/router/router_openbsd.go b/wgengine/router/router_openbsd.go index 9b5d38471..a6dbf9282 100644 --- a/wgengine/router/router_openbsd.go +++ b/wgengine/router/router_openbsd.go @@ -10,7 +10,6 @@ import ( "log" "os/exec" - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "inet.af/netaddr" "tailscale.com/net/dns" @@ -31,7 +30,7 @@ type openbsdRouter struct { dns *dns.Manager } -func newUserspaceRouter(logf logger.Logf, _ *device.Device, tundev tun.Device) (Router, error) { +func newUserspaceRouter(logf logger.Logf, tundev tun.Device) (Router, error) { tunname, err := tundev.Name() if err != nil { return nil, err diff --git a/wgengine/router/router_userspace_bsd.go b/wgengine/router/router_userspace_bsd.go index 494a1d51c..79a81de03 100644 --- a/wgengine/router/router_userspace_bsd.go +++ b/wgengine/router/router_userspace_bsd.go @@ -12,7 +12,6 @@ import ( "os/exec" "runtime" - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "inet.af/netaddr" "tailscale.com/net/dns" @@ -29,7 +28,7 @@ type userspaceBSDRouter struct { dns *dns.Manager } -func newUserspaceBSDRouter(logf logger.Logf, _ *device.Device, tundev tun.Device) (Router, error) { +func newUserspaceBSDRouter(logf logger.Logf, tundev tun.Device) (Router, error) { tunname, err := tundev.Name() if err != nil { return nil, err diff --git a/wgengine/router/router_windows.go b/wgengine/router/router_windows.go index cbe0ec316..2efdce7ed 100644 --- a/wgengine/router/router_windows.go +++ b/wgengine/router/router_windows.go @@ -16,7 +16,6 @@ import ( "syscall" "time" - "github.com/tailscale/wireguard-go/device" "github.com/tailscale/wireguard-go/tun" "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" @@ -30,7 +29,6 @@ type winRouter struct { logf func(fmt string, args ...interface{}) tunname string nativeTun *tun.NativeTun - wgdev *device.Device routeChangeCallback *winipcfg.RouteChangeCallback dns *dns.Manager firewall *firewallTweaker @@ -45,7 +43,7 @@ type winRouter struct { firewallSubproc *exec.Cmd } -func newUserspaceRouter(logf logger.Logf, wgdev *device.Device, tundev tun.Device) (Router, error) { +func newUserspaceRouter(logf logger.Logf, tundev tun.Device) (Router, error) { tunname, err := tundev.Name() if err != nil { return nil, err @@ -65,7 +63,6 @@ func newUserspaceRouter(logf logger.Logf, wgdev *device.Device, tundev tun.Devic return &winRouter{ logf: logf, - wgdev: wgdev, tunname: tunname, nativeTun: nativeTun, dns: dns.NewManager(mconfig), diff --git a/wgengine/userspace.go b/wgengine/userspace.go index b5a4ca832..f0ca94f48 100644 --- a/wgengine/userspace.go +++ b/wgengine/userspace.go @@ -145,7 +145,7 @@ func (e *userspaceEngine) GetInternals() (*tstun.TUN, *magicsock.Conn) { // RouterGen is the signature for a function that creates a // router.Router. -type RouterGen func(logf logger.Logf, wgdev *device.Device, tundev tun.Device) (router.Router, error) +type RouterGen func(logf logger.Logf, tundev tun.Device) (router.Router, error) // Config is the engine configuration. type Config struct { @@ -370,7 +370,7 @@ func newUserspaceEngine(logf logger.Logf, rawTUNDev tun.Device, conf Config) (_ // Pass the underlying tun.(*NativeDevice) to the router: // routers do not Read or Write, but do access native interfaces. e.logf("Creating router...") - e.router, err = conf.RouterGen(logf, e.wgdev, e.tundev.Unwrap()) + e.router, err = conf.RouterGen(logf, e.tundev.Unwrap()) if err != nil { return nil, err }