package websocket import ( "encoding/json" "net/http" ) type RelayInfo struct { 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 { MaxMessageLength int `json:"max_message_length,omitempty"` MaxSubscriptions int `json:"max_subscriptions,omitempty"` MaxFilters int `json:"max_filters,omitempty"` MaxLimit int `json:"max_limit,omitempty"` MaxSubidLength int `json:"max_subid_length,omitempty"` MaxEventTags int `json:"max_event_tags,omitempty"` MaxContentLength int `json:"max_content_length,omitempty"` MinPowDifficulty int `json:"min_pow_difficulty,omitempty"` AuthRequired bool `json:"auth_required"` PaymentRequired bool `json:"payment_required"` RestrictedWrites bool `json:"restricted_writes"` } 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: 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{ MaxMessageLength: 65536, MaxSubscriptions: 20, MaxFilters: 10, MaxLimit: 5000, MaxSubidLength: 64, MaxEventTags: 2000, MaxContentLength: 65536, AuthRequired: authRequired, PaymentRequired: false, RestrictedWrites: restrictedWrites, }, } w.Header().Set("Content-Type", "application/nostr+json") w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Accept") w.Header().Set("Access-Control-Allow-Methods", "GET") json.NewEncoder(w).Encode(info) }