mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-06-29 13:22:06 +03:00
Fix urltest logic
This commit is contained in:
@@ -287,8 +287,23 @@ func (g *URLTestGroup) Close() error {
|
|||||||
|
|
||||||
func (g *URLTestGroup) Select(network string) (adapter.Outbound, bool) {
|
func (g *URLTestGroup) Select(network string) (adapter.Outbound, bool) {
|
||||||
var minDelay uint16
|
var minDelay uint16
|
||||||
var minTime time.Time
|
|
||||||
var minOutbound adapter.Outbound
|
var minOutbound adapter.Outbound
|
||||||
|
switch network {
|
||||||
|
case N.NetworkTCP:
|
||||||
|
if g.selectedOutboundTCP != nil {
|
||||||
|
if history := g.history.LoadURLTestHistory(RealTag(g.selectedOutboundTCP)); history != nil {
|
||||||
|
minOutbound = g.selectedOutboundTCP
|
||||||
|
minDelay = history.Delay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case N.NetworkUDP:
|
||||||
|
if g.selectedOutboundUDP != nil {
|
||||||
|
if history := g.history.LoadURLTestHistory(RealTag(g.selectedOutboundUDP)); history != nil {
|
||||||
|
minOutbound = g.selectedOutboundUDP
|
||||||
|
minDelay = history.Delay
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for _, detour := range g.outbounds {
|
for _, detour := range g.outbounds {
|
||||||
if !common.Contains(detour.Network(), network) {
|
if !common.Contains(detour.Network(), network) {
|
||||||
continue
|
continue
|
||||||
@@ -297,9 +312,8 @@ func (g *URLTestGroup) Select(network string) (adapter.Outbound, bool) {
|
|||||||
if history == nil {
|
if history == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if minDelay == 0 || minDelay > history.Delay+g.tolerance || minDelay > history.Delay-g.tolerance && minTime.Before(history.Time) {
|
if minDelay == 0 || minDelay > history.Delay+g.tolerance {
|
||||||
minDelay = history.Delay
|
minDelay = history.Delay
|
||||||
minTime = history.Time
|
|
||||||
minOutbound = detour
|
minOutbound = detour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user