Version the protocol for 1.0, fail downloads the page abandoned

PROTOCOL (hellcon/1) goes in front of the PBKDF2 salt and names the data
channel, so different versions never meet via a tracker and the manual
receiver tells a sender on another protocol apart. The footer shows it, the
receiver's hints ask to compare it. Forks are asked to name their own.

public/sw.js and the page exchange a VERSION, a mismatch fails the download
with outdated. The worker fails a download after 20 s without a chunk or
ping from its page, else Firefox saves the truncated file of a closed tab as
complete.

The build uses relative links and works under any path. On https only wss:
trackers and ws: to this device are accepted, one the browser refuses to
open counts as lost. Also: a file read short stops the transfer, an offer
waiting on a lost tracker isn't answered, a share ended while its key was
derived opens no tracker, and tracker and receiver errors lose hidden
characters. The README lists what isn't planned and the phone limitation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-30 15:10:09 +01:00
1 parent 44a8a72261
commit ac4d496a48
11 files changed
+399 -56

No files matched your search

+23 -6
View File
@@ -11,6 +11,7 @@ import {
formatTime,
type Incoming,
type Phase,
PROTOCOL,
type ReceiveEvents,
randomCode,
receiveViaTracker,
@@ -46,9 +47,23 @@ function isStun(url: string) {
return stunChecks.get(url)!;
}
// Every # starts a fragment, which WebSocket rejects even when empty.
const isTracker = (url: string) =>
URL.canParse(url) && ['ws:', 'wss:'].includes(new URL(url).protocol) && !url.includes('#');
// public/ in the build, which works under any path, see vite.config.ts.
const BASE = import.meta.env.BASE_URL;
// Every # starts a fragment, which WebSocket rejects even when empty. An https page may open ws: only
// to this device, browsers refuse it or fail it for anything else. That is localhost and its
// subdomains, 127.0.0.0/8 and ::1, URL writes every form of these addresses this way.
const secure = location.protocol === 'https:';
const isLocal = (hostname: string) =>
hostname === 'localhost' ||
hostname.endsWith('.localhost') ||
/^127\.\d+\.\d+\.\d+$/.test(hostname) ||
hostname === '[::1]';
const isTracker = (url: string) => {
if (!URL.canParse(url) || url.includes('#')) return false;
const { protocol, hostname } = new URL(url);
return protocol === 'wss:' || (protocol === 'ws:' && (!secure || isLocal(hostname)));
};
// A textarea with one URL per line for the list at settings[key], invalid lines are listed and skipped.
function serverList(key: 'stunServers' | 'trackers', valid: (url: string) => boolean) {
@@ -349,7 +364,7 @@ document.addEventListener('visibilitychange', holdWakeLock);
<template>
<header>
<div>
<img src="/HellNet_alt.png" alt="" width="40" height="40" />
<img :src="`${BASE}HellNet_alt.png`" alt="" width="40" height="40" />
<h1>HellCon</h1>
</div>
<div id="options">
@@ -574,7 +589,8 @@ document.addEventListener('visibilitychange', holdWakeLock);
<label for="trackers">WebTorrent trackers for the code exchange, one URL per line:</label>
<textarea id="trackers" v-model="trackers.text" :aria-invalid="!!trackers.invalid.length"></textarea>
<p v-if="trackers.invalid.length">
Skipped, not a ws: or wss: URL without #: {{ trackers.invalid.join(', ') }}
Skipped, not a ws: or wss: URL without #{{ secure ? ', ws: only to this device on https' : '' }}:
{{ trackers.invalid.join(', ') }}
</p>
</section>
<button id="reset-servers" type="button" @click="onResetServers">Reset to defaults</button>
@@ -589,8 +605,9 @@ document.addEventListener('visibilitychange', holdWakeLock);
<footer>
<a href="https://gitea.pagequit.net/Schluffe/HellCon" target="_blank" rel="noopener noreferrer">
<img src="/gitea.svg" alt="" width="20" height="20" />
<img :src="`${BASE}gitea.svg`" alt="" width="20" height="20" />
Source code
</a>
<span>Protocol {{ PROTOCOL }}</span>
</footer>
</template>