mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 13:00:47 +00:00
Implement a tun interface to reduce dependency on Water library
This commit is contained in:
parent
b3ebe76b59
commit
c3600d14d6
@ -2,16 +2,25 @@ package yggdrasil
|
|||||||
|
|
||||||
// This manages the tun driver to send/recv packets to/from applications
|
// This manages the tun driver to send/recv packets to/from applications
|
||||||
|
|
||||||
import water "github.com/songgao/water"
|
// import water "github.com/songgao/water"
|
||||||
|
|
||||||
const IPv6_HEADER_LENGTH = 40
|
const IPv6_HEADER_LENGTH = 40
|
||||||
|
|
||||||
|
type tunInterface interface {
|
||||||
|
IsTUN() bool
|
||||||
|
IsTAP() bool
|
||||||
|
Name() string
|
||||||
|
Read(to []byte) (int, error)
|
||||||
|
Write(from []byte) (int, error)
|
||||||
|
Close() error
|
||||||
|
}
|
||||||
|
|
||||||
type tunDevice struct {
|
type tunDevice struct {
|
||||||
core *Core
|
core *Core
|
||||||
send chan<- []byte
|
send chan<- []byte
|
||||||
recv <-chan []byte
|
recv <-chan []byte
|
||||||
mtu int
|
mtu int
|
||||||
iface *water.Interface
|
iface tunInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *tunDevice) init(core *Core) {
|
func (tun *tunDevice) init(core *Core) {
|
||||||
|
Loading…
Reference in New Issue
Block a user