From 5195d8031b7930069ba5441a6cd1e7a59c21c546 Mon Sep 17 00:00:00 2001 From: Clawd Date: Sun, 22 Feb 2026 14:08:54 -0800 Subject: NIP-11: make relay info configurable - Add relay config section (name, description, pubkey, contact, icon) - Wire config to NIP-11 handler - AuthRequired/RestrictedWrites now reflect actual auth config - Add NIP-42 to supported_nips list - Update example config --- internal/handler/websocket/nip11.go | 56 ++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'internal/handler/websocket/nip11.go') diff --git a/internal/handler/websocket/nip11.go b/internal/handler/websocket/nip11.go index 8de95a2..f51faa6 100644 --- a/internal/handler/websocket/nip11.go +++ b/internal/handler/websocket/nip11.go @@ -6,14 +6,15 @@ import ( ) type RelayInfo struct { - Name string `json:"name"` - Description string `json:"description"` - Pubkey string `json:"pubkey,omitempty"` - Contact string `json:"contact,omitempty"` - SupportedNIPs []int `json:"supported_nips"` - Software string `json:"software"` - Version string `json:"version"` - Limitation *Limits `json:"limitation,omitempty"` + Name string `json:"name"` + Description string `json:"description"` + Pubkey string `json:"pubkey,omitempty"` + Contact string `json:"contact,omitempty"` + Icon string `json:"icon,omitempty"` + SupportedNIPs []int `json:"supported_nips"` + Software string `json:"software"` + Version string `json:"version"` + Limitation *Limits `json:"limitation,omitempty"` } type Limits struct { @@ -31,10 +32,39 @@ type Limits struct { } func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) { + // Defaults + name := "muxstr relay" + description := "High-performance Nostr relay with gRPC, Connect, and WebSocket support" + var pubkey, contact, icon string + + // Override from config if set + if h.relayConfig != nil { + if h.relayConfig.Name != "" { + name = h.relayConfig.Name + } + if h.relayConfig.Description != "" { + description = h.relayConfig.Description + } + pubkey = h.relayConfig.Pubkey + contact = h.relayConfig.Contact + icon = h.relayConfig.Icon + } + + // Determine auth status from authConfig + authRequired := false + restrictedWrites := false + if h.authConfig != nil { + authRequired = h.authConfig.ReadEnabled + restrictedWrites = h.authConfig.WriteEnabled + } + info := RelayInfo{ - Name: "muxstr relay", - Description: "High-performance Nostr relay with gRPC, Connect, and WebSocket support", - SupportedNIPs: []int{1, 9, 11}, + Name: name, + Description: description, + Pubkey: pubkey, + Contact: contact, + Icon: icon, + SupportedNIPs: []int{1, 9, 11, 42}, Software: "northwest.io/muxstr", Version: "0.1.0", Limitation: &Limits{ @@ -45,9 +75,9 @@ func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) { MaxSubidLength: 64, MaxEventTags: 2000, MaxContentLength: 65536, - AuthRequired: false, + AuthRequired: authRequired, PaymentRequired: false, - RestrictedWrites: false, + RestrictedWrites: restrictedWrites, }, } -- cgit v1.2.3