Commit9ea09009Recorded19 Oct 2026Repositorysigil-http3

Prepare isolated same-socket IPv6 priming and public phone controls

Changed
 scripts/check-continuous-punch.mjs        | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/check-phone-page.mjs              |  14 +++++++++++++-
 scripts/phantom-continuous-punch-check.sh |   7 +++++++
 scripts/phantom-spike-echo-check.sh       |   9 +++++++++
 scripts/phantom-spike-sdk.sh              |   3 ++-
 scripts/prepare-continuous-punch.mjs      |  33 +++++++++++++++++++++++++++++++++
 tools/trace/punch.sgl                     | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 web/phone.html                            |  15 +++++++++++++--
 8 files changed, 315 insertions(+), 4 deletions(-)
Diff
scripts/check-continuous-punch.mjsadded
@@ -0,0 +1,117 @@
+1
// Real native endpoint + UDP peers, entirely on IPv6 loopback on Linux.
+2
import assert from 'node:assert/strict';
+3
import { spawn } from 'node:child_process';
+4
import { createSocket } from 'node:dgram';
+5
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+6
import { hostname } from 'node:os';
+7
import { resolve, join } from 'node:path';
+8
import { identity, sameIdentity } from './echo-lifecycle.mjs';
+9
+10
const pause = ms => new Promise(done => setTimeout(done, ms));
+11
const root = resolve('build/continuous-punch-checks');
+12
mkdirSync(root, { mode: 0o700 });
+13
const peers = [], received = [];
+14
let interrupted = false;
+15
const interrupt = () => { interrupted = true; };
+16
process.on('SIGTERM', interrupt);
+17
process.on('SIGINT', interrupt);
+18
const deadline = setTimeout(interrupt, 30000);
+19
async function until(predicate, timeout = 6000) {
+20
const end = Date.now() + timeout;
+21
while (!predicate()) {
+22
if (interrupted || Date.now() > end) throw new Error('Continuous punch check interrupted/deadline');
+23
await pause(25);
+24
}
+25
}
+26
async function check(name, seconds, stopEarly = false) {
+27
const directory = join(root, name);
+28
mkdirSync(directory, { mode: 0o700 });
+29
let output = '', stderr = '', closed = false, code;
+30
const child = spawn(resolve('tools/interop/build/native/bin/http3-preflight'), [], { env: { ...process.env,
+31
HTTP3_PREFLIGHT_HOST: '::1', HTTP3_PREFLIGHT_PORT: '0', HTTP3_PREFLIGHT_DIR: resolve('build/browser'),
+32
HTTP3_PREFLIGHT_ORIGIN: 'https://example.com', HTTP3_PUNCH_DIRECTORY: directory,
+33
HTTP3_PUNCH_TEST_LOOPBACK: '1', HTTP3_SPIKE_TRACE: '1' }, stdio: ['ignore', 'pipe', 'pipe'] });
+34
const admitted = identity(child.pid);
+35
assert.ok(admitted && admitted.uid === process.getuid());
+36
const done = new Promise(done => child.once('close', result => { closed = true; code = result; done(); }));
+37
child.on('error', error => { stderr += error.message; });
+38
child.stdout.on('data', bytes => {
+39
output += bytes.toString().slice(0, Math.max(0, 1048576 - output.length));
+40
if (output.length >= 1048576) interrupt();
+41
});
+42
child.stderr.on('data', bytes => {
+43
stderr += bytes.toString().slice(0, Math.max(0, 1048576 - stderr.length));
+44
if (stderr.length >= 1048576) interrupt();
+45
});
+46
const before = received.length;
+47
let result;
+48
try {
+49
await until(() => closed || output.includes('HTTP3-READY'));
+50
assert.equal(closed, false, stderr);
+51
const port = Number(output.match(/HTTP3-READY[^\n]*port=(\d+)/)?.[1]);
+52
assert.ok(port > 0);
+53
await pause(1050);
+54
assert.equal(received.length, before, 'Control emitted a priming datagram');
+55
const controlAt = new Date().toISOString();
+56
writeFileSync(join(directory, 'command.scm'), `(1 "${name}" "::1" ${seconds})\n`, { flag: 'wx', mode: 0o600 });
+57
if (seconds > 180) {
+58
await until(() => closed);
+59
assert.notEqual(code, 0);
+60
assert.equal(received.length, before);
+61
assert.equal(existsSync(join(directory, 'started.json')), false);
+62
result = { invalidWindowRejected: true };
+63
} else {
+64
await until(() => received.length >= before + 3);
+65
assert.ok(sameIdentity(admitted, identity(child.pid)), 'Listener changed during priming');
+66
// The same endpoint still receives while its socket sends the pulse.
+67
await new Promise((done, reject) => peers[0].send(Buffer.from([0xc0, 0, 0, 0, 1]), port, '::1', error => error ? reject(error) : done()));
+68
await until(() => output.includes('event=udp-in'));
+69
if (stopEarly) writeFileSync(join(directory, 'stop'), 'stop\n', { mode: 0o600 });
+70
await until(() => existsSync(join(directory, 'finished.json')));
+71
const finish = JSON.parse(readFileSync(join(directory, 'finished.json')));
+72
const count = received.length;
+73
await pause(1200);
+74
assert.equal(received.length, count, 'Sender continued after its bounded window');
+75
assert.equal(closed, false, 'Priming stopped the listener');
+76
assert.ok(sameIdentity(admitted, identity(child.pid)));
+77
const packets = received.slice(before);
+78
assert.ok(packets.every(p => p.address === '::1' && p.port === port && p.bytes === 8), 'Priming used a different source tuple');
+79
assert.equal(packets.length, finish.packets);
+80
assert.ok(packets.length <= 3 * seconds);
+81
assert.equal(finish.reason, stopEarly ? 'controller-stop' : 'window-expired');
+82
if (!stopEarly) {
+83
assert.equal(packets.length, 9);
+84
const first = packets.filter(p => p.destinationPort === 40000).map(p => p.time);
+85
assert.ok(first[1] - first[0] >= 950 && first[2] - first[1] >= 950);
+86
}
+87
result = { controlAt, sourcePort: port, packets: packets.length, finish,
+88
samePID: true, ingressWhilePriming: true, stoppedSendingStillListening: true };
+89
}
+90
} finally {
+91
if (!closed && sameIdentity(admitted, identity(child.pid))) child.kill('SIGTERM');
+92
await Promise.race([done, pause(2000)]);
+93
if (!closed && sameIdentity(admitted, identity(child.pid))) child.kill('SIGKILL');
+94
await Promise.race([done, pause(2000)]);
+95
assert.equal(closed, true, 'Native child was not reaped');
+96
writeFileSync(join(directory, 'stdout.log'), output, { mode: 0o600 });
+97
writeFileSync(join(directory, 'stderr.log'), stderr, { mode: 0o600 });
+98
}
+99
return result;
+100
}
+101
try {
+102
for (const port of [40000, 40001, 40002]) {
+103
const socket = createSocket('udp6'); peers.push(socket);
+104
socket.on('message', (bytes, peer) => received.push({ destinationPort: port, address: peer.address,
+105
port: peer.port, bytes: bytes.length, time: Date.now() }));
+106
await new Promise((done, reject) => { socket.once('error', reject); socket.bind(port, '::1', done); });
+107
}
+108
const results = { bounded: await check('bounded', 3), cancelled: await check('cancelled', 180, true),
+109
invalid: await check('invalid', 181) };
+110
writeFileSync(join(root, 'result.json'), JSON.stringify({ passed: true, results }, null, 2) + '\n', { mode: 0o600 });
+111
console.log('RESULT native-same-socket-continuous-punch=PASS cases=3');
+112
} finally {
+113
clearTimeout(deadline);
+114
process.off('SIGTERM', interrupt);
+115
process.off('SIGINT', interrupt);
+116
await Promise.all(peers.map(socket => new Promise(done => { try { socket.close(done); } catch { done(); } })));
+117
}
scripts/check-phone-page.mjsmodified
@@ -191,9 +191,21 @@ export async function checkPhonePage(cdp, pageUrl, configuration) {
191
await waitFor(value => value.location === autoLink && value.state === 'open' && value.transports === 1,
192
'explicit query autoconnect');
193
await evaluate("document.getElementById('stop').click()");
+194
// Exercise the actual navigator hint, including programmatic form submit.
+195
await evaluate(`Object.defineProperty(navigator, 'onLine', { configurable: true, get: () => false });
+196
window.dispatchEvent(new Event('offline'))`);
+197
const offline = await evaluate(`({ disabled: document.getElementById('connect').disabled,
+198
banner: document.getElementById('network-banner').textContent, count: window.__phoneTransports.length })`);
+199
if (!offline.disabled || !offline.banner.includes('OFFLINE')) throw new Error('Offline Connect gate missing');
+200
await evaluate(`document.getElementById('configuration').dispatchEvent(new Event('submit', { cancelable: true }))`);
+201
if (await evaluate('window.__phoneTransports.length') !== offline.count)
+202
throw new Error('Programmatic submission bypassed the offline gate');
+203
await evaluate(`Object.defineProperty(navigator, 'onLine', { configurable: true, get: () => true });
+204
window.dispatchEvent(new Event('online'))`);
+205
if (await evaluate("document.getElementById('connect').disabled")) throw new Error('Online recovery did not enable Connect');
206
return { mode: 'simulated-page-controls-not-protocol', passed: true, pings,
207
noAutomaticReconnect: failed.transports === 1, manualReconnect: reopened.sessions,
−196
uniEcho: true, invalidHashRejected: true, liveRttGraph: true,
+208
uniEcho: true, invalidHashRejected: true, liveRttGraph: true, offlineGate: true, onlineRecovery: true,
209
pathEvents: paths.pathStatus, oversizedObservationRejected: true, outOfOrderObservationRejected: true,
210
queryLinks: { valid: validLinks.length, rejected: invalidLinks.length,
211
manualUntilRequested: true, explicitAutoconnect: true, safeTargetDisplay: true } };
scripts/phantom-continuous-punch-check.shadded
@@ -0,0 +1,7 @@
+1
#!/usr/bin/env bash
+2
set -euo pipefail
+3
cd "$(dirname "$0")/.."
+4
export HTTP3_SPIKE_SDK_JOB=http3-example
+5
export HTTP3_SPIKE_TRACE_BUILD=1 HTTP3_SPIKE_TRACE=1 HTTP3_TRACE_TESTS=1 HTTP3_SPIKE_TRACE_PROBE=1
+6
export HTTP3_CONTINUOUS_PUNCH_BUILD=1
+7
bash scripts/phantom-spike-echo-check.sh
scripts/phantom-spike-echo-check.shmodified
@@ -27,6 +27,10 @@ test "$(git -C .deps/sigil-quic rev-parse HEAD)" = "$(cat quic.rev)"
27
if [ "${HTTP3_SPIKE_TRACE_BUILD:-0}" = 1 ]; then
28
node scripts/prepare-spike-trace.mjs
29
fi
+30
if [ "${HTTP3_CONTINUOUS_PUNCH_BUILD:-0}" = 1 ]; then
+31
test "${HTTP3_SPIKE_TRACE_BUILD:-0}" = 1
+32
node scripts/prepare-continuous-punch.mjs
+33
fi
34
export SIGIL_JOBS=1
35
unset SIGIL_REDIRECTS SIGIL_LIB SIGIL_LIB_PATH
36
node scripts/generate-spike-tests.mjs > "$results/generate-tests.log" 2>&1
@@ -47,6 +51,8 @@ writeFileSync('build/spike-native-workspace/package.sgl', `;; SPIKE ONLY: no pro
51
bundle?: #t output-dir: "build/native")))
52
`);
53
const sources = ['preflight', 'observations'].map(name => resolve(`tools/interop/src/sigil/http3/interop/${name}.sgl`));
+54
if (process.env.HTTP3_CONTINUOUS_PUNCH_BUILD === '1')
+55
sources.push(resolve('tools/interop/src/sigil/http3/interop/punch.sgl'));
56
if (process.env.HTTP3_SPIKE_TRACE_BUILD === '1') sources.push(...['connection.sgl', 'endpoint.sgl', 'spike/trace.sgl']
57
.map(name => resolve('.deps/sigil-quic/src/sigil/quic/' + name)));
58
writeFileSync('build/spike-echo/read-source.sgl', `(import (sigil io))
@@ -104,6 +110,9 @@ export HTTP3_PREFLIGHT_PREBUILT=1 HTTP3_PREFLIGHT_HTTPS_PAGE=1 HTTP3_PREFLIGHT_Q
110
HTTP3_PREFLIGHT_HOST=127.0.0.1 bash scripts/phantom-browser-preflight.sh
111
mv build/browser build/browser-ipv4
112
HTTP3_PREFLIGHT_HOST=::1 bash scripts/phantom-browser-preflight.sh
+113
if [ "${HTTP3_CONTINUOUS_PUNCH_BUILD:-0}" = 1 ]; then
+114
timeout --foreground 40 node scripts/check-continuous-punch.mjs
+115
fi
116
bash scripts/phantom-lifecycle-check.sh
117
git -C "$sdk_source" diff --exit-code > "$results/sdk-source-after.diff"
118
git diff --exit-code -- sigil.lock tools/interop/sigil.lock > "$results/product-locks-after.diff"
scripts/phantom-spike-sdk.shmodified
@@ -12,7 +12,8 @@ record_result() {
12
}
13
trap record_result EXIT
14
printf 'RESULT scope=spike-only-unpublished-sdk\n' | tee "$sdk_results/result.txt"
−15
git clone --quiet spike-sdk-source.bundle "$sdk_source"
+15
git clone --quiet --no-checkout "${HTTP3_SDK_SOURCE:?Set HTTP3_SDK_SOURCE}" "$sdk_source"
+16
git -C "$sdk_source" checkout --quiet --detach "$(cat spike-sdk.rev)"
17
test "$(git -C "$sdk_source" rev-parse HEAD)" = "$(cat spike-sdk.rev)"
18
git -C "$sdk_source" status --porcelain > "$sdk_results/source-status.txt"
19
test ! -s "$sdk_results/source-status.txt"
scripts/prepare-continuous-punch.mjsadded
@@ -0,0 +1,33 @@
+1
// Apply after the trace patch, exclusively to the isolated Linux job tree.
+2
import { createHash } from 'node:crypto';
+3
import { readFileSync, writeFileSync, copyFileSync } from 'node:fs';
+4
import { hostname } from 'node:os';
+5
const manifest = [];
+6
function replace(path, before, after) {
+7
const source = readFileSync(path, 'utf8');
+8
if (source.split(before).length !== 2) throw new Error('Punch patch anchor mismatch: ' + path);
+9
const output = source.replace(before, after);
+10
const hash = value => createHash('sha256').update(value).digest('hex');
+11
manifest.push({ path, before: hash(source), after: hash(output) });
+12
writeFileSync(path, output);
+13
}
+14
const endpoint = '.deps/sigil-quic/src/sigil/quic/endpoint.sgl';
+15
replace(endpoint, ' quic-endpoint-step!\n', ' quic-endpoint-step! quic-spike-punch-send!\n');
+16
replace(endpoint, ' (define (endpoint-now endpoint)', ` ;; Spike-only: send through the endpoint's sole existing listening socket.
+17
(define (quic-spike-punch-send! endpoint host port bytes)
+18
(unless (and (quic-endpoint? endpoint) (not (quic-endpoint-closed? endpoint))
+19
(eq? (quic-endpoint-family endpoint) 'ipv6)
+20
(memv port '(40000 40001 40002))
+21
(bytevector? bytes) (= (bytevector-length bytes) 8))
+22
(error "Invalid spike-only priming send"))
+23
(udp-send (quic-endpoint-socket endpoint) bytes host port))
+24
+25
(define (endpoint-now endpoint)`);
+26
const driver = 'tools/interop/src/sigil/http3/interop/preflight.sgl';
+27
replace(driver, ' (sigil http3 interop observations))',
+28
' (sigil http3 interop observations)\n (sigil http3 interop punch))');
+29
replace(driver, ' (quic-endpoint-step! endpoint wait-ms: 0)',
+30
' (quic-endpoint-step! endpoint wait-ms: 0)\n (spike-punch-step! endpoint)');
+31
copyFileSync('tools/trace/punch.sgl', 'tools/interop/src/sigil/http3/interop/punch.sgl');
+32
writeFileSync('build/spike-echo/punch-manifest.json', JSON.stringify({ scope: 'spike-only', manifest }, null, 2) + '\n');
+33
console.log('RESULT same-listening-socket-punch-patch=APPLIED max-seconds=180 interval-ms=1000');
tools/trace/punch.sgladded
@@ -0,0 +1,121 @@
+1
;;; Spike-only sender: the endpoint's existing socket remains the sole owner.
+2
;;; Imported only by the private Linux build patch, never by released code.
+3
(define-library (sigil http3 interop punch)
+4
(import (sigil io)
+5
(sigil fs)
+6
(sigil process)
+7
(sigil time)
+8
(sigil socket)
+9
(sigil quic endpoint)
+10
(sigil http3 interop observations))
+11
(export spike-punch-step!)
+12
(begin
+13
(define directory (getenv "HTTP3_PUNCH_DIRECTORY"))
+14
(define ports '(40000 40001 40002))
+15
(define attempted? #f)
+16
(define finished? #f)
+17
(define owner #f)
+18
(define target #f)
+19
(define nonce #f)
+20
(define seconds 0)
+21
(define started 0)
+22
(define deadline 0)
+23
(define next-send 0)
+24
(define count 0)
+25
+26
(define (timestamp)
+27
(let ((now (current-second)))
+28
(string-append (format-date now #t) "T" (format-time now #t) "Z")))
+29
+30
(define (write-receipt name reason)
+31
(let* ((path (string-append directory "/" name ".json"))
+32
(temporary (string-append path ".next")))
+33
(write-file-string temporary
+34
(string-append "{\"schema\":1,\"nonce\":" (interop-json-token nonce)
+35
",\"utc\":" (interop-json-token (timestamp))
+36
",\"reason\":" (interop-json-token reason)
+37
",\"sourceHost\":" (interop-json-token (quic-endpoint-host owner))
+38
",\"sourcePort\":" (number->string (quic-endpoint-port owner))
+39
",\"seconds\":" (number->string seconds)
+40
",\"packets\":" (number->string count)
+41
",\"elapsedMs\":"
+42
(number->string
+43
(quotient (* 1000 (- (current-jiffy) started)) (jiffies-per-second)))
+44
"}"))
+45
(rename-file temporary path)))
+46
+47
(define (finish! reason)
+48
(unless finished?
+49
(set! finished? #t)
+50
(println "HTTP3-PUNCH time=~a event=finished reason=~a packets=~a"
+51
(timestamp) reason count)
+52
(write-receipt "finished" reason)))
+53
+54
(define (admit! endpoint path)
+55
(unless (<= 1 (file-size path) 1024)
+56
(error "Punch command exceeds bound"))
+57
(let* ((command
+58
(call-with-input-file path
+59
(lambda (input)
+60
(let ((value (read input)))
+61
(unless (eof-object? (read input))
+62
(error "Punch expects one command"))
+63
value))))
+64
(canonical
+65
(and (list? command) (= (length command) 4)
+66
(equal? (car command) 1)
+67
(string? (caddr command))
+68
(socket-normalize-address (caddr command)))))
+69
(unless (and canonical
+70
(string? (cadr command)) (<= 1 (string-length (cadr command)) 64)
+71
(integer? (cadddr command)) (exact? (cadddr command))
+72
(<= 1 (cadddr command) 180)
+73
(eq? (quic-endpoint-family endpoint) 'ipv6)
+74
(or (and (equal? (getenv "HTTP3_PUNCH_TEST_LOOPBACK") "1")
+75
(equal? canonical "::1")
+76
(equal? (quic-endpoint-host endpoint) "::1"))
+77
(and (= (quic-endpoint-port endpoint) 43443)
+78
(> (string-length canonical) 1)
+79
(memv (string-ref canonical 0) '(#\2 #\3))
+80
(not (equal? canonical (quic-endpoint-host endpoint))))))
+81
(error "Invalid bounded same-socket punch command"))
+82
(set! attempted? #t)
+83
(set! owner endpoint)
+84
(set! target canonical)
+85
(set! nonce (cadr command))
+86
(set! seconds (cadddr command))
+87
(set! started (current-jiffy))
+88
(set! deadline (+ started (* seconds (jiffies-per-second))))
+89
(set! next-send started)
+90
(println "HTTP3-PUNCH time=~a event=started seconds=~a source-port=~a"
+91
(timestamp) seconds (quic-endpoint-port endpoint))
+92
(write-receipt "started" "same-listening-socket")))
+93
+94
(define (spike-punch-step! endpoint)
+95
(when directory
+96
(let ((command (string-append directory "/command.scm")))
+97
(when (and (not attempted?) (file-exists? command))
+98
(admit! endpoint command)))
+99
(when (and attempted? (not finished?))
+100
(cond
+101
((or (not (eq? endpoint owner)) (quic-endpoint-closed? owner))
+102
(finish! "listener-ended"))
+103
((file-exists? (string-append directory "/stop"))
+104
(finish! "controller-stop"))
+105
((or (>= (current-jiffy) deadline) (>= count (* 3 seconds)))
+106
(finish! "window-expired"))
+107
((>= (current-jiffy) next-send)
+108
;; Schedule from now: delayed steps never produce catch-up bursts.
+109
(set! next-send (+ (current-jiffy) (jiffies-per-second)))
+110
(for-each
+111
(lambda (port)
+112
(when (and (not finished?) (< (current-jiffy) deadline))
+113
(let* ((bytes #u8(83 71 80 50 0 0 0 0))
+114
(sent (quic-spike-punch-send! owner target port bytes)))
+115
(set! count (+ count 1))
+116
(println "HTTP3-PUNCH time=~a event=send sequence=~a port=~a bytes=8 result=~a"
+117
(timestamp) count port sent)
+118
(unless (and sent (= sent 8))
+119
(finish! "send-failed")))))
+120
ports)))
+121
(flush-output-port (current-output-port)))))))
web/phone.htmlmodified
@@ -3,6 +3,7 @@
3
<meta charset="utf-8">
4
<meta name="viewport" content="width=device-width, initial-scale=1">
5
<title>Sigil network switch test</title>
+6
<link rel="icon" href="data:,">
7
<style>
8
:root { color-scheme: light dark; font: 16px system-ui, sans-serif; }
9
body { max-width: 48rem; margin: auto; padding: 1rem; }
@@ -13,13 +14,17 @@
14
dl { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
15
dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
16
#state { font-weight: bold; }
+17
#network-banner { padding: 1rem; border: 3px solid currentColor; font-size: 1.25rem; font-weight: bold; }
+18
#network-banner[data-online="false"] { color: #c43c35; }
19
pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow: auto; font-size: .8rem; }
20
.hint { opacity: .8; }
21
canvas { display: block; width: 100%; height: 200px; border: 1px solid #888; border-radius: .4rem; }
22
.stream-key { color: #278fe8; } .datagram-key { color: #d88b21; }
23
</style>
24
<h1>Sigil network switch test</h1>
−22
<p>Keep this page visible. Connect on Wi-Fi, mark the switch, then turn Wi-Fi off. Keep the VPN connected for the baseline; disable it for the separate public run. Watch the echo gap and session count.</p>
+25
<p>For the public punch test, load this page fresh on cellular with Wi-Fi and VPN off. Confirm ONLINE and cellular below, start chrome://net-export, then follow the operator's control-first instructions. Keep the page visible.</p>
+26
<p id="network-banner" role="status" aria-live="polite">Checking browser network state…</p>
+27
<p class="hint">Connect is disabled while the browser reports offline. ONLINE is a browser hint, not proof that the target is reachable. Priming starts only on the control confirmation.</p>
28
<p class="hint">Reconnect is manual. A surviving browser session needs matching server path and connection-ID logs to establish migration. WireGuard may hide the physical network switch from QUIC.</p>
29
<form id="configuration">
30
<label>WebTransport URL <input id="url" type="url" placeholder="https://test-address:port/echo" required></label>
@@ -129,7 +134,10 @@
134
downlink: navigator.connection?.downlink ?? null, saveData: navigator.connection?.saveData ?? null,
135
visibility: document.visibilityState, source: change?.type ?? 'initial' };
136
element('network').textContent = JSON.stringify(hint);
+137
element('network-banner').textContent = `${hint.online ? 'ONLINE' : 'OFFLINE'} · connection: ${hint.type} · ${hint.effectiveType}`;
+138
element('network-banner').dataset.online = String(hint.online);
139
event('browser-network-hint', hint);
+140
controls();
141
}
142
function usable(run) { return active === run && !run.ended; }
143
function drawGraph(run) {
@@ -185,7 +193,7 @@
193
}
194
function controls() {
195
const busy = pendingConnect || (active && !active.ended);
−188
element('connect').disabled = !!busy;
+196
element('connect').disabled = !!busy || !navigator.onLine || !!queryError;
197
element('stop').disabled = !busy;
198
element('uni').disabled = !(active?.ready && !active.ended);
199
for (const id of ['url', 'hash', 'datagrams']) element(id).disabled = !!busy;
@@ -373,6 +381,9 @@
381
if (pendingConnect || (active && !active.ended)) return;
382
const started = performance.now();
383
try {
+384
network({ type: 'before-connect' });
+385
if (!navigator.onLine) throw new Error('Browser reports offline; wait for ONLINE before Connect');
+386
if (queryError) throw queryError;
387
if (!isSecureContext) throw new Error('Open this page over HTTPS or as a trusted local file');
388
if (!('WebTransport' in window)) throw new Error('This browser does not expose WebTransport');
389
const url = new URL(element('url').value);