mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-04-24 20:28:11 +08:00
chore: close all connections after proxySet initial
This commit is contained in:
parent
5d7fd47cf9
commit
aaf534427e
@ -17,6 +17,7 @@ import (
|
|||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
types "github.com/Dreamacro/clash/constant/provider"
|
types "github.com/Dreamacro/clash/constant/provider"
|
||||||
"github.com/Dreamacro/clash/log"
|
"github.com/Dreamacro/clash/log"
|
||||||
|
"github.com/Dreamacro/clash/tunnel/statistic"
|
||||||
|
|
||||||
"github.com/dlclark/regexp2"
|
"github.com/dlclark/regexp2"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -81,6 +82,7 @@ func (pp *proxySetProvider) Initial() error {
|
|||||||
}
|
}
|
||||||
pp.OnUpdate(elm)
|
pp.OnUpdate(elm)
|
||||||
pp.getSubscriptionInfo()
|
pp.getSubscriptionInfo()
|
||||||
|
pp.closeAllConnections()
|
||||||
return nil
|
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) {
|
func stopProxyProvider(pd *ProxySetProvider) {
|
||||||
pd.healthCheck.close()
|
pd.healthCheck.close()
|
||||||
_ = pd.Fetcher.Destroy()
|
_ = pd.Fetcher.Destroy()
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
type tracker interface {
|
type tracker interface {
|
||||||
ID() string
|
ID() string
|
||||||
Close() error
|
Close() error
|
||||||
|
C.Connection
|
||||||
}
|
}
|
||||||
|
|
||||||
type trackerInfo struct {
|
type trackerInfo struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user