summaryrefslogtreecommitdiff
path: root/src/tun.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/tun.go')
-rw-r--r--src/tun.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/tun.go b/src/tun.go
index 024f0f0..54253b4 100644
--- a/src/tun.go
+++ b/src/tun.go
@@ -46,13 +46,21 @@ func (device *Device) RoutineTUNEventReader() {
}
if event&TUNEventUp != 0 {
- logInfo.Println("Interface set up")
- device.Up()
+ if !device.tun.isUp.Get() {
+ // begin listening for incomming datagrams
+ logInfo.Println("Interface set up")
+ device.tun.isUp.Set(true)
+ updateBind(device)
+ }
}
if event&TUNEventDown != 0 {
- logInfo.Println("Interface set down")
- device.Up()
+ if device.tun.isUp.Get() {
+ // stop listening for incomming datagrams
+ logInfo.Println("Interface set down")
+ device.tun.isUp.Set(false)
+ closeBind(device)
+ }
}
}
}