From c09544f29de389dceb432b05c5ce0e5a62468431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 12 Nov 2024 10:30:18 +0800 Subject: [PATCH] stack: Fix close before start --- stack_gvisor.go | 3 +++ stack_mixed.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/stack_gvisor.go b/stack_gvisor.go index 795d963..792c461 100644 --- a/stack_gvisor.go +++ b/stack_gvisor.go @@ -152,6 +152,9 @@ func (t *GVisor) Start() error { } func (t *GVisor) Close() error { + if t.stack == nil { + return nil + } t.endpoint.Attach(nil) t.stack.Close() for _, endpoint := range t.stack.CleanupEndpoints() { diff --git a/stack_mixed.go b/stack_mixed.go index c1abbb7..d2683cc 100644 --- a/stack_mixed.go +++ b/stack_mixed.go @@ -260,6 +260,9 @@ func (m *Mixed) packetLoop() { } func (m *Mixed) Close() error { + if m.stack == nil { + return nil + } m.endpoint.Attach(nil) m.stack.Close() for _, endpoint := range m.stack.CleanupEndpoints() {