Own each transfer in a session and harden the protocol

Every operation (share, receive, manual offer or answer) now runs as one
session tied to an AbortSignal. Starting another ends it: its connections,
tracker sockets and timers close, and it can no longer touch the shared
security check, progress or incoming file. Finished, failed and cancelled
transfers close their connections, and the sender's tracker sockets close
once the download starts.

- A malformed or never-connecting tracker offer no longer blocks a share
- The receiver validates the file offer and rejects excess bytes and
  data beyond the flow control window; sw.js checks name and size too
- Failures show up in the card instead of disappearing into rejected
  promises: bad manual codes, unreachable trackers, lost connections
- Primary buttons and pink text meet 4.5:1 contrast, the STUN switch
  shows keyboard focus again, the tracker Copy button matches the others
- Split the core into src/core.ts, src/main.ts only mounts the app, which
  removes the main.ts <-> App.vue import cycle
- Bring back the Gitea source link, write the README
- Tests reuse one browser per worker with fresh contexts, fail on page
  errors, check cleanup after transfers, use a local fake STUN server
  and cover empty files, window boundaries, odd names, malformed
  messages, session replacement and the production build

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-24 16:04:14 +02:00
1 parent bacc15baaf
commit 2abd0b504d
7 files changed
+1442 -752

No files matched your search

+59
View File
@@ -1 +1,60 @@
# HellCon
Sends a file directly from one browser to another over WebRTC. Nothing passes through a server: the
file goes peer to peer and the receiver's browser streams it straight into its download manager, so
it never has to fit in memory.
## Use
1. The sender picks a file and clicks **Share via tracker**, then gives the 8 character code to the
receiver, who enters it and clicks **Receive**.
Without a tracker, open **Manual** on both sides instead and exchange the offer and the answer
over any channel you trust.
2. Both sides now see a **security check**: two codes, *You* and *Peer*. Compare them over a channel
you trust, e.g. a call: the sender's *You* must equal the receiver's *Peer* and vice versa. Only
if they match, click **Codes match**. Otherwise someone is in between, click **Codes don't match**.
Nothing is transferred before both sides confirmed.
3. The receiver sees the file and clicks **Download**.
One tab runs one transfer at a time, starting another ends the current one. **Use STUN** (on by
default) is needed between different networks, without it only the same network or a VPN works and
no STUN server is contacted. The STUN servers and trackers can be changed under **Servers**, they are
kept in this browser only.
## Run
Needs Node.js and pnpm, see `package.json` for the versions.
```sh
pnpm install
pnpm dev # development server
pnpm build # type check and build into dist/
```
## Host
`dist/` is a static site and can be served by any web server, with these requirements:
- **HTTPS** (or `localhost`): service workers and Web Crypto only work in a secure context.
- **`sw.js` next to `index.html`**, served as JavaScript from the same origin. It streams downloads
and is registered for the `download/` path below the app, so requests there must reach it and not
be rewritten, e.g. by a single-page fallback.
- The trackers are public [WebTorrent](https://webtorrent.io/) trackers by default (`wss://`). Any
WebTorrent compatible tracker works, including a self-hosted one. Only the code exchange goes
through it.
## Test
```sh
pnpm test:install # once, downloads Chromium and Firefox for Playwright
pnpm test # everything except the large tests, needs network for the "live" tests
pnpm test:large # 2.5 GiB transfers and a 40 s stall
```
## Known limitations
- Firefox keeps a download "in progress" when the sender vanishes in the middle of it, until the user
cancels it. HellCon reports the failure, the download manager doesn't. Chromium fails the download,
but only after about 16 s. Details in `TODO.md`.
- Interrupted transfers can't be resumed, they start over.
- Private windows may block service workers, then receiving is not possible and HellCon says so.