Add an own tracker and STUN server in backend/
backend/ runs both as Docker Compose services, neither is needed: the client works with any WebTorrent tracker and STUN server. The tracker is one file on Node and ws that does only the part of the protocol HellCon uses. It accepts allowed origins only and messages of at most 16 KiB, only announce, one offer per announce and answers only to offers it delivered, once. Forwarded messages are rebuilt from the checked fields. It limits the message rate, the signaling each connection sends, the bytes queued for a peer that stops reading, connection age, connections per IP and in total, and peers per swarm. It logs nothing. coturn runs STUN only on the host network, pinned, read-only and without capabilities beyond the one its binary needs. backend/tracker.spec.mjs tests its rules one by one, e2e.spec.ts sends a real file through it alone in both directions between Chromium and Firefox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb69569b51
commit
22d794965e
10 files changed
+665
-51
No files matched your search
@@ -1,60 +1,21 @@
|
||||
# TODO
|
||||
|
||||
## Server at pagequit.net, to decide
|
||||
## Server at pagequit.net
|
||||
|
||||
### Review of the coturn setup (STUN only, host network)
|
||||
`backend/` holds both servers, tested locally: a real transfer Chromium to Firefox through only them,
|
||||
and the tracker's limits one by one. Left to do on the server:
|
||||
|
||||
- Good as it is: `stun-only`, `no-tcp`, `no-tls`, `no-software-attribute`, CPU, memory and process
|
||||
limits with swap off, and log rotation. Host networking is right for STUN, so Docker's NAT can't
|
||||
change the source address the clients get back. Listening on IPv4 only matches DNS:
|
||||
`stun.pagequit.net` has an A record and no AAAA.
|
||||
- `coturn/coturn:latest` is the only unpinned version. Pin `coturn/coturn:4.18.0` (2026-09-08).
|
||||
- Add `no-cli`. On the host network, coturn's admin CLI would otherwise listen on the host's
|
||||
127.0.0.1:5766 if it's enabled.
|
||||
- Add `no-stun-backward-compatibility`. Browsers only use the current STUN protocol, so the old
|
||||
RFC 3489 requests and their extra MAPPED-ADDRESS can go, which also makes responses smaller for
|
||||
reflection attacks.
|
||||
- Check that the logs hold no client addresses: send a STUN request, then
|
||||
`docker compose logs coturn | grep <your IP>`. Logging each request is off by default and
|
||||
`log-binding` turns it on, so it should stay empty. Otherwise up to 20 MB of addresses stay around.
|
||||
- Missing compared to the tracker draft: `cap_drop: [ALL]` and
|
||||
`security_opt: [no-new-privileges:true]`. `read_only: true` is worth trying too, but coturn may
|
||||
need a writable `/var/run` or `/var/lib/coturn` (`tmpfs`).
|
||||
- Replace the running coturn with `backend/compose.yaml`. coturn 4.18 has the admin CLI, DTLS, the
|
||||
RFC 3489 MAPPED-ADDRESS and the software attribute off by default, the `--no-` options for them are
|
||||
gone. Set `ORIGINS` in `backend/.env`, and `CADDY_NETWORK` if Caddy's network isn't `caddy`.
|
||||
- Add `tracker.pagequit.net` to Caddy and DNS (A record, like `stun.pagequit.net`).
|
||||
- Check that the logs hold no client addresses: transfer once, then
|
||||
`docker compose logs | grep <your IP>` should stay empty.
|
||||
- Then put `wss://tracker.pagequit.net` first in `DEFAULT_TRACKERS` and keep the public trackers as
|
||||
fallbacks.
|
||||
- coturn doesn't rate limit STUN requests. A response is about as big as the request, so it's a weak
|
||||
amplifier. If it gets abused, an nftables `limit` on the UDP port would help.
|
||||
|
||||
### Compared to the plan so far
|
||||
|
||||
- Caddy and coturn don't share a Docker network, coturn runs on the host network. The tracker joins
|
||||
Caddy's network (its name is in Caddy's compose file), coturn stays as it is.
|
||||
- Copy coturn's limits to the tracker, with smaller values: `cpus`, `mem_limit` equal to
|
||||
`memswap_limit`, `pids_limit`, and the same `json-file` log rotation.
|
||||
- Pin every version, coturn and the tracker alike.
|
||||
|
||||
### Decisions
|
||||
|
||||
1. **Which tracker.** Stock `bittorrent-tracker@11.2.3` behind Caddy works: tested locally with a
|
||||
real transfer from Chromium to Firefox, and it logs nothing with `--quiet`. A review found it too
|
||||
open to run unchanged:
|
||||
- it forwards any data and accepts messages up to 100 MiB
|
||||
- `scrape` lists all swarms even with `--no-stats`
|
||||
- it has no rate, byte or connection limits
|
||||
- it accepts any Origin
|
||||
|
||||
The recommendation is an own tracker for the WebTorrent subset HellCon uses, so the client stays
|
||||
unchanged and the public trackers keep working as fallbacks. Node 26 and `ws`, one file of about
|
||||
250 lines, enforcing:
|
||||
- an Origin allowlist and messages of at most 16 KiB
|
||||
- only `announce`, one offer per announce, and answers only to offers it delivered, once
|
||||
- per connection: a message rate, about 64 KiB of forwarded data, and at most 7 minutes
|
||||
- connections per IP (from `X-Forwarded-For`), total connections and peers per swarm capped
|
||||
- empty swarms removed, nothing logged
|
||||
|
||||
Then decide where it lives: `tracker/` in this repo (new files, every fork gets it) or a separate
|
||||
repository.
|
||||
2. **After deploying:** put `wss://tracker.pagequit.net` first in `DEFAULT_TRACKERS` and keep the
|
||||
public trackers as fallbacks.
|
||||
|
||||
## Ideas
|
||||
|
||||
- Resume interrupted transfers: the receiver already reports how much the download manager has
|
||||
@@ -77,3 +38,8 @@
|
||||
- `large: firefox sends 2.5 GiB` hit the 5 minute timeout once (first run after the normal suite),
|
||||
not reproduced in 3 runs since. The report was lost; the attached logs will show the cause if it
|
||||
happens again.
|
||||
|
||||
- `boundary: chromium sends an empty file` timed out in the first two full runs after `backend/`'s
|
||||
tests were added (2026-10-25), with empty logs on both sides. It passed alone 8 times, and in 5
|
||||
full runs since, one of them with a cold Vite cache. The suite without the new tests passed 4
|
||||
times. Not reproduced, cause unknown.
|
||||
Reference in new issue
Block a user