From b0f8d8af1319878fefd375b193a41f4cb0b33c44 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 18 Jun 2023 15:36:14 +0100 Subject: [PATCH] Define interface for RWCs --- src/tun/tun.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tun/tun.go b/src/tun/tun.go index 93cb433f..5768461d 100644 --- a/src/tun/tun.go +++ b/src/tun/tun.go @@ -8,6 +8,7 @@ package tun import ( "errors" "fmt" + "io" "net" "github.com/Arceliar/phony" @@ -21,22 +22,29 @@ import ( type MTU uint16 +type ReadWriteCloser interface { + io.ReadWriteCloser + Address() address.Address + Subnet() address.Subnet + MaxMTU() uint64 + SetMTU(uint64) +} + // 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 ReadWriteCloser log core.Logger addr address.Address subnet address.Subnet mtu uint64 iface tun.Device phony.Inbox // Currently only used for _handlePacket from the reader, TODO: all the stuff that currently needs a mutex below - //mutex sync.RWMutex // Protects the below - isOpen bool - isEnabled bool // Used by the writer to drop sessionTraffic if not enabled - config struct { + isOpen bool + isEnabled bool // Used by the writer to drop sessionTraffic if not enabled + config struct { name InterfaceName mtu InterfaceMTU }