mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
Fix tailscale endpoint early-start close panic
This commit is contained in:
@@ -110,6 +110,7 @@ type Endpoint struct {
|
|||||||
systemInterface bool
|
systemInterface bool
|
||||||
systemInterfaceName string
|
systemInterfaceName string
|
||||||
systemInterfaceMTU uint32
|
systemInterfaceMTU uint32
|
||||||
|
serverStarted bool
|
||||||
systemTun tun.Tun
|
systemTun tun.Tun
|
||||||
systemDialer *dialer.DefaultDialer
|
systemDialer *dialer.DefaultDialer
|
||||||
fallbackTCPCloser func()
|
fallbackTCPCloser func()
|
||||||
@@ -365,6 +366,7 @@ func (t *Endpoint) postStart() error {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
t.serverStarted = true
|
||||||
if t.fallbackTCPCloser == nil {
|
if t.fallbackTCPCloser == nil {
|
||||||
t.fallbackTCPCloser = t.server.RegisterFallbackTCPHandler(func(src, dst netip.AddrPort) (handler func(net.Conn), intercept bool) {
|
t.fallbackTCPCloser = t.server.RegisterFallbackTCPHandler(func(src, dst netip.AddrPort) (handler func(net.Conn), intercept bool) {
|
||||||
return func(conn net.Conn) {
|
return func(conn net.Conn) {
|
||||||
@@ -482,7 +484,11 @@ func (t *Endpoint) watchState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Endpoint) Close() error {
|
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)
|
netmon.RegisterInterfaceGetter(nil)
|
||||||
netns.SetControlFunc(nil)
|
netns.SetControlFunc(nil)
|
||||||
if t.fallbackTCPCloser != nil {
|
if t.fallbackTCPCloser != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user