From cd0d1a1d26b6ae13dc1c6e51189d4cfc2836e3d3 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 4 Mar 2018 13:57:34 -0600 Subject: [PATCH] get the fd instead of depending on water to do it --- src/yggdrasil/tun.go | 16 +++------------- src/yggdrasil/tun_bsd.go | 5 +++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/yggdrasil/tun.go b/src/yggdrasil/tun.go index bc14ae2..5f5e50a 100644 --- a/src/yggdrasil/tun.go +++ b/src/yggdrasil/tun.go @@ -2,29 +2,19 @@ package yggdrasil // This manages the tun driver to send/recv packets to/from applications -import "os" -import ethernet "github.com/songgao/packets/ethernet" +import "github.com/songgao/packets/ethernet" +import "github.com/yggdrasil-network/water" const IPv6_HEADER_LENGTH = 40 const ETHER_HEADER_LENGTH = 14 -type tunInterface interface { - IsTUN() bool - IsTAP() bool - Name() string - Read(to []byte) (int, error) - Write(from []byte) (int, error) - Close() error - FD() *os.File -} - type tunDevice struct { core *Core icmpv6 icmpv6 send chan<- []byte recv <-chan []byte mtu int - iface tunInterface + iface *water.Interface } type tunDefaultParameters struct { diff --git a/src/yggdrasil/tun_bsd.go b/src/yggdrasil/tun_bsd.go index 84a9d3c..bf8a6f8 100644 --- a/src/yggdrasil/tun_bsd.go +++ b/src/yggdrasil/tun_bsd.go @@ -2,12 +2,13 @@ package yggdrasil +import "os" import "os/exec" import "unsafe" import "golang.org/x/sys/unix" -import water "github.com/yggdrasil-network/water" +import "github.com/yggdrasil-network/water" type in6_addrlifetime struct { ia6t_expire float64 @@ -61,7 +62,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() + fd := tun.iface.ReadWriteCloser.(*os.File).Fd() var err error var ti tuninfo