mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 21:23:36 +08:00
Feature: close all connections on reset
This commit is contained in:
parent
5dbd94e42c
commit
bf59ead3b2
|
@ -36,6 +36,7 @@ func coreInit(home, versionName C.c_string, sdkVersion C.int) {
|
|||
func reset() {
|
||||
config.LoadDefault()
|
||||
tunnel.ResetStatistic()
|
||||
tunnel.CloseAllConnections()
|
||||
|
||||
runtime.GC()
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user