diff --git a/src/yggdrasil/tun_bsd.go b/src/yggdrasil/tun_bsd.go index ad2fbc7..d441829 100644 --- a/src/yggdrasil/tun_bsd.go +++ b/src/yggdrasil/tun_bsd.go @@ -2,7 +2,7 @@ package yggdrasil import "os/exec" import "unsafe" -//import "syscall" + import "golang.org/x/sys/unix" import water "github.com/yggdrasil-network/water" @@ -44,7 +44,6 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) case iftapmode || ifname[:8] == "/dev/tap": config = water.Config{DeviceType: water.TAP} case !iftapmode || ifname[:8] == "/dev/tun": - //config = water.Config{DeviceType: water.TUN} panic("TUN mode is not currently supported on this platform, please use TAP instead") default: panic("TUN/TAP name must be in format /dev/tunX or /dev/tapX") @@ -62,7 +61,7 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int) func (tun *tunDevice) setupAddress(addr string) error { fd := tun.iface.FD().Fd() var err error - var ti tuninfo + var ti tuninfo tun.core.log.Printf("Interface name: %s", tun.iface.Name()) tun.core.log.Printf("Interface IPv6: %s", addr) @@ -75,8 +74,8 @@ func (tun *tunDevice) setupAddress(addr string) error { return err } - // Update with any OS-specific flags, MTU, etc. - ti.setInfo(tun) + // Update with any OS-specific flags, MTU, etc. + ti.setInfo(tun) // Set the new interface flags if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(TUNSIFINFO), uintptr(unsafe.Pointer(&ti))); errno != 0 { diff --git a/src/yggdrasil/tun_freebsd.go b/src/yggdrasil/tun_freebsd.go index 909adfb..08946b9 100644 --- a/src/yggdrasil/tun_freebsd.go +++ b/src/yggdrasil/tun_freebsd.go @@ -34,11 +34,10 @@ type tuninfo struct { } func (ti *tuninfo) setInfo(tun *tunDevice) { - ti.tun_mtu = int16(tun.mtu) + ti.tun_mtu = int16(tun.mtu) } const TUNSIFINFO = (0x80000000) | ((8 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 91 const TUNGIFINFO = (0x40000000) | ((8 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 92 const TUNSIFHEAD = (0x80000000) | ((4 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 96 const SIOCAIFADDR_IN6 = (0x80000000) | ((4 & 0x1fff) << 16) | uint32(byte('i'))<<8 | 27 - diff --git a/src/yggdrasil/tun_openbsd.go b/src/yggdrasil/tun_openbsd.go index bb166b5..3146b39 100644 --- a/src/yggdrasil/tun_openbsd.go +++ b/src/yggdrasil/tun_openbsd.go @@ -48,10 +48,9 @@ func (ti *tuninfo) setInfo(tun *tunDevice) { case tun.iface.IsTUN(): ti.tun_flags |= syscall.IFF_POINTOPOINT } - ti.tun_mtu = uint32(tun.mtu) + ti.tun_mtu = uint32(tun.mtu) } const TUNSIFINFO = (0x80000000) | ((12 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 91 const TUNGIFINFO = (0x40000000) | ((12 & 0x1fff) << 16) | uint32(byte('t'))<<8 | 92 const SIOCAIFADDR_IN6 = (0x80000000) | ((4 & 0x1fff) << 16) | uint32(byte('i'))<<8 | 27 -