diff --git a/stack_gvisor.go b/stack_gvisor.go index 80c78af..df6a2b2 100644 --- a/stack_gvisor.go +++ b/stack_gvisor.go @@ -153,7 +153,9 @@ func (t *GVisor) Start() error { } func (t *GVisor) Close() error { - t.endpoint.Attach(nil) + if t.endpoint != nil { + t.endpoint.Attach(nil) + } t.stack.Close() for _, endpoint := range t.stack.CleanupEndpoints() { endpoint.Abort() diff --git a/stack_mixed.go b/stack_mixed.go index 03f887a..e7fa07f 100644 --- a/stack_mixed.go +++ b/stack_mixed.go @@ -261,7 +261,9 @@ func (m *Mixed) packetLoop() { } func (m *Mixed) Close() error { - m.endpoint.Attach(nil) + if m.endpoint != nil { + m.endpoint.Attach(nil) + } m.stack.Close() for _, endpoint := range m.stack.CleanupEndpoints() { endpoint.Abort()