From 33838a48014864d865d72f5ef9707ff6ab5c4b59 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 17 Jul 2025 16:46:44 -0300 Subject: [PATCH] khatru: optional ChallengePrefix. --- khatru/handlers.go | 2 +- khatru/relay.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/khatru/handlers.go b/khatru/handlers.go index 6323279..0b349be 100644 --- a/khatru/handlers.go +++ b/khatru/handlers.go @@ -75,7 +75,7 @@ func (rl *Relay) HandleWebsocket(w http.ResponseWriter, r *http.Request) { ws := &WebSocket{ conn: conn, Request: r, - Challenge: hex.EncodeToString(challenge), + Challenge: rl.ChallengePrefix + hex.EncodeToString(challenge), negentropySessions: xsync.NewMapOf[string, *NegentropySession](), } ws.Context, ws.cancel = context.WithCancel(context.Background()) diff --git a/khatru/relay.go b/khatru/relay.go index 925361a..74b53a6 100644 --- a/khatru/relay.go +++ b/khatru/relay.go @@ -75,6 +75,9 @@ type Relay struct { OverwriteRelayInformation func(ctx context.Context, r *http.Request, info nip11.RelayInformationDocument) nip11.RelayInformationDocument PreventBroadcast func(ws *WebSocket, event nostr.Event) bool + // this can be ignored unless you know what you're doing + ChallengePrefix string + // these are used when this relays acts as a router routes []Route getSubRelayFromEvent func(*nostr.Event) *Relay // used for handling EVENTs