summaryrefslogtreecommitdiffhomepage
path: root/tun/netstack/tun.go
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-11-09 23:56:58 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2021-11-09 23:56:58 +0100
commit3f73632cc3cb496a8e63087e7b4053e88976c2de (patch)
tree6f7a322d9123b020183d8782821e6cdaff4a00fd /tun/netstack/tun.go
parentc9f6cf925916b1f2553e24b2f629b43b969505e7 (diff)
WIP fix Attachtun-net-with-stack
Diffstat (limited to 'tun/netstack/tun.go')
-rw-r--r--tun/netstack/tun.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 8e3ce4b..233cf27 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -48,13 +48,19 @@ type Net struct {
}
func (e *endpoint) Attach(dispatcher stack.NetworkDispatcher) {
- if dispatcher == nil {
- (*netTun)(e).events <- tun.EventUp
- } else {
- (*netTun)(e).events <- tun.EventDown
+ var event tun.Event
+
+ if e.dispatcher == nil && dispatcher != nil {
+ event = tun.EventUp
+ } else if e.dispatcher != nil && dispatcher == nil {
+ event = tun.EventDown
}
e.dispatcher = dispatcher
+
+ if event > 0 {
+ (*netTun)(e).events <- event
+ }
}
func (e *endpoint) IsAttached() bool {