diff --git a/core/src/main/golang/native/main.go b/core/src/main/golang/native/main.go index 92933398..01c68b20 100644 --- a/core/src/main/golang/native/main.go +++ b/core/src/main/golang/native/main.go @@ -36,6 +36,7 @@ func coreInit(home, versionName C.c_string, sdkVersion C.int) { func reset() { config.LoadDefault() tunnel.ResetStatistic() + tunnel.CloseAllConnections() runtime.GC() } diff --git a/core/src/main/golang/native/tunnel/conn.go b/core/src/main/golang/native/tunnel/conn.go index c0b05bb3..beb7c3c9 100644 --- a/core/src/main/golang/native/tunnel/conn.go +++ b/core/src/main/golang/native/tunnel/conn.go @@ -5,6 +5,12 @@ import ( "github.com/Dreamacro/clash/tunnel/statistic" ) +func CloseAllConnections() { + for _, c := range statistic.DefaultManager.Snapshot().Connections { + _ = c.Close() + } +} + func closeMatch(filter func(conn C.Conn) bool) { for _, c := range statistic.DefaultManager.Snapshot().Connections { if cc, ok := c.(C.Conn); ok {