mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
chore: close all connections after proxySet initial
This commit is contained in:
parent
1d2c053e4d
commit
443583a116
|
@ -17,6 +17,7 @@ import (
|
|||
C "github.com/Dreamacro/clash/constant"
|
||||
types "github.com/Dreamacro/clash/constant/provider"
|
||||
"github.com/Dreamacro/clash/log"
|
||||
"github.com/Dreamacro/clash/tunnel/statistic"
|
||||
|
||||
"github.com/dlclark/regexp2"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
@ -81,6 +82,7 @@ func (pp *proxySetProvider) Initial() error {
|
|||
}
|
||||
pp.OnUpdate(elm)
|
||||
pp.getSubscriptionInfo()
|
||||
pp.closeAllConnections()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -138,6 +140,18 @@ func (pp *proxySetProvider) getSubscriptionInfo() {
|
|||
}()
|
||||
}
|
||||
|
||||
func (pp *proxySetProvider) closeAllConnections() {
|
||||
snapshot := statistic.DefaultManager.Snapshot()
|
||||
for _, c := range snapshot.Connections {
|
||||
for _, chain := range c.Chains() {
|
||||
if chain == pp.Name() {
|
||||
_ = c.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stopProxyProvider(pd *ProxySetProvider) {
|
||||
pd.healthCheck.close()
|
||||
_ = pd.Fetcher.Destroy()
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
type tracker interface {
|
||||
ID() string
|
||||
Close() error
|
||||
C.Connection
|
||||
}
|
||||
|
||||
type trackerInfo struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user