summaryrefslogtreecommitdiffstats
path: root/internal/handler/websocket/nip11.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handler/websocket/nip11.go')
-rw-r--r--internal/handler/websocket/nip11.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/handler/websocket/nip11.go b/internal/handler/websocket/nip11.go
new file mode 100644
index 0000000..a5bb9ca
--- /dev/null
+++ b/internal/handler/websocket/nip11.go
@@ -0,0 +1,60 @@
1package websocket
2
3import (
4 "encoding/json"
5 "net/http"
6)
7
8type RelayInfo struct {
9 Name string `json:"name"`
10 Description string `json:"description"`
11 Pubkey string `json:"pubkey,omitempty"`
12 Contact string `json:"contact,omitempty"`
13 SupportedNIPs []int `json:"supported_nips"`
14 Software string `json:"software"`
15 Version string `json:"version"`
16 Limitation *Limits `json:"limitation,omitempty"`
17}
18
19type Limits struct {
20 MaxMessageLength int `json:"max_message_length,omitempty"`
21 MaxSubscriptions int `json:"max_subscriptions,omitempty"`
22 MaxFilters int `json:"max_filters,omitempty"`
23 MaxLimit int `json:"max_limit,omitempty"`
24 MaxSubidLength int `json:"max_subid_length,omitempty"`
25 MaxEventTags int `json:"max_event_tags,omitempty"`
26 MaxContentLength int `json:"max_content_length,omitempty"`
27 MinPowDifficulty int `json:"min_pow_difficulty,omitempty"`
28 AuthRequired bool `json:"auth_required"`
29 PaymentRequired bool `json:"payment_required"`
30 RestrictedWrites bool `json:"restricted_writes"`
31}
32
33func (h *Handler) ServeNIP11(w http.ResponseWriter, r *http.Request) {
34 info := RelayInfo{
35 Name: "nostr-grpc relay",
36 Description: "High-performance Nostr relay with gRPC, Connect, and WebSocket support",
37 SupportedNIPs: []int{1, 9, 11},
38 Software: "northwest.io/nostr-grpc",
39 Version: "0.1.0",
40 Limitation: &Limits{
41 MaxMessageLength: 65536,
42 MaxSubscriptions: 20,
43 MaxFilters: 10,
44 MaxLimit: 5000,
45 MaxSubidLength: 64,
46 MaxEventTags: 2000,
47 MaxContentLength: 65536,
48 AuthRequired: false,
49 PaymentRequired: false,
50 RestrictedWrites: false,
51 },
52 }
53
54 w.Header().Set("Content-Type", "application/nostr+json")
55 w.Header().Set("Access-Control-Allow-Origin", "*")
56 w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Accept")
57 w.Header().Set("Access-Control-Allow-Methods", "GET")
58
59 json.NewEncoder(w).Encode(info)
60}