From 7d00206f4bde6de34dfd84ac4d9e092a98ce57de Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 22 Nov 2019 20:07:08 +0000 Subject: [PATCH] Update platform defaults, handling of 'auto' on Linux/Darwin --- src/defaults/defaults_freebsd.go | 2 +- src/defaults/defaults_netbsd.go | 25 ------------------------- src/defaults/defaults_other.go | 2 +- src/defaults/defaults_windows.go | 2 +- src/tuntap/tun_darwin.go | 3 +++ src/tuntap/tun_linux.go | 3 +++ 6 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 src/defaults/defaults_netbsd.go diff --git a/src/defaults/defaults_freebsd.go b/src/defaults/defaults_freebsd.go index d7dc43b..b08d80d 100644 --- a/src/defaults/defaults_freebsd.go +++ b/src/defaults/defaults_freebsd.go @@ -20,6 +20,6 @@ func GetDefaults() platformDefaultParameters { // TUN/TAP MaximumIfMTU: 32767, DefaultIfMTU: 32767, - DefaultIfName: "/dev/tap0", + DefaultIfName: "/dev/tun0", } } diff --git a/src/defaults/defaults_netbsd.go b/src/defaults/defaults_netbsd.go deleted file mode 100644 index bc9d7a3..0000000 --- a/src/defaults/defaults_netbsd.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build netbsd - -package defaults - -// Sane defaults for the BSD platforms. The "default" options may be -// may be replaced by the running configuration. -func GetDefaults() platformDefaultParameters { - return platformDefaultParameters{ - // Admin - DefaultAdminListen: "unix:///var/run/yggdrasil.sock", - - // Configuration (used for yggdrasilctl) - DefaultConfigFile: "/etc/yggdrasil.conf", - - // Multicast interfaces - DefaultMulticastInterfaces: []string{ - ".*", - }, - - // TUN/TAP - MaximumIfMTU: 9000, - DefaultIfMTU: 9000, - DefaultIfName: "/dev/tun0", - } -} diff --git a/src/defaults/defaults_other.go b/src/defaults/defaults_other.go index 763a7f8..3b03553 100644 --- a/src/defaults/defaults_other.go +++ b/src/defaults/defaults_other.go @@ -1,4 +1,4 @@ -// +build !linux,!darwin,!windows,!openbsd,!freebsd,!netbsd +// +build !linux,!darwin,!windows,!openbsd,!freebsd package defaults diff --git a/src/defaults/defaults_windows.go b/src/defaults/defaults_windows.go index ade833d..305a2ff 100644 --- a/src/defaults/defaults_windows.go +++ b/src/defaults/defaults_windows.go @@ -20,6 +20,6 @@ func GetDefaults() platformDefaultParameters { // TUN/TAP MaximumIfMTU: 65535, DefaultIfMTU: 65535, - DefaultIfName: "auto", + DefaultIfName: "Yggdrasil", } } diff --git a/src/tuntap/tun_darwin.go b/src/tuntap/tun_darwin.go index c9b8bce..cf2fbfb 100644 --- a/src/tuntap/tun_darwin.go +++ b/src/tuntap/tun_darwin.go @@ -17,6 +17,9 @@ import ( // Configures the "utun" adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error { + if ifname == "auto" { + ifname = "utun" + } iface, err := wgtun.CreateTUN(ifname, mtu) if err != nil { panic(err) diff --git a/src/tuntap/tun_linux.go b/src/tuntap/tun_linux.go index 7935e7c..4206b26 100644 --- a/src/tuntap/tun_linux.go +++ b/src/tuntap/tun_linux.go @@ -11,6 +11,9 @@ import ( // Configures the TUN adapter with the correct IPv6 address and MTU. func (tun *TunAdapter) setup(ifname string, addr string, mtu int) error { + if ifname == "auto" { + ifname = "\000" + } iface, err := wgtun.CreateTUN(ifname, mtu) if err != nil { panic(err)