Repository navigation
feat: 去中心化中继、单文件中继、Nostr/MQTT、界面简化与文件内自定义中继 - #6
Merged
Merged
Conversation
Room files gain a 更换中继 panel that re-emits the same room (master or wrapped key untouched, no password needed) with a new relay list and exact CSP connect-src. The hosted maker converts existing files, and the CLI gains a retarget command. All three paths produce byte-identical output that passes verify-room-file. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
1. Relay-agnostic transport (version 3 rooms)
- Relay entries bc+wss://, nostr+wss://, mqtt+wss:// select version 3;
classic wss:// rooms stay version 2, unchanged. Retarget converts
between them with the same key, password and roomId.
- html-room/mesh.js: members admit (AES-GCM frames under a master-derived
key), number (announce, claim, earliest claim wins), list and attribute
each other; relays only forward. Every frame goes to every relay and is
de-duplicated by IV, so one surviving relay keeps the room together.
- Node server and Cloudflare Worker serve /bc/<topic> plain broadcast.
2. Easier relays
- relay/go: dependency-free Go broadcast relay, one ~6 MB binary for
Windows, macOS, Linux, BSD, Android and OpenWrt routers; -tunnel prints
a public bc+wss:// address via a Cloudflare quick tunnel (no domain,
open port or root).
- scripts/relay-quickstart.sh downloads it (SHA-256 enforced) and
cloudflared; Relay binaries workflow publishes 13 platform builds.
3. External protocols
- Nostr: ephemeral kind 20111 events tagged with the topic, signed with
a per-session BIP-340 key (@noble/curves).
- MQTT 3.1.1 over WebSocket, QoS 0, topic htmlroom/<topic>.
Tests: unit (parsing, sealing, packets, membership clashes), real relays
(Node, Go, signature-checking Nostr relay, aedes MQTT, Worker /bc/ under
wrangler dev), browser end-to-end over four relays with relay loss.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Rewrites every user-facing string in the room creator and the generated index.html in everyday words, moves relay settings into a collapsed section, highlights the main buttons, and links the repository (https://github.com/Freecode100Year/htmlroom.git) from both pages. Tests updated for the new wording. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Files carry an optional custom: true (on by default in the creation page and CLI room; untick or --strict for exact relays only). Such files allow connect-src wss: plus loopback ws, and show a relay box on the entry screen; typed relays apply to that visit only and pick classic or decentralized mode, with the same key, password and roomId. Web links never show the box. Converter and CLI retarget keep or change the setting. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PCUwNSXQdqfDSugmFo4qmM
Owner
Author
|
已随 #8 并入 main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
一个分支完成三步:去中心化中继、降低中继部署门槛、接入外部协议。另外包括界面文字改为大白话,以及持有房间文件的人可以在文件里自定义中继。
1. 去中心化房间(version 3)
bc+wss://…、nostr+wss://…或mqtt+wss://…/mqtt,房间即为 version 3(1–5 个,可混用,但不能与经典wss://混用)。经典 version 2 房间保持不变;「换中继」可以在两类之间互转,密钥不变。html-room/mesh.js把原来中继负责的事交给成员协商:/bc/<topic>纯转发路径,限制帧大小、速率和每个 topic 的连接数,Origin 规则与/hr/相同。2. 更容易部署中继
relay/go:只用 Go 标准库的 bc 中继,单文件约 6 MB,覆盖 Windows、macOS、Linux、FreeBSD、Android 和 OpenWrt(mips/arm)。-tunnel通过 Cloudflare 临时隧道打印公网bc+wss://地址,不需要域名、公网 IP、开端口或 root。-allow-origin、-tls-cert等参数,以及一个 Dockerfile。scripts/relay-quickstart.sh:下载对应平台的二进制,强制校验 SHA-256;按需下载 cloudflared;也支持--from-source。.github/workflows/relay-binaries.yml:推送 tag 时构建 13 个平台并附加到 Release(需要推送一个 tag,quickstart 的下载地址才可用)。3. 外部协议
["t", topic],每次会话使用一次性密钥做 BIP-340 签名(新增依赖@noble/curves、@noble/hashes)。htmlroom/<topic>。界面文字
文件内自定义中继
custom: true:创建页默认勾选,取消勾选或 CLI 加--strict即关闭。wss: ws://localhost:* ws://127.0.0.1:*加列出的中继。security-model.md。测试
/bc/在wrangler dev下验证。mesh.mjs:3 名成员同时连 4 个中继,安全码一致,回执正常;逐个断开中继直到只剩 Nostr 仍能聊天;成员离开能及时看到;创建页一键生成去中心化房间。custom-relay.mjs:在文件里填写中继,经典和去中心化两种都测了。go vet,可交叉编译到 10 个平台。未验证
npm audit报的undici问题来自 wrangler 开发依赖,在本分支之前就已存在。Generated by Claude Code