diff --git a/README.md b/README.md index 8f1eec2..6bc62c5 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,102 @@ # 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. +Send a file straight from one browser to another. No account, no upload, no app to install, and no +size limit: the file goes directly to the other person and is never stored on a server. -## Use +## How to send a file -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**. +1. **Sender:** open HellCon, drop a file onto the Send card and click **Share via tracker**. You get + an 8 character code. Tell it to the receiver. +2. **Receiver:** open HellCon, enter the code under Receive and click **Receive**. +3. **Both:** compare the security check (see below) and click **Codes match**. +4. **Receiver:** you now see the file's name and size. Click **Download** to save it. -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. +Keep both tabs open until the transfer is finished. Starting something new in a tab ends what that +tab was doing. -## Run +### Without a tracker -Needs Node.js and pnpm, see `package.json` for the versions. +If you'd rather not use a tracker, open **Manual** on both sides. The sender creates an offer, a +long block of text, and sends it to the receiver any way you like, e.g. a chat or an email. The +receiver pastes it, creates an answer and sends that back. The sender pastes the answer and clicks +**Connect**. The offer and answer contain your network addresses, so only share them with the person +you're sending to. + +## The security check + +Once connected, both sides see two short codes: **You** and **Peer**. Compare them with the other +person over a channel you already trust, ideally a call or in person: + +- your **You** must be their **Peer**, and +- your **Peer** must be their **You**. + +If both match, you are connected directly to each other. If they don't, someone has placed +themselves in between: click **Codes don't match** and nothing is sent. Nothing is transferred before +both sides confirmed, so take the few seconds to really compare them. + +The codes are taken from the encryption keys of the connection. Someone in between would need their +own keys, which show up as different codes. + +## How it works + +The file travels over a direct, encrypted WebRTC connection between the two browsers. To set that up, +the browsers need two things: + +- **Finding each other.** The code puts both browsers into the same group on a public + [WebTorrent](https://webtorrent.io/) tracker, which only passes the connection details back and + forth. It never sees the file. With the manual exchange you play the tracker yourself. +- **Reaching each other.** Most devices sit behind a router and don't know their public address. + A STUN server tells them. With **Use STUN** turned off no STUN server is contacted, which works + only on the same network or over a VPN. + +On the receiving side, HellCon hands the incoming data to the browser's own download manager while +it arrives. That's why files larger than your memory work too, and why the download shows up in +your browser's download list. + +There is no relay server. If both sides are behind very strict networks, e.g. some company or mobile +networks, a direct connection may not be possible. + +## Privacy + +- The file only goes to the person you connected with. +- That person learns your IP address, as with any direct connection. The tracker and the STUN + servers see it too. +- Settings (STUN on or off, your server lists) are kept in your browser only. +- Whoever hosts HellCon serves the code that runs in your browser. If you'd rather not trust that, + host your own (below). + +## Settings + +Under **Servers** you can change which STUN servers and trackers your browser uses, one address per +line. Any WebTorrent compatible tracker works, including one you run yourself. **Reset to defaults** +brings back the original lists. Both sides must use at least one tracker in common to find each +other. + +## Host your own + +HellCon is a static website, any web server can host it. Build it with Node.js and pnpm: ```sh pnpm install -pnpm dev # development server -pnpm build # type check and build into dist/ +pnpm build ``` -## Host +Then serve the `dist/` folder, with these requirements: -`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 -``` +- **HTTPS.** Browsers only allow the parts HellCon needs on secure pages (`localhost` is fine for + trying it out). +- **`sw.js` next to `index.html`.** It streams the downloads. Requests to the `download/` path below + HellCon must reach it unchanged, so don't rewrite them to `index.html`. ## 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. +- **Firefox:** if the sender disappears in the middle of a transfer, HellCon reports the failure, + but Firefox keeps showing the download as in progress until you cancel it. +- **Chromium:** notices a vanished sender only after about 16 seconds. +- An interrupted transfer can't be resumed, it starts over. +- Private windows may not allow the background part that saves downloads. Receiving then doesn't + work, and HellCon tells you so. + +## License + +MIT, see [LICENSE](LICENSE).