mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2026-05-09 18:11:26 +08:00
break connection if set proxy for selector
This commit is contained in:
@@ -122,11 +122,26 @@ func SetSelectedProxy(name, proxy string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
selected := selector.Now()
|
||||
if selected == proxy {
|
||||
log.Infoln("Set " + name + " -> " + proxy)
|
||||
return true
|
||||
}
|
||||
|
||||
if err := selector.Set(proxy); err != nil {
|
||||
log.Infoln("Set %s: %s", name, err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
for _, conn := range tunnel.DefaultManager.Snapshot().Connections {
|
||||
for _, p := range conn.Chain() {
|
||||
if p == proxy {
|
||||
_ = conn.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Infoln("Set " + name + " -> " + proxy)
|
||||
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user