365 lines
18 KiB
Markdown
365 lines
18 KiB
Markdown
# HellCon
|
||
|
||
Current version: **0.0.6**. See the [changelog](CHANGELOG.md) for release
|
||
notes and compatibility changes.
|
||
|
||
Browser-to-browser file sharing with Vue 3 and WebRTC. There are no accounts or
|
||
server-side file storage. Exchange connection codes through a messenger, or
|
||
opt in to experimental tracker reconnect for remembered devices. Manual codes
|
||
need no signaling backend. Connections are direct by
|
||
default. A TURN relay is used only when both people opt in.
|
||
|
||
This is experimental software, not independently audited or battle-tested.
|
||
Browser compatibility, network connectivity, and storage availability vary.
|
||
|
||
## Connections
|
||
|
||
The sidebar lists your connections, starting with **Con 1**, up to 100. Each one
|
||
has its own setup and live session.
|
||
|
||
- **Open** a connection by clicking its row. The row shows its name and this
|
||
tab's session status (not whether the remote device is online).
|
||
- **Rename** with the pen. Enter or leaving the field saves; Escape cancels.
|
||
An empty name keeps the previous one.
|
||
- **Remove** with ✕, then confirm. This ends the connection's sessions in all
|
||
open tabs and forgets its remembered device. Downloaded files and your device
|
||
identity remain. Removing the last connection leaves a fresh **Con 1**.
|
||
- **Add connection** creates another empty slot.
|
||
|
||
Switching connections keeps active transfers and selected files alive while the
|
||
tab stays open. Closing or reloading the page ends live sessions and discards
|
||
selected files; reconnect with fresh codes or a saved tracker pairing. On small
|
||
screens, **Show connections** opens the sidebar, and the bar beside it shows the
|
||
open connection and its status.
|
||
|
||
Names and remembered devices are saved in this browser. Transfer history, file
|
||
contents, connection codes, and relay credentials are not. Clearing site data
|
||
removes saved connections, identities, and trust. If storage fails, the app says
|
||
so and temporary sessions still work.
|
||
|
||
## Sharing files
|
||
|
||
1. **Create a code.** The person starting picks one or more files, chooses a
|
||
STUN provider (PageQuit by default, Google, Cloudflare, custom, or None), and
|
||
clicks **Create code**. They send the code privately to the receiver through
|
||
an authenticated channel.
|
||
2. **Answer it.** The receiver pastes the code and clicks **Accept & create
|
||
answer**, then sends the answer back for the sender to paste. Gathering waits
|
||
up to 30 seconds and fails rather than exporting incomplete connection
|
||
information.
|
||
3. **Compare fingerprints.** Both people compare **both full SHA-256 certificate
|
||
fingerprints** over a channel they trust for authenticity, such as in person.
|
||
Your fingerprint must equal their “Their fingerprint”, and vice versa. Compare
|
||
every byte and cancel on any mismatch. Nothing about the files is sent until
|
||
both people confirm. A [remembered device](#remembered-devices) can replace
|
||
this step on later connections.
|
||
4. **Accept the file.** The receiver sees the filename and size and clicks
|
||
**Accept file**. Files stream into the browser's download manager through a
|
||
same-origin service worker (HTTPS or localhost; Chromium and Brave are tested
|
||
with 120 MiB files). Without streaming support, the native save picker is
|
||
used. Without either, files up to 64 MiB are buffered in memory and handed to
|
||
Downloads on completion (**Save again** repeats this); larger files cannot be
|
||
received. Keep the receiving tab open.
|
||
5. **Receipt.** The sender waits for the receiver's acknowledgment, sent after
|
||
the disk write closes, after all bytes reach the browser's download manager,
|
||
or after the memory download is built. A receipt does not prove the download
|
||
manager saved the file (check Downloads), nor that a malicious receiver told
|
||
the truth.
|
||
|
||
Streamed transfers have no app-defined size cap; browser, filesystem, and storage
|
||
limits apply, and byte counts must stay below 2^53. Files above 120 MiB have not
|
||
been tested end to end.
|
||
|
||
### During a session
|
||
|
||
Once verified, either person can add files without new codes. Each side queues
|
||
up to 32 files, including its active one. Each direction sends one file at a
|
||
time, and both directions can run at once. Every file has its own acceptance,
|
||
progress, and receipt. **Remove** drops a waiting file from your queue;
|
||
**Decline file** rejects an incoming one and lets the sender's queue continue.
|
||
Send/Receive chooses who starts before connecting; afterwards it switches between
|
||
the sending and receiving sections without reconnecting.
|
||
|
||
**Disconnect** ends the session, drops waiting files, and aborts unfinished disk
|
||
writes; cancelling a single active file is not supported. A completed memory
|
||
download stays available via **Save again** until the next accepted file
|
||
replaces it. **Reset** discards it and returns to setup; the connection stays.
|
||
|
||
Switching tabs or apps does not end the session, but browsers and mobile systems
|
||
may suspend pages. Pending verification or acceptance expires after five
|
||
minutes, stalled transfers after one minute; idle verified sessions stay open.
|
||
|
||
### Troubleshooting
|
||
|
||
- A pasted answer that is invalid, an offer in the answer field, or an answer for
|
||
a different code is reported without discarding the live offer. Fix it and
|
||
click **Connect** again.
|
||
- After a connection closes or fails, use **Reset** and exchange a new offer and
|
||
answer. Old codes cannot reopen it.
|
||
- If a configured STUN server is unreachable, try None for a local test. For a
|
||
local test, use two tabs or windows, and Disconnect before changing roles.
|
||
- Expand **Connection diagnostics** to copy the last 80 timed events: candidate
|
||
type counts, candidate-pair and DTLS states, selected route types, and ICE
|
||
check counters, with snapshots taken before failed pairs disappear. A `?` means
|
||
the browser supplied no value, not zero. Addresses, SDP, candidate IDs,
|
||
credentials, server URLs, and filenames are excluded.
|
||
|
||
Same-machine success does not show cross-device connectivity, and error 701
|
||
alone does not identify a cause. See [the investigation
|
||
notes](docs/connection-investigation.md) for the comparison with the first
|
||
version. `node scripts/compare-ice.mjs firefox` (or `chromium`) runs a local ICE
|
||
experiment with deliberately unusable offer ports and a 20-second answer delay;
|
||
add `--normal-candidates` to keep real ports. It is **not a cross-device test**.
|
||
|
||
## Remembered devices
|
||
|
||
Each connection can remember one device, so later sessions skip the manual
|
||
fingerprint comparison.
|
||
|
||
1. On both browsers, expand **Remembered device** and choose **Create device
|
||
identity**. This also turns on **Use my device identity on this connection**;
|
||
each connection has its own opt-in, and new connections start without it.
|
||
2. Connect and compare full fingerprints once. Leave **Remember this device for
|
||
…** ticked when confirming, and the verified peer is paired with this
|
||
connection. The connection's name is the device's name and never leaves
|
||
this browser.
|
||
|
||
Later sessions check fresh signed proofs bound to both device keys and both
|
||
connection fingerprints; file acceptance is still required. A changed or missing
|
||
identity falls back to manual comparison and only replaces the paired device if
|
||
you tick **Replace the paired device**. **Forget device** unpairs it. One device
|
||
can be paired with several connections.
|
||
|
||
Identity-enabled codes use signaling **v4**; temporary codes use **v3**. If only
|
||
one peer enables identity, the session uses manual comparison without
|
||
remembering. Public identities in codes can link sessions. Browser-stored keys
|
||
are usable by any code the host serves, so they do not protect against a
|
||
malicious host. See [the identity protocol and storage](docs/device-identities.md).
|
||
|
||
### Experimental reconnect without codes
|
||
|
||
Once both browsers have remembered each other in a verified session:
|
||
|
||
1. Under **Network settings → Connection discovery**, choose a custom `wss://`
|
||
WebTorrent tracker, or the host's default if one is configured.
|
||
2. Click **Set up reconnect**. The other person checks the tracker host and
|
||
accepts. Both browsers must save the settings before setup reports success.
|
||
3. After disconnecting or reloading, both people open their saved connection and
|
||
press **Reconnect**. Fresh device proofs authenticate the session; each file
|
||
still requires acceptance. TURN still requires both people to opt in.
|
||
|
||
The tracker sees IP addresses, timing and encrypted signaling sizes; codes and
|
||
files remain private from it. The pairing key stays in browser storage. Changing
|
||
Connection discovery applies to new setups; existing pairings keep their tracker.
|
||
**Turn off reconnect** removes the local pairing. The other browser removes its
|
||
copy at the next authenticated manual session if the pairings no longer match.
|
||
|
||
If reconnect fails, exchange fresh codes. Reconnect attempts started on opposite
|
||
sides of UTC midnight need restarting. See the [implementation status and
|
||
limits](docs/webtorrent-reconnect.md#concept-status).
|
||
|
||
## Privacy and security
|
||
|
||
### Connection codes
|
||
|
||
Connection codes are **compressed and Base64url-encoded, not encrypted** (`HC1.`
|
||
followed by deflated JSON). They contain SDP: candidate addresses, temporary ICE
|
||
credentials, and certificate fingerprints. Anyone who sees a code, including the
|
||
messaging service, may learn these details. Treat codes as private and do not
|
||
publish them. The browser may obscure local addresses, but this app does not
|
||
provide anonymity.
|
||
|
||
File transfers use protocol **v3**; codes from older builds are rejected before
|
||
connecting.
|
||
|
||
### STUN and optional TURN
|
||
|
||
STUN discovers externally reachable addresses. Its operator sees your public IP
|
||
and request metadata but never file contents. Choosing None avoids contacting a
|
||
STUN provider; direct connectivity then depends on addresses, routing, browser
|
||
policy, and firewalls. A VPN does not guarantee against address disclosure.
|
||
|
||
Restrictive NATs or firewalls can block direct connections, and there is no
|
||
silent TURN fallback. To permit a relay, both people check **Allow a TURN
|
||
relay**, enter their authorized TURN URL, username, and password, and create new
|
||
codes. Otherwise TURN URLs and codes with relay candidates are rejected. Enabling
|
||
TURN lets the browser use a relay route when needed; it does not force relay-only
|
||
routing or hide your IP from the peer, and it cannot control software the other
|
||
person runs.
|
||
|
||
When a credential endpoint is configured, **Use the configured relay with
|
||
temporary credentials** fetches fresh credentials for each connection after
|
||
opt-in and shows them read-only. Uncheck it to enter a relay manually. TURN
|
||
credentials stay in memory and never enter codes. The relay sees its
|
||
authentication exchange, addresses, timing, and traffic volume, but file traffic
|
||
remains DTLS-encrypted. Reset, cancel, or a closed connection clears TURN
|
||
consent; opt in again for the next relayed connection.
|
||
|
||
### Security model and limits
|
||
|
||
Data channels use **SCTP over DTLS** for transport confidentiality and integrity.
|
||
DTLS authenticates the certificate in the connection description; comparing full
|
||
fingerprints over an independently authenticated channel binds that certificate
|
||
to the intended peer. Comparing over a channel an attacker can rewrite proves
|
||
nothing.
|
||
|
||
You must trust your browser, device, and **the JavaScript you load**. A
|
||
compromised host or build can steal plaintext or falsify the verification
|
||
display. HTTPS protects delivery, not against a malicious host. This code does
|
||
not upload files to its host, but that is no guarantee against a host serving
|
||
different code. The web host, DNS resolver, and code-exchange service are also
|
||
relevant third parties.
|
||
|
||
The protocol accepts one ordered, reliable data channel with bounded metadata
|
||
and messages, exact declared byte counts, and at most one accepted file per
|
||
direction. Monotonic per-direction file IDs bind offers, data, and receipts to
|
||
their files; unexpected states, excess data, and duplicate metadata are rejected.
|
||
A 1 MiB acknowledged send window and a bounded receive queue limit buffering.
|
||
Files are opaque downloads and metadata is never rendered as HTML. Encryption
|
||
does not make a file safe to open. These limits reduce, but do not eliminate,
|
||
denial-of-service and malicious-peer risks.
|
||
|
||
## Self-hosting
|
||
|
||
```sh
|
||
bun install --frozen-lockfile
|
||
bun run build
|
||
```
|
||
|
||
Serve the whole `dist/` directory over HTTPS as static files, including
|
||
`assets/` and `download/worker.js` (with a JavaScript MIME type). No backend or
|
||
third-party helper is needed. Do not expose the Vite dev or preview server;
|
||
`bun run preview` is for local inspection only.
|
||
|
||
Configure `Content-Security-Policy`, `X-Content-Type-Options: nosniff`, and
|
||
`Referrer-Policy: no-referrer`. A baseline CSP for this build:
|
||
|
||
```text
|
||
default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline';
|
||
img-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'none';
|
||
frame-ancestors 'none'
|
||
```
|
||
|
||
Inline styles are used for progress and Vue visibility. The experimental
|
||
tracker reconnect also needs the tracker in `connect-src`, for example
|
||
`connect-src 'self' wss://tracker.example`. Custom policies must
|
||
permit same-origin workers and frames. Test headers on the actual host; CSP is
|
||
defense in depth, not a substitute for trusting the host or a WebRTC egress
|
||
filter. `robots.txt` and indexing metadata are crawler requests, not access
|
||
control.
|
||
|
||
The download worker's scope is `download/` only: it does not control the app
|
||
page, cache the app, or proxy other requests. It serves single-use, randomly
|
||
named URLs from incoming streams with bounded buffering. Closing or resetting an
|
||
unfinished transfer aborts it; interrupted transfers must restart.
|
||
|
||
## Development
|
||
|
||
Use Bun to install dependencies and Node.js 22.18+ to run scripts and tests. All
|
||
code is strict TypeScript; `vue-tsc` checks scripts and templates and runs before
|
||
every production build. TypeScript stays on 6.0 until Vue's checker supports
|
||
TypeScript 7. Vite 8 supplies the Rolldown bundler and Oxc transforms. Node runs
|
||
the TypeScript tests directly, with no test framework or loader. The lockfile
|
||
pins dependencies; review updates and advisories before publishing a build.
|
||
|
||
```sh
|
||
bun install --frozen-lockfile
|
||
bun run dev
|
||
bun run typecheck
|
||
bun run test # unit tests
|
||
bun run build
|
||
bun run test:browser # Chromium integration and axe checks against dist/
|
||
bun run test:browser --connections # sidebar, persistence, live switching, mobile layout
|
||
bun run test:browser --tracker=wss://tracker.example # experimental tracker reconnect
|
||
bun run test:download # real hosted downloads up to 120 MiB, no native picker
|
||
bun run test:cross-browser # Brave sender → Firefox receiver
|
||
bun audit
|
||
```
|
||
|
||
Browser checks run against `dist/`, so build first. They use isolated temporary
|
||
profiles and a loopback server, and never touch your normal browser settings.
|
||
|
||
- `test:browser` and `test:download` need Chromium at `/usr/bin/chromium`
|
||
(override with `CHROMIUM_PATH`, e.g. `/usr/bin/brave`). They verify the actual
|
||
saved bytes; worker tests cover byte counts, backpressure, single-use URLs, and
|
||
cancellation.
|
||
- `test:cross-browser` needs `/usr/bin/brave` and `/usr/bin/firefox` (override
|
||
with `BRAVE_PATH` and `FIREFOX_PATH`) and checks the received file stays
|
||
downloadable after the sender disconnects. Pass `--reverse` for Firefox →
|
||
Brave, or `--default-network` for PageQuit STUN instead of None.
|
||
|
||
### Local STUN/TURN (Linux)
|
||
|
||
Vite stays on the host for hot reload; only coturn runs in Docker. Both bind to
|
||
loopback, so test with two tabs on this machine. Nothing starts at boot and the
|
||
container has no restart policy.
|
||
|
||
```sh
|
||
sudo systemctl start docker.service # if not already running
|
||
# After joining the docker group, log in again or run: newgrp docker
|
||
bun install --frozen-lockfile
|
||
bun run dev:setup # creates .env.development without overwriting it
|
||
bun run turn:up
|
||
bun run dev # open the printed URL in two tabs
|
||
```
|
||
|
||
Pick a file in one tab and choose Receive in the other. Check **Allow a TURN
|
||
relay** in both, leave **Use the configured relay with temporary credentials**
|
||
checked, then exchange codes as usual. Consent clears after each connection.
|
||
|
||
```sh
|
||
bun run test:turn # real file transfer over forced TURN/UDP
|
||
bun run test:turn --tcp # browser-to-TURN over TCP only
|
||
docker compose --env-file .env.development logs --tail=50 coturn
|
||
bun run turn:down
|
||
sudo systemctl stop docker.service docker.socket containerd.service # optional
|
||
```
|
||
|
||
The TURN checks start their own Vite server and browsers but need coturn
|
||
running. They force relay-only routing, assert relay candidates on both ends,
|
||
verify received bytes and receipts, and exercise cancellation and reconnection.
|
||
They do not test Internet NATs or a remote firewall.
|
||
|
||
`.env.development` holds the private `TURN_SECRET`, server-side
|
||
`TURN_HOST`/`TURN_PORT`, and public `VITE_ICE_ENDPOINT`/`VITE_STUN_URL` (see
|
||
[.env.example](.env.example)). The secret never enters the client bundle. When
|
||
changing the port, update `TURN_PORT` and `VITE_STUN_URL`, rerun `turn:up`, and
|
||
restart Vite. Listeners, relay ports 49160–49200, and the pinned image are in
|
||
[compose.yaml](compose.yaml).
|
||
|
||
The credential endpoint is **development-only** Vite middleware and is not part
|
||
of `dist/` or `vite preview`. To use it in production, set `VITE_ICE_ENDPOINT`
|
||
and `VITE_STUN_URL` at build time and implement the same JSON endpoint behind
|
||
your own access policy; [dev/ice-server.ts](dev/ice-server.ts) has the HMAC
|
||
logic. Never expose the development endpoint or the loopback-permitting Compose
|
||
setup as a public relay. Credentials expire after one hour and are not renewed
|
||
during a transfer. See the [coturn Docker
|
||
guide](https://github.com/coturn/coturn/blob/master/docker/coturn/README.md) and
|
||
[configuration
|
||
reference](https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf).
|
||
|
||
### Local WebTorrent tracker
|
||
|
||
[tracker/Dockerfile](tracker/Dockerfile) and
|
||
[compose.tracker.yaml](compose.tracker.yaml) build a locked `bittorrent-tracker`
|
||
release on the official Node image:
|
||
|
||
```sh
|
||
bun run tracker:up # build and start ws://127.0.0.1:8000
|
||
bun run test:tracker # integration checks inside the test image
|
||
bun run tracker:down
|
||
```
|
||
|
||
See [the tracker README](tracker/README.md) for configuration and VPS use.
|
||
The browser supports opt-in [experimental tracker reconnect](#experimental-reconnect-without-codes).
|
||
For a local integration check, run `bun run test:browser --tracker=ws://127.0.0.1:8000`
|
||
after building the app and starting the tracker.
|
||
|
||
## Roadmap
|
||
|
||
See [the hosted-first UX roadmap](docs/ux-roadmap.md).
|
||
|
||
## License
|
||
|
||
MIT — see [LICENSE](LICENSE).
|