286 lines
16 KiB
Markdown
286 lines
16 KiB
Markdown
# HellCon
|
||
|
||
Current version: **0.0.3**. See the [changelog](CHANGELOG.md) for release notes
|
||
and compatibility changes.
|
||
|
||
Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling
|
||
backend, or server-side file storage. You exchange connection codes manually.
|
||
Direct connections are the default. TURN relaying is optional and requires
|
||
explicit opt-in by both people; no relay is configured automatically.
|
||
|
||
## How it works
|
||
|
||
1. The sender picks one file and configures STUN (PageQuit by default, Google,
|
||
Cloudflare, a custom provider, or None). They create a code and send it
|
||
privately to the intended receiver through an authenticated channel. Normal
|
||
messenger copy/paste is supported; there is no need to transcribe codes.
|
||
2. The receiver pastes the code, creates an answer, and sends it back. The sender
|
||
pastes the answer. Gathering waits for completion, up to 30 seconds; a timeout
|
||
fails rather than quietly exporting incomplete connection information.
|
||
3. **Both people compare both full SHA-256 certificate fingerprints** over a
|
||
channel whose authenticity and integrity they trust, such as in person.
|
||
Your fingerprint must equal their “Their fingerprint”, and vice versa.
|
||
Compare every byte. Cancel on any mismatch. Both people must explicitly
|
||
confirm before the app sends the filename, size, MIME metadata, or contents.
|
||
4. The receiver sees the filename and size and explicitly accepts the file.
|
||
Supported browsers can stream directly to a chosen disk destination, up to
|
||
64 GiB. Other browsers can receive files up to 64 MiB in memory and then offer
|
||
a download. Larger files require direct-to-disk support. Even capped memory
|
||
downloads may be too large on a memory-constrained device.
|
||
5. The sender waits for a receipt acknowledgment. For disk transfers, the receiver
|
||
sends this only after its writable stream closes successfully; for memory
|
||
transfers, after constructing the complete download. This does not prove a
|
||
human saved the memory download, nor that a malicious receiver told the truth.
|
||
|
||
Cancel, reset, changing the selected file, or switching Send/Receive closes the
|
||
connection and aborts unfinished disk writes. Keep the tab open until receipt is
|
||
confirmed. A completed memory download is discarded when you reset or switch.
|
||
Switching browser tabs or apps to copy/paste does not explicitly cancel the
|
||
session, although a browser or mobile OS can suspend a background page.
|
||
Pending verification/acceptance expires after five minutes; stalled transfers
|
||
expire after one minute. The two peers must use this protocol version (v2);
|
||
legacy connection codes are rejected.
|
||
|
||
If an answer is rejected as invalid, correct the pasted answer and click Connect
|
||
again; the sender keeps its existing offer while it is still awaiting an answer.
|
||
After a connection actually closes or fails, use Reset and exchange a **new offer
|
||
and new answer**. Old codes refer to the closed connection and cannot reopen it.
|
||
Reset returns the page to its initial ready state. For a local test, open two
|
||
separate browser tabs or windows; switching Send/Receive inside one page cancels
|
||
that page's previous connection. Use the specific error shown in red to diagnose
|
||
failures; if a configured STUN server is unreachable, try None for a local test.
|
||
|
||
### Connection diagnostics and first-version comparison
|
||
|
||
Expand **Connection diagnostics** to copy the last 80 timed events. The log
|
||
retains local/remote candidate type counts, candidate-pair states, selected
|
||
route types, and ICE check request/response counters after failure. Final stats
|
||
are requested before closing the peer, with a 300 ms cleanup bound. A `?` means
|
||
the browser did not supply a counter; it does not mean zero. Addresses, raw SDP,
|
||
candidate IDs, credentials, server URLs and filenames are excluded.
|
||
|
||
Same-machine success does not establish cross-device connectivity. Error 701
|
||
alone does not establish the cause of a failed connection. A receiver shutdown
|
||
after both sides report completion can be normal sender cleanup.
|
||
|
||
The comparison with the first commit and controlled test results are recorded in
|
||
[the investigation notes](docs/connection-investigation.md). Run the isolated
|
||
ICE experiment with `node scripts/compare-ice.mjs firefox` or replace `firefox`
|
||
with `chromium`. This uses local browser peers and deliberately unusable offer
|
||
ports plus a 20-second answer delay; it is **not a cross-device test**. Add
|
||
`--normal-candidates` to preserve the real candidate ports. No firewall changes,
|
||
TURN credentials or public STUN service are required.
|
||
|
||
## Network privacy and optional TURN
|
||
|
||
STUN discovers externally reachable addresses. Its operator can see your public
|
||
IP address and request metadata, but STUN does not relay file contents. Lookups,
|
||
retries and connectivity checks may involve multiple packets. Choosing None
|
||
avoids contacting a configured STUN provider; direct connectivity depends on
|
||
addresses, routing, browser policy and firewalls, not simply whether peers share
|
||
one network. A VPN is not automatically a guarantee against address disclosure.
|
||
|
||
Connection codes are **Base64-encoded, not encrypted**. They contain SDP,
|
||
including candidate addresses, temporary ICE credentials and certificate
|
||
fingerprints. Peers and anyone who sees these codes (including the messaging
|
||
service used to exchange them) may learn connection details. Local addresses may
|
||
be obscured by the browser, but this app does not provide anonymity. Treat codes
|
||
as private session information; do not publish them.
|
||
|
||
Restrictive NATs or firewalls can prevent direct connections. There is no silent
|
||
TURN retry. To permit a relay, both people must explicitly check **Allow a TURN
|
||
relay**, supply their authorized TURN URL, username and password, and generate
|
||
new codes. Otherwise TURN URLs are rejected in the STUN field and codes with
|
||
relay candidates are rejected. Enabling TURN allows the browser to contact that
|
||
relay during gathering and select a relay route when needed. This does not force
|
||
relay-only routing or hide your IP from the peer. A remote peer can independently
|
||
proxy their own traffic; the opt-in controls this app's configuration and the
|
||
relay candidates it accepts, not arbitrary software run by the other person.
|
||
|
||
When a credential endpoint is configured (including the local development setup
|
||
below), **Use the configured relay with temporary credentials** replaces manual
|
||
credential entry. The app fetches fresh credentials for each new connection,
|
||
only after TURN opt-in. The issued relay address, username and masked password
|
||
appear in read-only fields while the connection is active. Uncheck it to use a
|
||
different relay manually.
|
||
|
||
TURN credentials stay in the current component's memory; the app does not persist
|
||
them or include them in codes. The relay receives its authentication exchange and
|
||
can observe addresses, timing and traffic volume, and may charge for bandwidth.
|
||
Resetting, cancelling, completing or failing a connection clears TURN consent;
|
||
check the option again before creating another relayed connection.
|
||
File traffic remains DTLS encrypted through the relay. The web host, DNS resolver,
|
||
and code-exchange service are also relevant third parties.
|
||
|
||
## Security model and limits
|
||
|
||
Data channels use **SCTP over DTLS**, which provides transport confidentiality and
|
||
integrity. This is not DTLS-SRTP (the media transport). DTLS authenticates the
|
||
certificate in the connection description; an independently authenticated full
|
||
fingerprint comparison binds that certificate to the intended peer. Comparing
|
||
fingerprints through a channel an attacker can rewrite provides no such assurance.
|
||
|
||
You must trust your browser, device, and **the JavaScript you load**. A compromised
|
||
host or build can steal plaintext or falsify the verification display. Serve the
|
||
production build over HTTPS, or run a verified build you control on localhost.
|
||
HTTPS protects delivery against network tampering, not against a malicious host.
|
||
The app does not upload files to its web host in this implementation; that is a
|
||
property of this code, not a guarantee against a host serving different code.
|
||
|
||
The protocol accepts one ordered, reliable data channel, bounded metadata and
|
||
messages, an exact declared byte count, and a single file. It rejects unexpected
|
||
states, excess data and duplicate metadata. An acknowledged 1 MiB send window
|
||
and a bounded receive queue limit buffering during disk writes. Files are treated
|
||
as opaque downloads; metadata is not rendered as HTML. Encryption does not make
|
||
a file safe to open. These limits reduce denial-of-service exposure but do not
|
||
eliminate browser, device, network, or malicious-peer risks.
|
||
|
||
For deployment, serve `dist/` as static files over HTTPS. Do not expose the Vite
|
||
dev or preview server as the production service. Configure hosting headers such
|
||
as `Content-Security-Policy` (including `frame-ancestors 'none'`),
|
||
`X-Content-Type-Options: nosniff` and `Referrer-Policy: no-referrer`. A baseline
|
||
CSP for this build is `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 currently used for progress and
|
||
Vue visibility. Test headers on the actual host; CSP is defense in depth and is
|
||
not a substitute for trusting the host or a portable WebRTC egress filter.
|
||
`robots.txt` and indexing metadata are crawler requests, not access control.
|
||
|
||
## Download and run locally
|
||
|
||
Run `bun run build`, then open `dist/hellcon-local.html` directly in a browser.
|
||
This single HTML file includes the app code, styles, and icon. A hosted production
|
||
build also offers **Download app for local use**. Download that file instead of
|
||
using the browser's **Save Page As** command, which may save only the hosted page
|
||
without its required assets. You can share the downloaded HTML file with the
|
||
other participant; both can open it from disk. No web server is needed to load
|
||
the app itself.
|
||
|
||
The app still needs network access to connect peers on different machines, and
|
||
the selected STUN or TURN servers must be reachable. A `file://` copy cannot use
|
||
the host's managed TURN credential endpoint; enter your own relay details when
|
||
needed. Direct-to-disk receiving depends on browser support and may be unavailable
|
||
from a local file. The in-memory receive option remains available.
|
||
|
||
To self-host the regular multi-file build, serve the whole `dist/` directory,
|
||
including `assets/`. Serve it over HTTPS for access from other machines.
|
||
|
||
## Development
|
||
|
||
### Local STUN/TURN environment (Linux)
|
||
|
||
Keep Vite on the host for hot reload; only coturn runs in Docker. Both bind to
|
||
loopback, so use two browser tabs on this machine. No DNS, certificates, firewall
|
||
changes or production services are needed. Nothing is enabled at boot, and the
|
||
container has no automatic restart policy.
|
||
|
||
```sh
|
||
# Start Docker only when needed (if it isn't already running).
|
||
sudo systemctl start docker.service
|
||
# If you just joined the docker group, log in again or run: newgrp docker
|
||
bun install --frozen-lockfile
|
||
bun run dev:setup # creates ignored .env.development, without overwriting it
|
||
bun run turn:up
|
||
bun run dev # open the printed localhost URL in two tabs
|
||
```
|
||
|
||
Pick a file in the sender tab, choose Receive in the other, and check **Allow a
|
||
TURN relay** in both tabs. Leave **Use the configured relay with temporary
|
||
credentials** checked. Exchange codes and compare fingerprints as usual. Reset,
|
||
failure or completion clears consent, so check it again for each connection.
|
||
STUN defaults to the local server; TURN remains opt-in, with direct routes preferred.
|
||
|
||
```sh
|
||
bun run test # protocol and temporary-credential unit tests
|
||
bun run test:turn # real Chromium file transfer, forced TURN/UDP
|
||
bun run test:turn --tcp # same test, TURN/TCP only
|
||
bun run build
|
||
bun run test:browser # direct-path browser regressions and axe accessibility checks
|
||
docker compose --env-file .env.development logs --tail=50 coturn
|
||
```
|
||
|
||
The TURN checks start and stop their own Vite server and isolated browser profiles;
|
||
coturn must already be running. They obtain real temporary credentials, force
|
||
relay-only routing, assert selected relay candidates on both ends, verify exact
|
||
received bytes and receipts, and exercise cancellation and reconnection. TCP here
|
||
means browser-to-TURN transport; relay-to-peer traffic is UDP. These same-machine
|
||
checks do not test Internet NATs or a remote server's firewall.
|
||
|
||
Stop Vite with Ctrl-C, then:
|
||
|
||
```sh
|
||
bun run turn:down
|
||
# Optional: stop Docker too, after finishing any other containers.
|
||
sudo systemctl stop docker.service docker.socket containerd.service
|
||
```
|
||
|
||
`.env.development` contains the private shared `TURN_SECRET`, server-side
|
||
`TURN_HOST`/`TURN_PORT`, and public `VITE_ICE_ENDPOINT`/`VITE_STUN_URL` settings.
|
||
See [.env.example](.env.example). The secret never enters the client bundle.
|
||
Compose passes it directly to coturn; no config-file environment substitution is
|
||
assumed. If changing the port, update both `TURN_PORT` and `VITE_STUN_URL`, then
|
||
rerun `turn:up` and restart Vite. The image is pinned to a concrete release;
|
||
loopback listeners and UDP relay ports 49160–49200 are defined in [compose.yaml](compose.yaml).
|
||
Loopback peer access is explicitly allowed for these local tests.
|
||
|
||
The credential endpoint is **development-only**, implemented as Vite middleware.
|
||
It isn't included in `dist/` or `vite preview`. Production builds ignore
|
||
`.env.development` and retain the existing static/manual configuration. To reuse
|
||
the client integration later, set `VITE_ICE_ENDPOINT` and `VITE_STUN_URL` when
|
||
building and implement the same JSON endpoint behind your production access
|
||
policy. [dev/ice-server.ts](dev/ice-server.ts) contains the HMAC issuance logic.
|
||
There are no accounts or room sessions in this app to authorize production
|
||
credential issuance automatically. Don't expose this development endpoint or
|
||
reuse the loopback-permitting Compose configuration as a public relay.
|
||
|
||
Credentials expire after one hour; each new code exchange fetches fresh ones.
|
||
Automatic renewal during long transfers is not implemented because this app
|
||
uses manual signaling. Keep development transfers below that duration; expired
|
||
or failed sessions need fresh codes.
|
||
|
||
Configuration references: [coturn Docker usage](https://github.com/coturn/coturn/blob/master/docker/coturn/README.md)
|
||
and [coturn configuration](https://github.com/coturn/coturn/blob/master/examples/etc/turnserver.conf).
|
||
|
||
### Existing checks and static build
|
||
|
||
Use Bun for dependency installation and Node.js 22.18+ for the scripts and tests.
|
||
All application code, Vue scripts, development middleware, and checks use strict
|
||
TypeScript. `vue-tsc` checks both TypeScript and Vue templates, and runs before
|
||
every production build. TypeScript stays on 5.9 until Vue's checker supports the
|
||
TypeScript 7 compiler.
|
||
|
||
Vite 8 supplies VoidZero's Rolldown bundler and Oxc transforms. The only added
|
||
development dependencies are TypeScript, `vue-tsc`, and Node types. Node runs
|
||
the TypeScript tests directly; no separate test framework or TS loader is needed.
|
||
|
||
```sh
|
||
bun install --frozen-lockfile
|
||
bun run dev
|
||
bun run typecheck
|
||
bun run test
|
||
bun run build
|
||
bun run test:browser # local Chromium integration checks against dist/
|
||
bun run test:cross-browser # Brave sender → Firefox receiver
|
||
bun run preview # local build inspection only
|
||
bun audit
|
||
```
|
||
|
||
The lockfile pins dependencies. Review dependency updates and advisories before
|
||
publishing a build. Protocol regression tests cover verification gating, malformed
|
||
messages, size limits, cancellation, receipt acknowledgment, and relay opt-in.
|
||
The browser check requires Chromium at `/usr/bin/chromium` (override with
|
||
`CHROMIUM_PATH`); it uses an isolated temporary profile and a loopback server.
|
||
The cross-browser check uses Brave and Firefox at `/usr/bin/brave` and
|
||
`/usr/bin/firefox` (override with `BRAVE_PATH` and `FIREFOX_PATH`). It checks
|
||
that the received file remains downloadable after the sender disconnects.
|
||
Pass `--reverse` to test Firefox → Brave, or `--default-network` to use PageQuit
|
||
STUN instead of the local test's default None. These checks use temporary
|
||
browser profiles and do not modify your normal browser settings.
|
||
|
||
This is experimental software, not independently audited or battle-tested.
|
||
Browser compatibility, network connectivity and storage availability vary.
|
||
|
||
## License
|
||
|
||
MIT — see `LICENSE`.
|