mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 05:44:12 +08:00
fix health check
This commit is contained in:
parent
8d2f261105
commit
ebe1b0f381
@ -109,6 +109,7 @@ func (h *HealthCheck) Check() {
|
||||
nodes := h.refreshNodes()
|
||||
h.mutex.Unlock()
|
||||
for _, n := range nodes {
|
||||
n := n
|
||||
go h.checkNode(n)
|
||||
}
|
||||
}
|
||||
@ -124,6 +125,7 @@ func (h *HealthCheck) CheckNodes() {
|
||||
nodes := h.refreshNodes()
|
||||
h.mutex.Unlock()
|
||||
for _, n := range nodes {
|
||||
n := n
|
||||
delay := time.Duration(rand.Intn(int(h.options.Interval)))
|
||||
time.AfterFunc(delay, func() {
|
||||
h.checkNode(n)
|
||||
|
@ -59,6 +59,12 @@ func (h *HealthCheck) Nodes(network string) *Nodes {
|
||||
default:
|
||||
nodes.Qualified = append(nodes.Qualified, n)
|
||||
}
|
||||
h.logger.Trace(
|
||||
"[", n.Tag, "]",
|
||||
" STD=", n.Deviation,
|
||||
" AVG=", n.Average,
|
||||
" Fail=", n.Fail, "/", n.All,
|
||||
)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
@ -83,6 +89,7 @@ func (h *HealthCheck) refreshNodes() []adapter.Outbound {
|
||||
nodes := CoveredOutbounds(h.router, h.tags)
|
||||
tags := make(map[string]struct{})
|
||||
for _, n := range nodes {
|
||||
n := n
|
||||
tag := n.Tag()
|
||||
tags[tag] = struct{}{}
|
||||
// make it known to the health check results
|
||||
|
Loading…
x
Reference in New Issue
Block a user