diff --git a/FUTURE.md b/FUTURE.md index 190aeb2..1a9d514 100644 --- a/FUTURE.md +++ b/FUTURE.md @@ -38,12 +38,12 @@ React + Vite frontend. Two modes: ### NAT Traversal ✅ (WebRTC ICE/STUN) Solved by using WebRTC DataChannels via pion. ICE gathers host + server-reflexive (STUN) candidates and performs UDP hole punching automatically. The anchor (`cmd/anchor`) doubles as a STUN server on UDP/3478. -### TURN relay ✅ (shipped, browser mode) -Browser mode now supports TURN relay. `iceServers()` in `browser.ts` reads `WASTE_CONFIG.turnURL` and `WASTE_CONFIG.turnSecret`, generates time-limited HMAC-SHA1 credentials (compatible with coturn `use-auth-secret`), and adds the TURN server to the ICE candidate list. Mobile/CGNAT peers that fail STUN hole-punching automatically fall back to TURN relay. +### TURN relay ✅ (shipped) +Both browser and daemon modes support TURN relay. -The peer dot in the sidebar turns yellow for relayed connections (`candidate_type: relay`). +**Browser mode:** `iceServers()` in `browser.ts` reads `WASTE_CONFIG.turnURL` and `WASTE_CONFIG.turnSecret`, generates time-limited HMAC-SHA1 credentials (compatible with coturn `use-auth-secret`), and adds the TURN server to the ICE candidate list. The peer dot turns yellow for relayed connections (`candidate_type: relay`). -**Daemon mode:** not yet wired. Add `-turn-url` / `-turn-secret` flags to `cmd/daemon/main.go` and pass them into the `ICEServers` slice in `internal/anchor/client.go`. +**Daemon mode:** `-turn-url` and `-turn-secret` flags on `cmd/daemon`. `turnICEServers()` in `internal/netmgr/manager.go` generates HMAC-SHA1 credentials and injects them into the ICE server list for every new peer connection. ### Signaling ✅ YAW/2.1 (shipped) Forward-secret signaling via per-session ephemeral X25519 keys. Falls back transparently to 2.0 static-key sealing for peers that don't speak 2.1. @@ -76,10 +76,14 @@ Multiple share roots per network, with global (all networks) or scoped visibilit - **Daemon:** `shares.json` next to `identity.json` in the data dir. `add_share`/`remove_share`/`list_shares` IPC commands. File listing recursively walks all share roots, returning relative paths. Backward compatible with the existing `set_share_dir` single-dir mechanism. - **Browser:** `waste_shares` in `localStorage` stores named share records (folder name, global flag). The `ShareManager` sidebar component shows the list with re-pick (↺) and remove (✕) buttons. Actual `File` objects live in memory — the record persists across reloads so the user can restore with one click. -### Additional Channels / Rooms ✅ (shipped, web UI) -The `+` button in the Rooms sidebar section creates custom rooms, stored in `customRooms` keyed by `network_id`. Room names are slugified strings — any peer that sends to a room name causes it to appear on the recipient automatically. DM rooms (`dm:`) appear automatically when messages arrive. +### Additional Channels / Rooms ✅ (shipped) +Custom rooms are supported in both the web UI and the TUI. -**Not yet done:** TUI room creation, daemon-side SQLite persistence of room lists across restarts. +**Web UI:** The `+` button in the Rooms sidebar creates custom rooms, stored in `customRooms` keyed by `network_id`. Room names are slugified strings — any peer that sends to a room name causes it to appear on the recipient automatically. + +**TUI:** Type `/room ` in the input to create a room. The daemon persists it in the `rooms` SQLite table and echoes a `room_created` IPC event back. On reconnect, rooms are restored via `state_snapshot`. Rooms that receive messages while not active show a `*` prefix in the sidebar; the marker clears when you switch to that room. + +DM rooms (`dm:`) appear automatically in both interfaces when messages arrive. ### File Transfer UX ✅ (shipped) - Manual accept/reject via the Transfers panel in the sidebar @@ -89,9 +93,6 @@ The `+` button in the Rooms sidebar section creates custom rooms, stored in `cus **Not yet done:** resume after disconnection, daemon-side download directory. -### TURN Relay for Daemon Mode -The daemon doesn't yet support TURN. Add `-turn-url` and `-turn-secret` flags to `cmd/daemon/main.go` and wire them into the ICE server list in `internal/anchor/client.go`. The credential generation is the same HMAC-SHA1 scheme already implemented in browser mode. - ### Native UI Web frontend (React, already built) + Tauri shell for native packaging. The IPC protocol is the full boundary — the UI is already a pure consumer. Main work: Tauri setup, system tray, OS notifications. @@ -124,8 +125,9 @@ Web frontend (React, already built) + Tauri shell for native packaging. The IPC | ✅ shipped | Signed invites + invite-only networks (`RequireInvite`) | | ✅ shipped | Hash-based "come hang" links (`#waste:...`) | | ✅ shipped | Protocol extensions documented in EXTENSIONS.md | -| next | TURN relay for daemon mode | -| next | TUI room creation + daemon-side room persistence | +| ✅ shipped | TURN relay for daemon mode (`-turn-url` / `-turn-secret`) | +| ✅ shipped | TUI room creation + daemon-side room persistence | +| ✅ shipped | Unread room indicators in TUI (`*` prefix) | | next | File transfer resume after disconnection | | future | Native UI (React + Tauri) | diff --git a/README.md b/README.md index 482cb55..a1a877c 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,8 @@ The `use-auth-secret` mode generates short-lived TURN credentials from the share > The browser adapter reads `turnURL` and `turnSecret` from `WASTE_CONFIG` and adds the TURN server to the WebRTC `ICEServers` list automatically. If not configured, STUN-only is used (works for most desktop/home NAT situations). +**Daemon mode TURN:** pass `-turn-url turn:your-domain.com:3478 -turn-secret YOUR_SECRET_HERE` when starting the daemon. The same coturn `use-auth-secret` HMAC-SHA1 scheme is used — no extra config required beyond what you set up for browser mode. + --- ## How it works: daemon vs browser mode @@ -318,6 +320,8 @@ go run ./cmd/tui -network friends **Key bindings:** `Tab`/`Shift+Tab` — switch rooms · `PgUp`/`PgDn` — scroll · `Enter` — send · `Ctrl+I` — generate invite · `Esc` — close overlay · `Ctrl+C` — quit +**Slash commands:** `/room ` — create a new room (persisted in SQLite, restored on reconnect). Rooms with unread messages show a `*` prefix in the sidebar. + --- ## IPC protocol @@ -338,6 +342,7 @@ Newline-delimited JSON on TCP port 17337 (or WebSocket on 17338). {"type":"add_share","path":"/home/alice/Docs","networks":["abc123"]} // network-scoped {"type":"remove_share","path":"/home/alice/Music"} {"type":"list_shares"} +{"type":"create_room","room":"dev"} {"type":"export_identity","passphrase":"..."} {"type":"import_identity","passphrase":"...","backup":"..."} ``` @@ -353,6 +358,7 @@ Newline-delimited JSON on TCP port 17337 (or WebSocket on 17338). {"type":"invite_generated","invite":"waste:"} {"type":"incoming_file","peer_id":"<64-hex>","offer":{"xid":"...","name":"notes.txt","size":1024,"sha256":"..."}} {"type":"file_complete","transfer_id":"...","path":"/downloads/notes.txt"} +{"type":"room_created","network_id":"...","room":"dev"} {"type":"identity_exported","backup":"..."} {"type":"error","error_message":"..."} ```