Add multi-relay URL support with round-robin and random endpoint selection

This commit is contained in:
Amin.MasterkinG
2026-04-21 15:58:23 +03:30
parent ab7365e35d
commit 787bd90ffd
9 changed files with 254 additions and 20 deletions
+21 -10
View File
@@ -224,18 +224,29 @@ func buildRefererCandidates(cfg config.Config) []string {
return []string{cfg.HTTPReferer}
}
relayURL, err := url.Parse(cfg.RelayURL)
if err != nil || relayURL.Scheme == "" || relayURL.Host == "" {
return nil
}
candidates := make([]string, 0)
seen := make(map[string]struct{})
for _, rawRelayURL := range cfg.RelayEndpointURLs() {
relayURL, err := url.Parse(rawRelayURL)
if err != nil || relayURL.Scheme == "" || relayURL.Host == "" {
continue
}
base := relayURL.Scheme + "://" + relayURL.Host
return []string{
base + "/",
base + "/index.html",
base + "/home",
base + "/api/status",
base := relayURL.Scheme + "://" + relayURL.Host
for _, candidate := range []string{
base + "/",
base + "/index.html",
base + "/home",
base + "/api/status",
} {
if _, exists := seen[candidate]; exists {
continue
}
seen[candidate] = struct{}{}
candidates = append(candidates, candidate)
}
}
return candidates
}
func pickRandomString(values ...string) string {