mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-05-13 13:57:05 +00:00
Fix tailscale endpoint early-start close panic
This commit is contained in:
parent
3a236d9c3c
commit
a80ef94f09
1 changed files with 7 additions and 1 deletions
|
|
@ -110,6 +110,7 @@ type Endpoint struct {
|
|||
systemInterface bool
|
||||
systemInterfaceName string
|
||||
systemInterfaceMTU uint32
|
||||
serverStarted bool
|
||||
systemTun tun.Tun
|
||||
systemDialer *dialer.DefaultDialer
|
||||
fallbackTCPCloser func()
|
||||
|
|
@ -365,6 +366,7 @@ func (t *Endpoint) postStart() error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
t.serverStarted = true
|
||||
if t.fallbackTCPCloser == nil {
|
||||
t.fallbackTCPCloser = t.server.RegisterFallbackTCPHandler(func(src, dst netip.AddrPort) (handler func(net.Conn), intercept bool) {
|
||||
return func(conn net.Conn) {
|
||||
|
|
@ -482,7 +484,11 @@ func (t *Endpoint) watchState() {
|
|||
}
|
||||
|
||||
func (t *Endpoint) Close() error {
|
||||
err := common.Close(common.PtrOrNil(t.server))
|
||||
var err error
|
||||
if t.serverStarted {
|
||||
err = common.Close(common.PtrOrNil(t.server))
|
||||
t.serverStarted = false
|
||||
}
|
||||
netmon.RegisterInterfaceGetter(nil)
|
||||
netns.SetControlFunc(nil)
|
||||
if t.fallbackTCPCloser != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue