mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Define Adapter base type/interface
This commit is contained in:
parent
8045cb4dc3
commit
f9dc300787
3 changed files with 29 additions and 12 deletions
25
src/yggdrasil/adapter.go
Normal file
25
src/yggdrasil/adapter.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package yggdrasil
|
||||
|
||||
// Defines the minimum required functions for an adapter type.
|
||||
type AdapterInterface interface {
|
||||
init(core *Core, send chan<- []byte, recv <-chan []byte)
|
||||
read() error
|
||||
write() error
|
||||
close() error
|
||||
}
|
||||
|
||||
// Defines the minimum required struct members for an adapter type (this is
|
||||
// now the base type for tunAdapter in tun.go)
|
||||
type Adapter struct {
|
||||
AdapterInterface
|
||||
core *Core
|
||||
send chan<- []byte
|
||||
recv <-chan []byte
|
||||
}
|
||||
|
||||
// Initialises the adapter.
|
||||
func (adapter *Adapter) init(core *Core, send chan<- []byte, recv <-chan []byte) {
|
||||
adapter.core = core
|
||||
adapter.send = send
|
||||
adapter.recv = recv
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue