From ebe366ef3bcb1b22a31225b06d140d013e463647 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 7 Aug 2021 10:17:21 +0100 Subject: [PATCH] Add IPReadWriteCloser interface --- src/tuntap/tun.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 4caefe4a..8676ff99 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -11,6 +11,7 @@ package tuntap import ( "errors" "fmt" + "io" "net" //"sync" @@ -22,17 +23,23 @@ import ( "github.com/yggdrasil-network/yggdrasil-go/src/address" "github.com/yggdrasil-network/yggdrasil-go/src/config" "github.com/yggdrasil-network/yggdrasil-go/src/defaults" - "github.com/yggdrasil-network/yggdrasil-go/src/ipv6rwc" ) -type MTU uint16 +type IPReadWriteCloser interface { + io.ReadWriteCloser + MaxMTU() uint64 + SetMTU(mtu uint64) + MTU() uint64 + Address() address.Address + Subnet() address.Subnet +} // TunAdapter represents a running TUN interface and extends the // yggdrasil.Adapter type. In order to use the TUN adapter with Yggdrasil, you // should pass this object to the yggdrasil.SetRouterAdapter() function before // calling yggdrasil.Start(). type TunAdapter struct { - rwc *ipv6rwc.ReadWriteCloser + rwc IPReadWriteCloser config *config.NodeConfig log *log.Logger addr address.Address @@ -93,7 +100,7 @@ func MaximumMTU() uint64 { // Init initialises the TUN module. You must have acquired a Listener from // the Yggdrasil core before this point and it must not be in use elsewhere. -func (tun *TunAdapter) Init(rwc *ipv6rwc.ReadWriteCloser, config *config.NodeConfig, log *log.Logger, options interface{}) error { +func (tun *TunAdapter) Init(rwc IPReadWriteCloser, config *config.NodeConfig, log *log.Logger, options interface{}) error { tun.rwc = rwc tun.config = config tun.log = log