package websocket import ( "html/template" "net/http" ) var indexTemplate = template.Must(template.New("index").Parse(`
Muxstr is a Nostr relay providing gRPC, HTTP/JSON, and WebSocket interfaces.
{{.GrpcAddr}}
High-performance binary protocol using Protocol Buffers over HTTP/2.
{{.HttpAddr}}/nostr.v1.NostrRelay/*
Browser-compatible HTTP interface. Standard JSON over HTTP/1.1 or HTTP/2. CORS enabled.
{{.WsAddr}}/
Standard Nostr protocol implementation (NIP-01) compatible with all Nostr clients.
Storage: SQLite with Write-Ahead Logging
Event Format: Binary-first (Protocol Buffers + compressed JSON)
Validation: Full cryptographic signature and event ID verification
Subscriptions: Real-time event streaming with filter matching
Deletion: Hard delete (events are permanently removed)
Events are stored in binary format using Protocol Buffers alongside compressed canonical JSON. This dual-storage approach provides both performance (binary queries) and compatibility (JSON export).
The relay validates all events before storage:
1. Verify event ID matches SHA256(canonical_json) 2. Verify schnorr signature against pubkey 3. Store in SQLite with indexed queries
Subscriptions use a shared manager across all three protocols. An event published via gRPC will be immediately broadcast to WebSocket subscribers and vice versa.
This relay is free open-source software. Source code
`)) type IndexData struct { GrpcAddr string HttpAddr string WsAddr string } func (h *Handler) ServeIndex(w http.ResponseWriter, r *http.Request, data IndexData) { w.Header().Set("Content-Type", "text/html; charset=utf-8") indexTemplate.Execute(w, data) }