diff --git a/transport/wireguard/device_stack.go b/transport/wireguard/device_stack.go index 2210f127..3919a6b7 100644 --- a/transport/wireguard/device_stack.go +++ b/transport/wireguard/device_stack.go @@ -197,10 +197,9 @@ func (w *StackDevice) Events() chan tun.Event { func (w *StackDevice) Close() error { select { - case <-w.events: + case <-w.done: return os.ErrClosed default: - close(w.events) } w.stack.Close() for _, endpoint := range w.stack.CleanupEndpoints() { diff --git a/transport/wireguard/device_system.go b/transport/wireguard/device_system.go index ac8f285b..b5bde2fd 100644 --- a/transport/wireguard/device_system.go +++ b/transport/wireguard/device_system.go @@ -105,11 +105,5 @@ func (w *SystemDevice) Events() chan wgTun.Event { } func (w *SystemDevice) Close() error { - select { - case <-w.events: - return os.ErrClosed - default: - close(w.events) - } return w.device.Close() }