Bucket VPN route switch reasons

This commit is contained in:
2026-05-16 13:19:33 +03:00
parent c97044cd34
commit 5c3b19cff7
3 changed files with 38 additions and 2 deletions
@@ -929,6 +929,24 @@ func normalizeFabricRouteSwitchReason(reason string) string {
if reason == "" {
return "route_failure"
}
for _, mapping := range []struct {
needle string
label string
}{
{needle: "context deadline exceeded", label: "timeout"},
{needle: "i/o timeout", label: "timeout"},
{needle: "connection refused", label: "connection_refused"},
{needle: "connection reset", label: "connection_reset"},
{needle: "no route to host", label: "no_route_to_host"},
{needle: "peer unavailable", label: "peer_unavailable"},
{needle: "peer is unavailable", label: "peer_unavailable"},
{needle: "next peer is unavailable", label: "peer_unavailable"},
{needle: "capacity", label: "capacity_limited"},
} {
if strings.Contains(reason, mapping.needle) {
return mapping.label
}
}
replacer := strings.NewReplacer(" ", "_", "\t", "_", "\n", "_", "\r", "_", ":", "_", ";", "_", ",", "_")
reason = replacer.Replace(reason)
for strings.Contains(reason, "__") {