diff options
Diffstat (limited to 'tun')
-rw-r--r-- | tun/netstack/tun.go | 14 |
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 { |