mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-04 19:04:00 +00:00
chore: close all connections after proxySet initial
This commit is contained in:
parent
5d7fd47cf9
commit
aaf534427e
2 changed files with 15 additions and 0 deletions
|
@ -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 a new issue