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 {
|
func (t *Endpoint) Start(stage adapter.StartStage) error {
|
||||||
if stage != adapter.StartStateStart {
|
switch stage {
|
||||||
return nil
|
case adapter.StartStateStart:
|
||||||
|
return t.start()
|
||||||
|
case adapter.StartStatePostStart:
|
||||||
|
return t.postStart()
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Endpoint) start() error {
|
||||||
if t.platformInterface != nil {
|
if t.platformInterface != nil {
|
||||||
err := t.network.UpdateInterfaces()
|
err := t.network.UpdateInterfaces()
|
||||||
if err != nil {
|
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()
|
err := t.server.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if t.systemTun != nil {
|
if t.systemTun != nil {
|
||||||
@@ -471,13 +482,13 @@ func (t *Endpoint) watchState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Endpoint) Close() error {
|
func (t *Endpoint) Close() error {
|
||||||
|
err := common.Close(common.PtrOrNil(t.server))
|
||||||
netmon.RegisterInterfaceGetter(nil)
|
netmon.RegisterInterfaceGetter(nil)
|
||||||
netns.SetControlFunc(nil)
|
netns.SetControlFunc(nil)
|
||||||
if t.fallbackTCPCloser != nil {
|
if t.fallbackTCPCloser != nil {
|
||||||
t.fallbackTCPCloser()
|
t.fallbackTCPCloser()
|
||||||
t.fallbackTCPCloser = nil
|
t.fallbackTCPCloser = nil
|
||||||
}
|
}
|
||||||
err := common.Close(common.PtrOrNil(t.server))
|
|
||||||
if t.systemTun != nil {
|
if t.systemTun != nil {
|
||||||
t.systemTun.Close()
|
t.systemTun.Close()
|
||||||
t.systemTun = nil
|
t.systemTun = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user