From c3600d14d666743e7082178addba57c9f82f5874 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 5 Jan 2018 23:35:59 +0000 Subject: [PATCH] Implement a tun interface to reduce dependency on Water library --- src/yggdrasil/tun.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/yggdrasil/tun.go b/src/yggdrasil/tun.go index 7c4a06ea..3a819982 100644 --- a/src/yggdrasil/tun.go +++ b/src/yggdrasil/tun.go @@ -2,16 +2,25 @@ package yggdrasil // This manages the tun driver to send/recv packets to/from applications -import water "github.com/songgao/water" +// import water "github.com/songgao/water" const IPv6_HEADER_LENGTH = 40 +type tunInterface interface { + IsTUN() bool + IsTAP() bool + Name() string + Read(to []byte) (int, error) + Write(from []byte) (int, error) + Close() error +} + type tunDevice struct { core *Core send chan<- []byte recv <-chan []byte mtu int - iface *water.Interface + iface tunInterface } func (tun *tunDevice) init(core *Core) {