aboutsummaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
Diffstat (limited to 'device')
-rw-r--r--device/device.go5
-rw-r--r--device/tun.go6
-rw-r--r--device/tun_test.go18
3 files changed, 14 insertions, 15 deletions
diff --git a/device/device.go b/device/device.go
index 7775844..a583fa9 100644
--- a/device/device.go
+++ b/device/device.go
@@ -86,7 +86,7 @@ type Device struct {
}
tun struct {
- device tun.TUNDevice
+ device tun.Device
mtu int32
}
}
@@ -252,7 +252,7 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
return nil
}
-func NewDevice(tunDevice tun.TUNDevice, logger *Logger) *Device {
+func NewDevice(tunDevice tun.Device, logger *Logger) *Device {
device := new(Device)
device.isUp.Set(false)
@@ -324,7 +324,6 @@ func (device *Device) LookupPeer(pk NoisePublicKey) *Peer {
func (device *Device) RemovePeer(key NoisePublicKey) {
device.peers.Lock()
defer device.peers.Unlock()
-
// stop peer and remove from routing
peer, ok := device.peers.keyMap[key]
diff --git a/device/tun.go b/device/tun.go
index fe1158c..0a3fc79 100644
--- a/device/tun.go
+++ b/device/tun.go
@@ -23,7 +23,7 @@ func (device *Device) RoutineTUNEventReader() {
device.state.starting.Done()
for event := range device.tun.device.Events() {
- if event&tun.TUNEventMTUUpdate != 0 {
+ if event&tun.EventMTUUpdate != 0 {
mtu, err := device.tun.device.MTU()
old := atomic.LoadInt32(&device.tun.mtu)
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")
setUp = true
device.Up()
}
- if event&tun.TUNEventDown != 0 && setUp {
+ if event&tun.EventDown != 0 && setUp {
logInfo.Println("Interface set down")
setUp = false
device.Down()
diff --git a/device/tun_test.go b/device/tun_test.go
index fbe4c1d..5614771 100644
--- a/device/tun_test.go
+++ b/device/tun_test.go
@@ -13,27 +13,27 @@ import (
)
// newDummyTUN creates a dummy TUN device with the specified name.
-func newDummyTUN(name string) tun.TUNDevice {
+func newDummyTUN(name string) tun.Device {
return &dummyTUN{
name: name,
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 {
name string
mtu int
packets chan []byte
- events chan tun.TUNEvent
+ events chan tun.Event
}
-func (d *dummyTUN) Events() chan tun.TUNEvent { return d.events }
-func (*dummyTUN) File() *os.File { return nil }
-func (*dummyTUN) Flush() error { return nil }
-func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
-func (d *dummyTUN) Name() (string, error) { return d.name, nil }
+func (d *dummyTUN) Events() chan tun.Event { return d.events }
+func (*dummyTUN) File() *os.File { return nil }
+func (*dummyTUN) Flush() error { return nil }
+func (d *dummyTUN) MTU() (int, error) { return d.mtu, nil }
+func (d *dummyTUN) Name() (string, error) { return d.name, nil }
func (d *dummyTUN) Close() error {
close(d.events)