aboutsummaryrefslogtreecommitdiffstats
path: root/internal/handler/websocket/handler.go
diff options
context:
space:
mode:
authorClawd <ai@clawd.bot>2026-02-22 14:08:54 -0800
committerClawd <ai@clawd.bot>2026-02-22 14:08:54 -0800
commit5195d8031b7930069ba5441a6cd1e7a59c21c546 (patch)
tree50a110dd565cc1c9330c61dea6f4cc720e1efbd0 /internal/handler/websocket/handler.go
parent3b760256768e45ddb2965aab2a60f11327972e63 (diff)
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
Diffstat (limited to 'internal/handler/websocket/handler.go')
-rw-r--r--internal/handler/websocket/handler.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/internal/handler/websocket/handler.go b/internal/handler/websocket/handler.go
index 6eb8763..b11171d 100644
--- a/internal/handler/websocket/handler.go
+++ b/internal/handler/websocket/handler.go
@@ -49,6 +49,14 @@ type AuthConfig struct {
49 WriteAllowedPubkeys []string 49 WriteAllowedPubkeys []string
50} 50}
51 51
52type RelayInfoConfig struct {
53 Name string
54 Description string
55 Pubkey string
56 Contact string
57 Icon string
58}
59
52type connState struct { 60type connState struct {
53 authenticatedPubkey string 61 authenticatedPubkey string
54 authChallenge string 62 authChallenge string
@@ -56,13 +64,14 @@ type connState struct {
56} 64}
57 65
58type Handler struct { 66type Handler struct {
59 store EventStore 67 store EventStore
60 auth AuthStore 68 auth AuthStore
61 subs *subscription.Manager 69 subs *subscription.Manager
62 metrics MetricsRecorder 70 metrics MetricsRecorder
63 limiter RateLimiter 71 limiter RateLimiter
64 authConfig *AuthConfig 72 authConfig *AuthConfig
65 indexData IndexData 73 relayConfig *RelayInfoConfig
74 indexData IndexData
66} 75}
67 76
68func NewHandler(store EventStore, subs *subscription.Manager) *Handler { 77func NewHandler(store EventStore, subs *subscription.Manager) *Handler {
@@ -88,6 +97,10 @@ func (h *Handler) SetAuthConfig(cfg *AuthConfig) {
88 h.authConfig = cfg 97 h.authConfig = cfg
89} 98}
90 99
100func (h *Handler) SetRelayConfig(cfg *RelayInfoConfig) {
101 h.relayConfig = cfg
102}
103
91// SetIndexData sets the addresses for the index page 104// SetIndexData sets the addresses for the index page
92func (h *Handler) SetIndexData(grpcAddr, httpAddr, wsAddr string) { 105func (h *Handler) SetIndexData(grpcAddr, httpAddr, wsAddr string) {
93 h.indexData = IndexData{ 106 h.indexData = IndexData{