1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
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"`
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) {
info := RelayInfo{
Name: "nostr-grpc relay",
Description: "High-performance Nostr relay with gRPC, Connect, and WebSocket support",
SupportedNIPs: []int{1, 9, 11},
Software: "northwest.io/nostr-grpc",
Version: "0.1.0",
Limitation: &Limits{
MaxMessageLength: 65536,
MaxSubscriptions: 20,
MaxFilters: 10,
MaxLimit: 5000,
MaxSubidLength: 64,
MaxEventTags: 2000,
MaxContentLength: 65536,
AuthRequired: false,
PaymentRequired: false,
RestrictedWrites: false,
},
}
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)
}
|