From fbc5f62add6ea6227cd8d904b3e3791041b9983f Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 17 Aug 2023 14:08:03 +0100 Subject: [PATCH] Fix missing `setupFD` stubs --- src/tun/tun_bsd.go | 6 ++++++ src/tun/tun_linux.go | 7 +++++++ src/tun/tun_other.go | 7 +++++++ src/tun/tun_windows.go | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/src/tun/tun_bsd.go b/src/tun/tun_bsd.go index 9a8f70ce..3910ccef 100644 --- a/src/tun/tun_bsd.go +++ b/src/tun/tun_bsd.go @@ -5,6 +5,7 @@ package tun import ( "encoding/binary" + "fmt" "os/exec" "strconv" "strings" @@ -88,6 +89,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { return tun.setupAddress(addr) } +// Configures the "utun" adapter from an existing file descriptor. +func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error { + return fmt.Errorf("setup via FD not supported on this platform") +} + func (tun *TunAdapter) setupAddress(addr string) error { var sfd int var err error diff --git a/src/tun/tun_linux.go b/src/tun/tun_linux.go index 1e42b7b8..16deb8e5 100644 --- a/src/tun/tun_linux.go +++ b/src/tun/tun_linux.go @@ -6,6 +6,8 @@ package tun // The linux platform specific tun parts import ( + "fmt" + "github.com/vishvananda/netlink" wgtun "golang.zx2c4.com/wireguard/tun" ) @@ -28,6 +30,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { return tun.setupAddress(addr) } +// Configures the "utun" adapter from an existing file descriptor. +func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error { + return fmt.Errorf("setup via FD not supported on this platform") +} + // Configures the TUN adapter with the correct IPv6 address and MTU. Netlink // is used to do this, so there is not a hard requirement on "ip" or "ifconfig" // to exist on the system, but this will fail if Netlink is not present in the diff --git a/src/tun/tun_other.go b/src/tun/tun_other.go index c618d837..dd33708e 100644 --- a/src/tun/tun_other.go +++ b/src/tun/tun_other.go @@ -7,6 +7,8 @@ package tun // If your platform supports tun devices, you could try configuring it manually import ( + "fmt" + wgtun "golang.zx2c4.com/wireguard/tun" ) @@ -25,6 +27,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { return tun.setupAddress(addr) } +// Configures the "utun" adapter from an existing file descriptor. +func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error { + return fmt.Errorf("setup via FD not supported on this platform") +} + // We don't know how to set the IPv6 address on an unknown platform, therefore // write about it to stdout and don't try to do anything further. func (tun *TunAdapter) setupAddress(addr string) error { diff --git a/src/tun/tun_windows.go b/src/tun/tun_windows.go index c3e36596..2713f991 100644 --- a/src/tun/tun_windows.go +++ b/src/tun/tun_windows.go @@ -6,6 +6,7 @@ package tun import ( "bytes" "errors" + "fmt" "log" "net" @@ -50,6 +51,11 @@ func (tun *TunAdapter) setup(ifname string, addr string, mtu uint64) error { }) } +// Configures the "utun" adapter from an existing file descriptor. +func (tun *TunAdapter) setupFD(fd int32, addr string, mtu uint64) error { + return fmt.Errorf("setup via FD not supported on this platform") +} + // Sets the MTU of the TUN adapter. func (tun *TunAdapter) setupMTU(mtu uint64) error { if tun.iface == nil || tun.Name() == "" {