From 8e0fe553635f38da36d7c252025937ceeefba1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 15 Jan 2023 19:47:32 +0800 Subject: [PATCH] Fix wireguard events --- transport/wireguard/device_stack.go | 3 +-- transport/wireguard/device_system.go | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) 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() }