mirror of
https://github.com/SagerNet/sing-box.git
synced 2026-04-13 20:28:32 +10:00
Fix tailscale crash
This commit is contained in:
@@ -262,9 +262,16 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
}
|
||||
|
||||
func (t *Endpoint) Start(stage adapter.StartStage) error {
|
||||
if stage != adapter.StartStateStart {
|
||||
return nil
|
||||
switch stage {
|
||||
case adapter.StartStateStart:
|
||||
return t.start()
|
||||
case adapter.StartStatePostStart:
|
||||
return t.postStart()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Endpoint) start() error {
|
||||
if t.platformInterface != nil {
|
||||
err := t.network.UpdateInterfaces()
|
||||
if err != nil {
|
||||
@@ -347,6 +354,10 @@ func (t *Endpoint) Start(stage adapter.StartStage) error {
|
||||
})
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Endpoint) postStart() error {
|
||||
err := t.server.Start()
|
||||
if err != nil {
|
||||
if t.systemTun != nil {
|
||||
@@ -471,13 +482,13 @@ func (t *Endpoint) watchState() {
|
||||
}
|
||||
|
||||
func (t *Endpoint) Close() error {
|
||||
err := common.Close(common.PtrOrNil(t.server))
|
||||
netmon.RegisterInterfaceGetter(nil)
|
||||
netns.SetControlFunc(nil)
|
||||
if t.fallbackTCPCloser != nil {
|
||||
t.fallbackTCPCloser()
|
||||
t.fallbackTCPCloser = nil
|
||||
}
|
||||
err := common.Close(common.PtrOrNil(t.server))
|
||||
if t.systemTun != nil {
|
||||
t.systemTun.Close()
|
||||
t.systemTun = nil
|
||||
|
||||
Reference in New Issue
Block a user