diff options
Diffstat (limited to 'internal/handler/websocket/nip11.go')
| -rw-r--r-- | internal/handler/websocket/nip11.go | 56 |
1 files changed, 43 insertions, 13 deletions
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 ( | |||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type RelayInfo struct { | 8 | type RelayInfo struct { |
| 9 | Name string `json:"name"` | 9 | Name string `json:"name"` |
| 10 | Description string `json:"description"` | 10 | Description string `json:"description"` |
| 11 | Pubkey string `json:"pubkey,omitempty"` | 11 | Pubkey string `json:"pubkey,omitempty"` |
| 12 | Contact string `json:"contact,omitempty"` | 12 | Contact string `json:"contact,omitempty"` |
| 13 | SupportedNIPs []int `json:"supported_nips"` | 13 | Icon string `json:"icon,omitempty"` |
| 14 | Software string `json:"software"` | 14 | SupportedNIPs []int `json:"supported_nips"` |
| 15 | Version string `json:"version"` | 15 | Software string `json:"software"` |
| 16 | Limitation *Limits `json:"limitation,omitempty"` | 16 | Version string `json:"version"` |
| 17 | Limitation *Limits `json:"limitation,omitempty"` | ||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | type Limits struct { | 20 | type Limits struct { |
| @@ -31,10 +32,39 @@ type Limits struct { | |||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) { | 34 | func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) { |
| 35 | // Defaults | ||
| 36 | name := "muxstr relay" | ||
| 37 | description := "High-performance Nostr relay with gRPC, Connect, and WebSocket support" | ||
| 38 | var pubkey, contact, icon string | ||
| 39 | |||
| 40 | // Override from config if set | ||
| 41 | if h.relayConfig != nil { | ||
| 42 | if h.relayConfig.Name != "" { | ||
| 43 | name = h.relayConfig.Name | ||
| 44 | } | ||
| 45 | if h.relayConfig.Description != "" { | ||
| 46 | description = h.relayConfig.Description | ||
| 47 | } | ||
| 48 | pubkey = h.relayConfig.Pubkey | ||
| 49 | contact = h.relayConfig.Contact | ||
| 50 | icon = h.relayConfig.Icon | ||
| 51 | } | ||
| 52 | |||
| 53 | // Determine auth status from authConfig | ||
| 54 | authRequired := false | ||
| 55 | restrictedWrites := false | ||
| 56 | if h.authConfig != nil { | ||
| 57 | authRequired = h.authConfig.ReadEnabled | ||
| 58 | restrictedWrites = h.authConfig.WriteEnabled | ||
| 59 | } | ||
| 60 | |||
| 34 | info := RelayInfo{ | 61 | info := RelayInfo{ |
| 35 | Name: "muxstr relay", | 62 | Name: name, |
| 36 | Description: "High-performance Nostr relay with gRPC, Connect, and WebSocket support", | 63 | Description: description, |
| 37 | SupportedNIPs: []int{1, 9, 11}, | 64 | Pubkey: pubkey, |
| 65 | Contact: contact, | ||
| 66 | Icon: icon, | ||
| 67 | SupportedNIPs: []int{1, 9, 11, 42}, | ||
| 38 | Software: "northwest.io/muxstr", | 68 | Software: "northwest.io/muxstr", |
| 39 | Version: "0.1.0", | 69 | Version: "0.1.0", |
| 40 | Limitation: &Limits{ | 70 | Limitation: &Limits{ |
| @@ -45,9 +75,9 @@ func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) { | |||
| 45 | MaxSubidLength: 64, | 75 | MaxSubidLength: 64, |
| 46 | MaxEventTags: 2000, | 76 | MaxEventTags: 2000, |
| 47 | MaxContentLength: 65536, | 77 | MaxContentLength: 65536, |
| 48 | AuthRequired: false, | 78 | AuthRequired: authRequired, |
| 49 | PaymentRequired: false, | 79 | PaymentRequired: false, |
| 50 | RestrictedWrites: false, | 80 | RestrictedWrites: restrictedWrites, |
| 51 | }, | 81 | }, |
| 52 | } | 82 | } |
| 53 | 83 | ||
