Skip to content
Snippets Groups Projects
Commit bf59ead3 authored by kr328's avatar kr328
Browse files

Feature: close all connections on reset

parent 5dbd94e4
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ func coreInit(home, versionName C.c_string, sdkVersion C.int) { ...@@ -36,6 +36,7 @@ func coreInit(home, versionName C.c_string, sdkVersion C.int) {
func reset() { func reset() {
config.LoadDefault() config.LoadDefault()
tunnel.ResetStatistic() tunnel.ResetStatistic()
tunnel.CloseAllConnections()
runtime.GC() runtime.GC()
} }
......
...@@ -5,6 +5,12 @@ import ( ...@@ -5,6 +5,12 @@ import (
"github.com/Dreamacro/clash/tunnel/statistic" "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) { func closeMatch(filter func(conn C.Conn) bool) {
for _, c := range statistic.DefaultManager.Snapshot().Connections { for _, c := range statistic.DefaultManager.Snapshot().Connections {
if cc, ok := c.(C.Conn); ok { if cc, ok := c.(C.Conn); ok {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment