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
+33
View File
@@ -51,3 +51,36 @@ func TestBuildRelayURLAddsRandomQuerySuffixWhenEnabled(t *testing.T) {
t.Fatalf("expected one randomized query suffix key, got query %q", parsed.RawQuery)
}
}
func TestBuildRefererCandidatesIncludesAllRelayHosts(t *testing.T) {
cfg := config.Config{
RelayURLs: []string{
"https://relay-a.example/relay",
"https://relay-b.example/relay",
},
}
candidates := buildRefererCandidates(cfg)
expected := map[string]bool{
"https://relay-a.example/": false,
"https://relay-a.example/index.html": false,
"https://relay-a.example/home": false,
"https://relay-a.example/api/status": false,
"https://relay-b.example/": false,
"https://relay-b.example/index.html": false,
"https://relay-b.example/home": false,
"https://relay-b.example/api/status": false,
}
for _, candidate := range candidates {
if _, ok := expected[candidate]; ok {
expected[candidate] = true
}
}
for candidate, seen := range expected {
if !seen {
t.Fatalf("expected referer candidate %q to be present", candidate)
}
}
}