mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 21:51:38 +00:00
get the fd instead of depending on water to do it
This commit is contained in:
parent
3eccca62cc
commit
cd0d1a1d26
@ -2,29 +2,19 @@ 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 "os"
|
import "github.com/songgao/packets/ethernet"
|
||||||
import ethernet "github.com/songgao/packets/ethernet"
|
import "github.com/yggdrasil-network/water"
|
||||||
|
|
||||||
const IPv6_HEADER_LENGTH = 40
|
const IPv6_HEADER_LENGTH = 40
|
||||||
const ETHER_HEADER_LENGTH = 14
|
const ETHER_HEADER_LENGTH = 14
|
||||||
|
|
||||||
type tunInterface interface {
|
|
||||||
IsTUN() bool
|
|
||||||
IsTAP() bool
|
|
||||||
Name() string
|
|
||||||
Read(to []byte) (int, error)
|
|
||||||
Write(from []byte) (int, error)
|
|
||||||
Close() error
|
|
||||||
FD() *os.File
|
|
||||||
}
|
|
||||||
|
|
||||||
type tunDevice struct {
|
type tunDevice struct {
|
||||||
core *Core
|
core *Core
|
||||||
icmpv6 icmpv6
|
icmpv6 icmpv6
|
||||||
send chan<- []byte
|
send chan<- []byte
|
||||||
recv <-chan []byte
|
recv <-chan []byte
|
||||||
mtu int
|
mtu int
|
||||||
iface tunInterface
|
iface *water.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
type tunDefaultParameters struct {
|
type tunDefaultParameters struct {
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
package yggdrasil
|
package yggdrasil
|
||||||
|
|
||||||
|
import "os"
|
||||||
import "os/exec"
|
import "os/exec"
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
import water "github.com/yggdrasil-network/water"
|
import "github.com/yggdrasil-network/water"
|
||||||
|
|
||||||
type in6_addrlifetime struct {
|
type in6_addrlifetime struct {
|
||||||
ia6t_expire float64
|
ia6t_expire float64
|
||||||
@ -61,7 +62,7 @@ func (tun *tunDevice) setup(ifname string, iftapmode bool, addr string, mtu int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tun *tunDevice) setupAddress(addr string) error {
|
func (tun *tunDevice) setupAddress(addr string) error {
|
||||||
fd := tun.iface.FD().Fd()
|
fd := tun.iface.ReadWriteCloser.(*os.File).Fd()
|
||||||
var err error
|
var err error
|
||||||
var ti tuninfo
|
var ti tuninfo
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user