mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 08:31:30 +00:00
Fix wireguard events
This commit is contained in:
parent
59e521c1db
commit
8e0fe55363
|
@ -197,10 +197,9 @@ func (w *StackDevice) Events() chan tun.Event {
|
||||||
|
|
||||||
func (w *StackDevice) Close() error {
|
func (w *StackDevice) Close() error {
|
||||||
select {
|
select {
|
||||||
case <-w.events:
|
case <-w.done:
|
||||||
return os.ErrClosed
|
return os.ErrClosed
|
||||||
default:
|
default:
|
||||||
close(w.events)
|
|
||||||
}
|
}
|
||||||
w.stack.Close()
|
w.stack.Close()
|
||||||
for _, endpoint := range w.stack.CleanupEndpoints() {
|
for _, endpoint := range w.stack.CleanupEndpoints() {
|
||||||
|
|
|
@ -105,11 +105,5 @@ func (w *SystemDevice) Events() chan wgTun.Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *SystemDevice) Close() error {
|
func (w *SystemDevice) Close() error {
|
||||||
select {
|
|
||||||
case <-w.events:
|
|
||||||
return os.ErrClosed
|
|
||||||
default:
|
|
||||||
close(w.events)
|
|
||||||
}
|
|
||||||
return w.device.Close()
|
return w.device.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue