mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-05 17:13:32 +08:00
fix: handle manually select in url-test
This commit is contained in:
parent
d51aab0cc8
commit
a9cb5342ee
@ -96,25 +96,30 @@ func (u *URLTest) Unwrap(metadata *C.Metadata, touch bool) C.Proxy {
|
||||
}
|
||||
|
||||
func (u *URLTest) fast(touch bool) C.Proxy {
|
||||
elm, _, shared := u.fastSingle.Do(func() (C.Proxy, error) {
|
||||
var s C.Proxy
|
||||
proxies := u.GetProxies(touch)
|
||||
fast := proxies[0]
|
||||
if fast.Name() == u.selected {
|
||||
s = fast
|
||||
|
||||
proxies := u.GetProxies(touch)
|
||||
if u.selected != "" {
|
||||
for _, proxy := range proxies {
|
||||
if !proxy.Alive() {
|
||||
continue
|
||||
}
|
||||
if proxy.Name() == u.selected {
|
||||
u.fastNode = proxy
|
||||
return proxy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elm, _, shared := u.fastSingle.Do(func() (C.Proxy, error) {
|
||||
fast := proxies[0]
|
||||
min := fast.LastDelay()
|
||||
fastNotExist := true
|
||||
|
||||
for _, proxy := range proxies[1:] {
|
||||
|
||||
if u.fastNode != nil && proxy.Name() == u.fastNode.Name() {
|
||||
fastNotExist = false
|
||||
}
|
||||
|
||||
if proxy.Name() == u.selected {
|
||||
s = proxy
|
||||
}
|
||||
if !proxy.Alive() {
|
||||
continue
|
||||
}
|
||||
@ -124,16 +129,12 @@ func (u *URLTest) fast(touch bool) C.Proxy {
|
||||
fast = proxy
|
||||
min = delay
|
||||
}
|
||||
|
||||
}
|
||||
// tolerance
|
||||
if u.fastNode == nil || fastNotExist || !u.fastNode.Alive() || u.fastNode.LastDelay() > fast.LastDelay()+u.tolerance {
|
||||
u.fastNode = fast
|
||||
}
|
||||
if s != nil {
|
||||
if s.Alive() && s.LastDelay() < fast.LastDelay()+u.tolerance {
|
||||
u.fastNode = s
|
||||
}
|
||||
}
|
||||
return u.fastNode, nil
|
||||
})
|
||||
if shared && touch { // a shared fastSingle.Do() may cause providers untouched, so we touch them again
|
||||
|
Loading…
x
Reference in New Issue
Block a user