mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-09 16:20:26 +00:00
cleanup
This commit is contained in:
parent
e7726cfb00
commit
478b80a07a
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user