mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 01:33:15 +08:00
Fix: wait for device to close
This commit is contained in:
@@ -17,4 +17,7 @@ type Device interface {
|
|||||||
|
|
||||||
// Type returns the driver type of the device.
|
// Type returns the driver type of the device.
|
||||||
Type() string
|
Type() string
|
||||||
|
|
||||||
|
// Wait waits for the device to close.
|
||||||
|
Wait()
|
||||||
}
|
}
|
||||||
|
@@ -79,5 +79,6 @@ func (t *TUN) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TUN) Close() error {
|
func (t *TUN) Close() error {
|
||||||
|
t.Endpoint.Close()
|
||||||
return t.nt.Close()
|
return t.nt.Close()
|
||||||
}
|
}
|
||||||
|
@@ -80,13 +80,16 @@ func (e *engine) start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *engine) stop() error {
|
func (e *engine) stop() (err error) {
|
||||||
if e.device != nil {
|
if e.device != nil {
|
||||||
return e.device.Close()
|
err = e.device.Close()
|
||||||
|
e.device.Wait()
|
||||||
}
|
}
|
||||||
|
if e.stack != nil {
|
||||||
e.stack.Close()
|
e.stack.Close()
|
||||||
e.stack.Wait()
|
e.stack.Wait()
|
||||||
return nil
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *engine) insert(k *Key) {
|
func (e *engine) insert(k *Key) {
|
||||||
|
Reference in New Issue
Block a user