tun: remove TUN prefix from types to reduce stutter elsewhere
Signed-off-by: Matt Layher <mdlayher@gmail.com>
This commit is contained in:
parent
3371f8dac6
commit
1f48971a80
|
@ -86,7 +86,7 @@ type Device struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
tun struct {
|
tun struct {
|
||||||
device tun.TUNDevice
|
device tun.Device
|
||||||
mtu int32
|
mtu int32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDevice(tunDevice tun.TUNDevice, logger *Logger) *Device {
|
func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
|
||||||
device := new(Device)
|
device := new(Device)
|
||||||
|
|
||||||
device.isUp.Set(false)
|
device.isUp.Set(false)
|
||||||
|
@ -324,7 +324,6 @@ func (device *Device) LookupPeer(pk NoisePublicKey) *Peer {
|
||||||
func (device *Device) RemovePeer(key NoisePublicKey) {
|
func (device *Device) RemovePeer(key NoisePublicKey) {
|
||||||
device.peers.Lock()
|
device.peers.Lock()
|
||||||
defer device.peers.Unlock()
|
defer device.peers.Unlock()
|
||||||
|
|
||||||
// stop peer and remove from routing
|
// stop peer and remove from routing
|
||||||
|
|
||||||
peer, ok := device.peers.keyMap[key]
|
peer, ok := device.peers.keyMap[key]
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (device *Device) RoutineTUNEventReader() {
|
||||||
device.state.starting.Done()
|
device.state.starting.Done()
|
||||||
|
|
||||||
for event := range device.tun.device.Events() {
|
for event := range device.tun.device.Events() {
|
||||||
if event&tun.TUNEventMTUUpdate != 0 {
|
if event&tun.EventMTUUpdate != 0 {
|
||||||
mtu, err := device.tun.device.MTU()
|
mtu, err := device.tun.device.MTU()
|
||||||
old := atomic.LoadInt32(&device.tun.mtu)
|
old := atomic.LoadInt32(&device.tun.mtu)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,13 +38,13 @@ func (device *Device) RoutineTUNEventReader() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if event&tun.TUNEventUp != 0 && !setUp {
|
if event&tun.EventUp != 0 && !setUp {
|
||||||
logInfo.Println("Interface set up")
|
logInfo.Println("Interface set up")
|
||||||
setUp = true
|
setUp = true
|
||||||
device.Up()
|
device.Up()
|
||||||
}
|
}
|
||||||
|
|
||||||
if event&tun.TUNEventDown != 0 && setUp {
|
if event&tun.EventDown != 0 && setUp {
|
||||||
logInfo.Println("Interface set down")
|
logInfo.Println("Interface set down")
|
||||||
setUp = false
|
setUp = false
|
||||||
device.Down()
|
device.Down()
|
||||||
|
|
|
@ -13,23 +13,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// newDummyTUN creates a dummy TUN device with the specified name.
|
// newDummyTUN creates a dummy TUN device with the specified name.
|
||||||
func newDummyTUN(name string) tun.TUNDevice {
|
func newDummyTUN(name string) tun.Device {
|
||||||
return &dummyTUN{
|
return &dummyTUN{
|
||||||
name: name,
|
name: name,
|
||||||
packets: make(chan []byte, 100),
|
packets: make(chan []byte, 100),
|
||||||
events: make(chan tun.TUNEvent, 10),
|
events: make(chan tun.Event, 10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A dummyTUN is a tun.TUNDevice which is used in unit tests.
|
// A dummyTUN is a tun.Device which is used in unit tests.
|
||||||
type dummyTUN struct {
|
type dummyTUN struct {
|
||||||
name string
|
name string
|
||||||
mtu int
|
mtu int
|
||||||
packets chan []byte
|
packets chan []byte
|
||||||
events chan tun.TUNEvent
|
events chan tun.Event
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dummyTUN) Events() chan tun.TUNEvent { return d.events }
|
func (d *dummyTUN) Events() chan tun.Event { return d.events }
|
||||||
func (*dummyTUN) File() *os.File { return nil }
|
func (*dummyTUN) File() *os.File { return nil }
|
||||||
func (*dummyTUN) Flush() error { return nil }
|
func (*dummyTUN) Flush() error { return nil }
|
||||||
func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
|
func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
|
||||||
|
|
2
main.go
2
main.go
|
@ -125,7 +125,7 @@ func main() {
|
||||||
|
|
||||||
// open TUN device (or use supplied fd)
|
// open TUN device (or use supplied fd)
|
||||||
|
|
||||||
tun, err := func() (tun.TUNDevice, error) {
|
tun, err := func() (tun.Device, error) {
|
||||||
tunFdStr := os.Getenv(ENV_WG_TUN_FD)
|
tunFdStr := os.Getenv(ENV_WG_TUN_FD)
|
||||||
if tunFdStr == "" {
|
if tunFdStr == "" {
|
||||||
return tun.CreateTUN(interfaceName, device.DefaultMTU)
|
return tun.CreateTUN(interfaceName, device.DefaultMTU)
|
||||||
|
|
12
tun/tun.go
12
tun/tun.go
|
@ -9,21 +9,21 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TUNEvent int
|
type Event int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TUNEventUp = 1 << iota
|
EventUp = 1 << iota
|
||||||
TUNEventDown
|
EventDown
|
||||||
TUNEventMTUUpdate
|
EventMTUUpdate
|
||||||
)
|
)
|
||||||
|
|
||||||
type TUNDevice interface {
|
type Device interface {
|
||||||
File() *os.File // returns the file descriptor of the device
|
File() *os.File // returns the file descriptor of the device
|
||||||
Read([]byte, int) (int, error) // read a packet from the device (without any additional headers)
|
Read([]byte, int) (int, error) // read a packet from the device (without any additional headers)
|
||||||
Write([]byte, int) (int, error) // writes a packet to the device (without any additional headers)
|
Write([]byte, int) (int, error) // writes a packet to the device (without any additional headers)
|
||||||
Flush() error // flush all previous writes to the device
|
Flush() error // flush all previous writes to the device
|
||||||
MTU() (int, error) // returns the MTU of the device
|
MTU() (int, error) // returns the MTU of the device
|
||||||
Name() (string, error) // fetches and returns the current name
|
Name() (string, error) // fetches and returns the current name
|
||||||
Events() chan TUNEvent // returns a constant channel of events related to the device
|
Events() chan Event // returns a constant channel of events related to the device
|
||||||
Close() error // stops the device and closes the event channel
|
Close() error // stops the device and closes the event channel
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ type sockaddrCtl struct {
|
||||||
type NativeTun struct {
|
type NativeTun struct {
|
||||||
name string
|
name string
|
||||||
tunFile *os.File
|
tunFile *os.File
|
||||||
events chan TUNEvent
|
events chan Event
|
||||||
errors chan error
|
errors chan error
|
||||||
routeSocket int
|
routeSocket int
|
||||||
}
|
}
|
||||||
|
@ -86,22 +86,22 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) {
|
||||||
// Up / Down event
|
// Up / Down event
|
||||||
up := (iface.Flags & net.FlagUp) != 0
|
up := (iface.Flags & net.FlagUp) != 0
|
||||||
if up != statusUp && up {
|
if up != statusUp && up {
|
||||||
tun.events <- TUNEventUp
|
tun.events <- EventUp
|
||||||
}
|
}
|
||||||
if up != statusUp && !up {
|
if up != statusUp && !up {
|
||||||
tun.events <- TUNEventDown
|
tun.events <- EventDown
|
||||||
}
|
}
|
||||||
statusUp = up
|
statusUp = up
|
||||||
|
|
||||||
// MTU changes
|
// MTU changes
|
||||||
if iface.MTU != statusMTU {
|
if iface.MTU != statusMTU {
|
||||||
tun.events <- TUNEventMTUUpdate
|
tun.events <- EventMTUUpdate
|
||||||
}
|
}
|
||||||
statusMTU = iface.MTU
|
statusMTU = iface.MTU
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
func CreateTUN(name string, mtu int) (Device, error) {
|
||||||
ifIndex := -1
|
ifIndex := -1
|
||||||
if name != "utun" {
|
if name != "utun" {
|
||||||
_, err := fmt.Sscanf(name, "utun%d", &ifIndex)
|
_, err := fmt.Sscanf(name, "utun%d", &ifIndex)
|
||||||
|
@ -171,10 +171,10 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
||||||
return tun, err
|
return tun, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
|
func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
|
||||||
tun := &NativeTun{
|
tun := &NativeTun{
|
||||||
tunFile: file,
|
tunFile: file,
|
||||||
events: make(chan TUNEvent, 10),
|
events: make(chan Event, 10),
|
||||||
errors: make(chan error, 5),
|
errors: make(chan error, 5),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ func (tun *NativeTun) File() *os.File {
|
||||||
return tun.tunFile
|
return tun.tunFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Events() chan TUNEvent {
|
func (tun *NativeTun) Events() chan Event {
|
||||||
return tun.events
|
return tun.events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ type in6_ndireq struct {
|
||||||
type NativeTun struct {
|
type NativeTun struct {
|
||||||
name string
|
name string
|
||||||
tunFile *os.File
|
tunFile *os.File
|
||||||
events chan TUNEvent
|
events chan Event
|
||||||
errors chan error
|
errors chan error
|
||||||
routeSocket int
|
routeSocket int
|
||||||
}
|
}
|
||||||
|
@ -125,16 +125,16 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) {
|
||||||
// Up / Down event
|
// Up / Down event
|
||||||
up := (iface.Flags & net.FlagUp) != 0
|
up := (iface.Flags & net.FlagUp) != 0
|
||||||
if up != statusUp && up {
|
if up != statusUp && up {
|
||||||
tun.events <- TUNEventUp
|
tun.events <- EventUp
|
||||||
}
|
}
|
||||||
if up != statusUp && !up {
|
if up != statusUp && !up {
|
||||||
tun.events <- TUNEventDown
|
tun.events <- EventDown
|
||||||
}
|
}
|
||||||
statusUp = up
|
statusUp = up
|
||||||
|
|
||||||
// MTU changes
|
// MTU changes
|
||||||
if iface.MTU != statusMTU {
|
if iface.MTU != statusMTU {
|
||||||
tun.events <- TUNEventMTUUpdate
|
tun.events <- EventMTUUpdate
|
||||||
}
|
}
|
||||||
statusMTU = iface.MTU
|
statusMTU = iface.MTU
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func tunDestroy(name string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
func CreateTUN(name string, mtu int) (Device, error) {
|
||||||
if len(name) > unix.IFNAMSIZ-1 {
|
if len(name) > unix.IFNAMSIZ-1 {
|
||||||
return nil, errors.New("interface name too long")
|
return nil, errors.New("interface name too long")
|
||||||
}
|
}
|
||||||
|
@ -365,11 +365,11 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
||||||
return CreateTUNFromFile(tunFile, mtu)
|
return CreateTUNFromFile(tunFile, mtu)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
|
func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
|
||||||
|
|
||||||
tun := &NativeTun{
|
tun := &NativeTun{
|
||||||
tunFile: file,
|
tunFile: file,
|
||||||
events: make(chan TUNEvent, 10),
|
events: make(chan Event, 10),
|
||||||
errors: make(chan error, 1),
|
errors: make(chan error, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ func (tun *NativeTun) File() *os.File {
|
||||||
return tun.tunFile
|
return tun.tunFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Events() chan TUNEvent {
|
func (tun *NativeTun) Events() chan Event {
|
||||||
return tun.events
|
return tun.events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ type NativeTun struct {
|
||||||
index int32 // if index
|
index int32 // if index
|
||||||
name string // name of interface
|
name string // name of interface
|
||||||
errors chan error // async error handling
|
errors chan error // async error handling
|
||||||
events chan TUNEvent // device related events
|
events chan Event // device related events
|
||||||
nopi bool // the device was pased IFF_NO_PI
|
nopi bool // the device was pased IFF_NO_PI
|
||||||
netlinkSock int
|
netlinkSock int
|
||||||
netlinkCancel *rwcancel.RWCancel
|
netlinkCancel *rwcancel.RWCancel
|
||||||
|
@ -64,9 +64,9 @@ func (tun *NativeTun) routineHackListener() {
|
||||||
}
|
}
|
||||||
switch err {
|
switch err {
|
||||||
case unix.EINVAL:
|
case unix.EINVAL:
|
||||||
tun.events <- TUNEventUp
|
tun.events <- EventUp
|
||||||
case unix.EIO:
|
case unix.EIO:
|
||||||
tun.events <- TUNEventDown
|
tun.events <- EventDown
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -148,14 +148,14 @@ func (tun *NativeTun) routineNetlinkListener() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Flags&unix.IFF_RUNNING != 0 {
|
if info.Flags&unix.IFF_RUNNING != 0 {
|
||||||
tun.events <- TUNEventUp
|
tun.events <- EventUp
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Flags&unix.IFF_RUNNING == 0 {
|
if info.Flags&unix.IFF_RUNNING == 0 {
|
||||||
tun.events <- TUNEventDown
|
tun.events <- EventDown
|
||||||
}
|
}
|
||||||
|
|
||||||
tun.events <- TUNEventMTUUpdate
|
tun.events <- EventMTUUpdate
|
||||||
|
|
||||||
default:
|
default:
|
||||||
remain = remain[hdr.Len:]
|
remain = remain[hdr.Len:]
|
||||||
|
@ -342,7 +342,7 @@ func (tun *NativeTun) Read(buff []byte, offset int) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Events() chan TUNEvent {
|
func (tun *NativeTun) Events() chan Event {
|
||||||
return tun.events
|
return tun.events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ func (tun *NativeTun) Close() error {
|
||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
func CreateTUN(name string, mtu int) (Device, error) {
|
||||||
nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0)
|
nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -400,10 +400,10 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
||||||
return CreateTUNFromFile(fd, mtu)
|
return CreateTUNFromFile(fd, mtu)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
|
func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
|
||||||
tun := &NativeTun{
|
tun := &NativeTun{
|
||||||
tunFile: file,
|
tunFile: file,
|
||||||
events: make(chan TUNEvent, 5),
|
events: make(chan Event, 5),
|
||||||
errors: make(chan error, 5),
|
errors: make(chan error, 5),
|
||||||
statusListenersShutdown: make(chan struct{}),
|
statusListenersShutdown: make(chan struct{}),
|
||||||
nopi: false,
|
nopi: false,
|
||||||
|
@ -445,7 +445,7 @@ func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
|
||||||
return tun, nil
|
return tun, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateUnmonitoredTUNFromFD(fd int) (TUNDevice, string, error) {
|
func CreateUnmonitoredTUNFromFD(fd int) (Device, string, error) {
|
||||||
err := unix.SetNonblock(fd, true)
|
err := unix.SetNonblock(fd, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
|
@ -453,7 +453,7 @@ func CreateUnmonitoredTUNFromFD(fd int) (TUNDevice, string, error) {
|
||||||
file := os.NewFile(uintptr(fd), "/dev/tun")
|
file := os.NewFile(uintptr(fd), "/dev/tun")
|
||||||
tun := &NativeTun{
|
tun := &NativeTun{
|
||||||
tunFile: file,
|
tunFile: file,
|
||||||
events: make(chan TUNEvent, 5),
|
events: make(chan Event, 5),
|
||||||
errors: make(chan error, 5),
|
errors: make(chan error, 5),
|
||||||
nopi: true,
|
nopi: true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ const _TUNSIFMODE = 0x8004745d
|
||||||
type NativeTun struct {
|
type NativeTun struct {
|
||||||
name string
|
name string
|
||||||
tunFile *os.File
|
tunFile *os.File
|
||||||
events chan TUNEvent
|
events chan Event
|
||||||
errors chan error
|
errors chan error
|
||||||
routeSocket int
|
routeSocket int
|
||||||
}
|
}
|
||||||
|
@ -75,16 +75,16 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) {
|
||||||
// Up / Down event
|
// Up / Down event
|
||||||
up := (iface.Flags & net.FlagUp) != 0
|
up := (iface.Flags & net.FlagUp) != 0
|
||||||
if up != statusUp && up {
|
if up != statusUp && up {
|
||||||
tun.events <- TUNEventUp
|
tun.events <- EventUp
|
||||||
}
|
}
|
||||||
if up != statusUp && !up {
|
if up != statusUp && !up {
|
||||||
tun.events <- TUNEventDown
|
tun.events <- EventDown
|
||||||
}
|
}
|
||||||
statusUp = up
|
statusUp = up
|
||||||
|
|
||||||
// MTU changes
|
// MTU changes
|
||||||
if iface.MTU != statusMTU {
|
if iface.MTU != statusMTU {
|
||||||
tun.events <- TUNEventMTUUpdate
|
tun.events <- EventMTUUpdate
|
||||||
}
|
}
|
||||||
statusMTU = iface.MTU
|
statusMTU = iface.MTU
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func errorIsEBUSY(err error) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
func CreateTUN(name string, mtu int) (Device, error) {
|
||||||
ifIndex := -1
|
ifIndex := -1
|
||||||
if name != "tun" {
|
if name != "tun" {
|
||||||
_, err := fmt.Sscanf(name, "tun%d", &ifIndex)
|
_, err := fmt.Sscanf(name, "tun%d", &ifIndex)
|
||||||
|
@ -139,11 +139,11 @@ func CreateTUN(name string, mtu int) (TUNDevice, error) {
|
||||||
return tun, err
|
return tun, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTUNFromFile(file *os.File, mtu int) (TUNDevice, error) {
|
func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
|
||||||
|
|
||||||
tun := &NativeTun{
|
tun := &NativeTun{
|
||||||
tunFile: file,
|
tunFile: file,
|
||||||
events: make(chan TUNEvent, 10),
|
events: make(chan Event, 10),
|
||||||
errors: make(chan error, 1),
|
errors: make(chan error, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ func (tun *NativeTun) File() *os.File {
|
||||||
return tun.tunFile
|
return tun.tunFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Events() chan TUNEvent {
|
func (tun *NativeTun) Events() chan Event {
|
||||||
return tun.events
|
return tun.events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ type NativeTun struct {
|
||||||
close bool
|
close bool
|
||||||
rdBuff *exchgBufRead
|
rdBuff *exchgBufRead
|
||||||
wrBuff *exchgBufWrite
|
wrBuff *exchgBufWrite
|
||||||
events chan TUNEvent
|
events chan Event
|
||||||
errors chan error
|
errors chan error
|
||||||
forcedMTU int
|
forcedMTU int
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ func packetAlign(size uint32) uint32 {
|
||||||
// CreateTUN creates a Wintun adapter with the given name. Should a Wintun
|
// CreateTUN creates a Wintun adapter with the given name. Should a Wintun
|
||||||
// adapter with the same name exist, it is reused.
|
// adapter with the same name exist, it is reused.
|
||||||
//
|
//
|
||||||
func CreateTUN(ifname string) (TUNDevice, error) {
|
func CreateTUN(ifname string) (Device, error) {
|
||||||
return CreateTUNWithRequestedGUID(ifname, nil)
|
return CreateTUNWithRequestedGUID(ifname, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func CreateTUN(ifname string) (TUNDevice, error) {
|
||||||
// CreateTUNWithRequestedGUID creates a Wintun adapter with the given name and
|
// CreateTUNWithRequestedGUID creates a Wintun adapter with the given name and
|
||||||
// a requested GUID. Should a Wintun adapter with the same name exist, it is reused.
|
// a requested GUID. Should a Wintun adapter with the same name exist, it is reused.
|
||||||
//
|
//
|
||||||
func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (TUNDevice, error) {
|
func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Device, error) {
|
||||||
var err error
|
var err error
|
||||||
var wt *wintun.Wintun
|
var wt *wintun.Wintun
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (TUN
|
||||||
wt: wt,
|
wt: wt,
|
||||||
rdBuff: &exchgBufRead{},
|
rdBuff: &exchgBufRead{},
|
||||||
wrBuff: &exchgBufWrite{},
|
wrBuff: &exchgBufWrite{},
|
||||||
events: make(chan TUNEvent, 10),
|
events: make(chan Event, 10),
|
||||||
errors: make(chan error, 1),
|
errors: make(chan error, 1),
|
||||||
forcedMTU: 1500,
|
forcedMTU: 1500,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -202,7 +202,7 @@ func (tun *NativeTun) File() *os.File {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tun *NativeTun) Events() chan TUNEvent {
|
func (tun *NativeTun) Events() chan Event {
|
||||||
return tun.events
|
return tun.events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue