Update platform defaults, handling of 'auto' on Linux/Darwin

This commit is contained in:
Neil Alexander 2019-11-22 20:07:08 +00:00
parent 15726fe90d
commit 7d00206f4b
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
6 changed files with 9 additions and 28 deletions

View File

@ -20,6 +20,6 @@ func GetDefaults() platformDefaultParameters {
// TUN/TAP
MaximumIfMTU: 32767,
DefaultIfMTU: 32767,
DefaultIfName: "/dev/tap0",
DefaultIfName: "/dev/tun0",
}
}

View File

@ -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",
}
}

View File

@ -1,4 +1,4 @@
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!netbsd
// +build !linux,!darwin,!windows,!openbsd,!freebsd
package defaults

View File

@ -20,6 +20,6 @@ func GetDefaults() platformDefaultParameters {
// TUN/TAP
MaximumIfMTU: 65535,
DefaultIfMTU: 65535,
DefaultIfName: "auto",
DefaultIfName: "Yggdrasil",
}
}

View File

@ -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)

View File

@ -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)