diff --git a/api/template.html b/api/template.html new file mode 100644 index 0000000..1b249d9 --- /dev/null +++ b/api/template.html @@ -0,0 +1,813 @@ + + + + + + + TEMPLATE + + + + + + + + + + + + + +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ + +
+ + +
+
+
+
+
0 sats
+
+ + +
+
+ +
+ +
+
+
+ +
+
AI
+
+
No saved providers yet.
+
+
+ + +
+
+ リレー +
+
+ Loading relays... +
+
+ +
+ +
ブロッサム
+ +
Loading blossom servers...
+ +
+ + +
+ v0.0.1 +
+ + +
+
+
+ + + + + + + + + diff --git a/nip_11_curl.sh b/nip_11_curl.sh index 8e10e96..b6c59d5 100755 --- a/nip_11_curl.sh +++ b/nip_11_curl.sh @@ -1,3 +1,3 @@ #!/bin/bash -curl -H "Accept: application/nostr+json" http://localhost:8888/ +curl -H "Accept: application/nostr+json" https://relay.laantungir.net diff --git a/plans/c_relay_pg_html_migration_plan.md b/plans/c_relay_pg_html_migration_plan.md new file mode 100644 index 0000000..d5ae4aa --- /dev/null +++ b/plans/c_relay_pg_html_migration_plan.md @@ -0,0 +1,240 @@ +# C-Relay-PG Admin Page Migration Plan + +## Overview + +Migrate the relay admin dashboard from an embedded HTTP-served page (`api/index.html` + `api/index.js`) to a full client-ndk page (`c-relay-pg.html`) built on the client-ndk template. The page will live in the client-ndk project (`~/lt/client-ndk/www/`) alongside other pages and communicate with the relay purely through Nostr protocol subscriptions. + +## Why This Migration + +The current `/api` page is served directly by the relay's `lws-main` thread, which causes: +- **Slow page delivery** — HTTP file serving competes with WebSocket event processing on a single thread +- **Incomplete page loads** — 10-second `timeout_secs` kills connections when the main thread is busy +- **6+ sequential HTTP round-trips** — each asset requires a two-phase header/body delivery cycle +- **Unnecessary complexity** — embedded file generation, `lws_set_wsi_user()` overwriting, session data type dispatch + +The admin page already communicates entirely via Nostr protocol: +- **Kind 23456** → Admin commands (encrypted, sent by admin) +- **Kind 23457** → Admin responses (encrypted, sent by relay) +- **Kind 24567** → Monitoring/stats events (ephemeral, broadcast by relay) +- **NIP-11** → Relay info (fetched via HTTP, independent of file serving) +- **NIP-17** → DM admin commands (gift-wrapped) + +Moving to client-ndk means the relay serves zero HTML — it only speaks Nostr protocol. + +## Architecture + +```mermaid +graph LR + subgraph client-ndk project + A[c-relay-pg.html] --> B[init-ndk.mjs] + B --> C[NDK SharedWorker] + end + + subgraph c-relay-pg + D[WebSocket Server] + E[api-worker thread] + end + + C -->|kind 23456 admin cmds| D + D -->|kind 23457 responses| C + E -->|kind 24567 monitoring| D + D -->|kind 24567 events| C + C -->|kind 1059 NIP-17 DMs| D +``` + +## Current Admin Page Sections + +| Section | Data Source | Communication | +|---------|-----------|---------------| +| Statistics | kind 24567 monitoring events with d-tags: event_kinds, time_stats, top_pubkeys, cpu_metrics | Subscribe to kind 24567 | +| Subscriptions | kind 24567 monitoring events with d-tag: subscription_details | Subscribe to kind 24567 | +| Configuration | kind 23457 admin responses | Send kind 23456 config_query, receive kind 23457 | +| Authorization | kind 23457 admin responses | Send kind 23456 auth rule commands, receive kind 23457 | +| IP Bans | kind 23457 admin responses | Send kind 23456 ip_ban_* commands, receive kind 23457 | +| Relay Events | Live subscription to all events + kind 0/10050/10002 management | Standard Nostr subscriptions | +| DM | NIP-17 gift-wrapped DMs kind 1059 | NIP-17 encrypt/wrap/publish | +| SQL Query | kind 23457 admin responses | Send kind 23456 sql_query, receive kind 23457 | + +## Design Decisions + +1. **Full client-ndk page** — Uses `client.css`, `init-ndk.mjs`, `HamburgerMorphing`, `relay-ui.mjs`, `blossom-ui.mjs`, `ai-ui.mjs` — all standard template infrastructure stays intact +2. **Sidenav preserved** — All existing sidenav sections (Relay, Blossom, AI) remain. Admin page navigation links are added to `divSideNavBody` as clickable items +3. **Page-specific CSS** — Follows client-ndk convention: page styles in inline `