mirror of
https://github.com/yggdrasil-network/yggdrasil-go
synced 2024-11-09 23:20:26 +03:00
Merge pull request #1045 from yggdrasil-network/neil/tunintf
Define interface for RWCs
This commit is contained in:
commit
80724438c9
@ -8,6 +8,7 @@ package tun
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/Arceliar/phony"
|
"github.com/Arceliar/phony"
|
||||||
@ -21,22 +22,29 @@ import (
|
|||||||
|
|
||||||
type MTU uint16
|
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
|
// TunAdapter represents a running TUN interface and extends the
|
||||||
// yggdrasil.Adapter type. In order to use the TUN adapter with Yggdrasil, you
|
// yggdrasil.Adapter type. In order to use the TUN adapter with Yggdrasil, you
|
||||||
// should pass this object to the yggdrasil.SetRouterAdapter() function before
|
// should pass this object to the yggdrasil.SetRouterAdapter() function before
|
||||||
// calling yggdrasil.Start().
|
// calling yggdrasil.Start().
|
||||||
type TunAdapter struct {
|
type TunAdapter struct {
|
||||||
rwc *ipv6rwc.ReadWriteCloser
|
rwc ReadWriteCloser
|
||||||
log core.Logger
|
log core.Logger
|
||||||
addr address.Address
|
addr address.Address
|
||||||
subnet address.Subnet
|
subnet address.Subnet
|
||||||
mtu uint64
|
mtu uint64
|
||||||
iface tun.Device
|
iface tun.Device
|
||||||
phony.Inbox // Currently only used for _handlePacket from the reader, TODO: all the stuff that currently needs a mutex below
|
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
|
||||||
isOpen bool
|
isEnabled bool // Used by the writer to drop sessionTraffic if not enabled
|
||||||
isEnabled bool // Used by the writer to drop sessionTraffic if not enabled
|
config struct {
|
||||||
config struct {
|
|
||||||
name InterfaceName
|
name InterfaceName
|
||||||
mtu InterfaceMTU
|
mtu InterfaceMTU
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user