mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-20 00:04:24 +00:00
Fix URLTest group hang on unresponsive outbound
This commit is contained in:
@@ -184,6 +184,30 @@ func updateProxy(w http.ResponseWriter, r *http.Request) {
|
||||
render.NoContent(w, r)
|
||||
}
|
||||
|
||||
func groupContains(outboundManager adapter.OutboundManager, outboundGroup adapter.OutboundGroup, tag string, visited map[string]bool) bool {
|
||||
for _, memberTag := range outboundGroup.All() {
|
||||
if memberTag == tag {
|
||||
return true
|
||||
}
|
||||
member, loaded := outboundManager.Outbound(memberTag)
|
||||
if !loaded {
|
||||
continue
|
||||
}
|
||||
if group.RealTag(member) == tag {
|
||||
return true
|
||||
}
|
||||
memberGroup, isGroup := member.(adapter.OutboundGroup)
|
||||
if !isGroup || visited[memberTag] {
|
||||
continue
|
||||
}
|
||||
visited[memberTag] = true
|
||||
if groupContains(outboundManager, memberGroup, tag, visited) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getProxyDelay(server *Server) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
query := r.URL.Query()
|
||||
@@ -213,6 +237,16 @@ func getProxyDelay(server *Server) func(w http.ResponseWriter, r *http.Request)
|
||||
Delay: delay,
|
||||
})
|
||||
}
|
||||
for _, detour := range server.outbound.Outbounds() {
|
||||
urlTestGroup, isURLTestGroup := detour.(adapter.URLTestGroup)
|
||||
if !isURLTestGroup {
|
||||
continue
|
||||
}
|
||||
if !groupContains(server.outbound, urlTestGroup, realTag, map[string]bool{detour.Tag(): true}) {
|
||||
continue
|
||||
}
|
||||
urlTestGroup.PerformUpdateCheck()
|
||||
}
|
||||
}()
|
||||
|
||||
if ctx.Err() != nil {
|
||||
|
||||
Reference in New Issue
Block a user