TUN/TAP now uses config, log, etc from adapter.go

This commit is contained in:
Neil Alexander 2019-04-01 20:10:14 +01:00
parent 58f5cc88d0
commit 350b51cabb
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
7 changed files with 65 additions and 65 deletions

View file

@ -6,13 +6,15 @@ import (
"github.com/yggdrasil-network/yggdrasil-go/src/config"
)
// Defines the minimum required struct members for an adapter type. This is now
// the base type for adapters like tun.go. When implementing a new adapter type,
// you should extend the adapter struct with this one and should call the
// Adapter.Init() function when initialising.
// Adapter defines the minimum required struct members for an adapter type. This
// is now the base type for adapters like tun.go. When implementing a new
// adapter type, you should extend the adapter struct with this one and should
// call the Adapter.Init() function when initialising.
type Adapter struct {
adapterImplementation
Core *Core
Config *config.NodeState
Log *log.Logger
Send chan<- []byte
Recv <-chan []byte
Reject <-chan RejectedPacket
@ -31,11 +33,13 @@ type adapterImplementation interface {
Close() error
}
// Initialises the adapter with the necessary channels to operate from the
// Init initialises the adapter with the necessary channels to operate from the
// router. When defining a new Adapter type, the Adapter should call this
// function from within it's own Init function to set up the channels. It is
// otherwise not expected for you to call this function directly.
func (adapter *Adapter) Init(config *config.NodeState, log *log.Logger, send chan<- []byte, recv <-chan []byte, reject <-chan RejectedPacket) {
adapter.Config = config
adapter.Log = log
adapter.Send = send
adapter.Recv = recv
adapter.Reject = reject