From 356f9d529ab17ec75771dbadef74f4b133f586a4 Mon Sep 17 00:00:00 2001 From: Evan Jarrett Date: Sat, 21 Feb 2026 14:24:37 -0600 Subject: [PATCH] actually check if the requestCrawl endpoint exists via HEAD --- pkg/atproto/relays.go | 42 ++++++++++++++++++- pkg/hold/admin/handlers_relays.go | 2 + .../templates/partials/relay_status.html | 4 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/pkg/atproto/relays.go b/pkg/atproto/relays.go index b615a0b..251b799 100644 --- a/pkg/atproto/relays.go +++ b/pkg/atproto/relays.go @@ -30,6 +30,9 @@ var KnownRelays = []KnownRelay{ {Name: "Microcosm France", URL: "https://relay3.fr.hose.cam"}, {Name: "Upcloud", URL: "https://relay.upcloud.world"}, {Name: "Blacksky", URL: "https://atproto.africa"}, + {Name: "Hayes", URL: "https://relay.hayescmd.net"}, + {Name: "Xero", URL: "https://relay.xero.systems"}, + {Name: "Feeds Blue", URL: "https://relay.feeds.blue"}, } // RelayHTTPError indicates the relay responded with a non-200 status code. @@ -62,6 +65,7 @@ type HostStatus struct { type RelayStatus struct { Online bool Error string + HasRequestCrawl bool HasListReposByCollection bool RepoStatus *RepoStatus HostStatus *HostStatus @@ -73,7 +77,7 @@ func CheckRelayStatus(relayURL, hostname, did string) *RelayStatus { result := &RelayStatus{} var mu sync.Mutex var wg sync.WaitGroup - wg.Add(3) + wg.Add(4) // Mark relay as online if any check gets an HTTP response markOnline := func() { @@ -82,6 +86,20 @@ func CheckRelayStatus(relayURL, hostname, did string) *RelayStatus { mu.Unlock() } + // Probe requestCrawl + go func() { + defer wg.Done() + supported, online := probeRequestCrawl(relayURL) + if online { + markOnline() + } + if supported { + mu.Lock() + result.HasRequestCrawl = true + mu.Unlock() + } + }() + // Check host status go func() { defer wg.Done() @@ -139,6 +157,28 @@ func CheckRelayStatus(relayURL, hostname, did string) *RelayStatus { return result } +// probeRequestCrawl checks if a relay supports the requestCrawl endpoint using a HEAD request. +// A 4xx response (e.g. 405 Method Not Allowed) means the endpoint exists. +// A 5xx or connection failure means it's broken or unsupported. +func probeRequestCrawl(relayURL string) (supported bool, online bool) { + client := &http.Client{Timeout: 5 * time.Second} + req, err := http.NewRequest("HEAD", relayURL+SyncRequestCrawl, nil) + if err != nil { + return false, false + } + + resp, err := client.Do(req) + if err != nil { + return false, false + } + defer resp.Body.Close() + + // Any HTTP response means the relay is online. + // 4xx (typically 405 Method Not Allowed) = endpoint exists. + // 5xx = endpoint is broken. + return resp.StatusCode >= 400 && resp.StatusCode < 500, true +} + // probeListReposByCollection checks if a relay supports the listReposByCollection endpoint. // Returns (supported, online) — online is true if we got any HTTP response. func probeListReposByCollection(relayURL string) (supported bool, online bool) { diff --git a/pkg/hold/admin/handlers_relays.go b/pkg/hold/admin/handlers_relays.go index 693f92e..2c921d1 100644 --- a/pkg/hold/admin/handlers_relays.go +++ b/pkg/hold/admin/handlers_relays.go @@ -21,6 +21,7 @@ type RelayStatusView struct { URL string Online bool Error string + HasRequestCrawl bool HasListReposByCollection bool RepoStatus *atproto.RepoStatus HostStatus *atproto.HostStatus @@ -75,6 +76,7 @@ func (ui *AdminUI) handleRelayStatus(w http.ResponseWriter, r *http.Request) { URL: relayURL, Online: status.Online, Error: status.Error, + HasRequestCrawl: status.HasRequestCrawl, HasListReposByCollection: status.HasListReposByCollection, RepoStatus: status.RepoStatus, HostStatus: status.HostStatus, diff --git a/pkg/hold/admin/templates/partials/relay_status.html b/pkg/hold/admin/templates/partials/relay_status.html index 6b80f44..dcbc406 100644 --- a/pkg/hold/admin/templates/partials/relay_status.html +++ b/pkg/hold/admin/templates/partials/relay_status.html @@ -22,7 +22,7 @@
{{if .Online}} - requestCrawl + {{if .HasRequestCrawl}}requestCrawl{{end}} {{if .HasListReposByCollection}}listReposByCollection{{end}} {{else}} - @@ -47,7 +47,7 @@ {{end}} - {{if .Online}} + {{if and .Online .HasRequestCrawl}}