calendar
All repositories: gitoria
3.4 KB
// tls-on-plain-port.mjs — a TLS ClientHello sent to a plain hl:http1 port must be// closed at once, not held open until the client times out (routger, 2026-09-27:// Firefox's HTTPS-First tries https:// first on any non-localhost name, so the// page "loaded forever" instead of falling back to http). Drives the built// libhttp1.so through the interpreter (tls_on_plain_port.hl), then talks to it// with raw sockets — this is protocol-shape testing, below what an .hl fixture// can reach.import { spawn } from 'node:child_process';import { connect } from 'node:net';import { fileURLToPath } from 'node:url';import { dirname, resolve } from 'node:path';const HERE = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(HERE, '../../..');const BIN = resolve(ROOT, 'native/zig-out/bin/hybriel');const FIXTURE = resolve(HERE, 'tls_on_plain_port.hl');const PORT = Number(process.env.HL_TEST_PORT || 14980);const sleep = (ms) => new Promise((r) => setTimeout(r, ms));let failed = false;const fail = (msg) => { console.log('FAIL ' + msg); failed = true; };const server = spawn(BIN, [FIXTURE], {env: { ...process.env, HL_TEST_PORT: String(PORT) },stdio: ['ignore', 'pipe', 'pipe'],});let log = '';server.stdout.on('data', (d) => { log += d; });server.stderr.on('data', (d) => { log += d; });let up = false;for (let i = 0; i < 80; i++) {try {const r = await fetch(`http://127.0.0.1:${PORT}/`);if (r.status === 200) { up = true; break; }} catch {}await sleep(250);}if (!up) {console.log('FAIL server did not come up\n' + log.slice(0, 4000));server.kill('SIGKILL');process.exit(1);}// A TLS 1.2-shaped ClientHello record header: content type 0x16 (handshake),// version 0x03 0x03, followed by a plausible length and a few handshake bytes.// The fix only looks at the first two bytes, but this is what a real client// sends, so the fixture proves it against a realistic prefix.const clientHello = Buffer.from([0x16, 0x03, 0x03, 0x00, 0x2f, // TLS record: handshake, TLS 1.2, length 0x2f0x01, 0x00, 0x00, 0x2b, // handshake: ClientHello, length 0x2b0x03, 0x03, // client_version 1.2...Array(32).fill(0x42), // "random"]);const closedInTime = await new Promise((resolvePromise) => {const sock = connect(PORT, '127.0.0.1');const start = Date.now();let settled = false;sock.on('connect', () => sock.write(clientHello));sock.on('close', () => {if (settled) return;settled = true;resolvePromise(Date.now() - start);});sock.on('error', () => {}); // ECONNRESET counts as closedsetTimeout(() => {if (settled) return;settled = true;sock.destroy();resolvePromise(-1); // never closed within the budget}, 1000);});if (closedInTime < 0) {fail(`TLS ClientHello prefix was NOT closed within 1000ms`);} else {console.log(`ClientHello prefix closed in ${closedInTime}ms`);}// Plain HTTP on the same port must still answer — the fix must not have// turned the port TLS-only or broken ordinary requests.try {const r = await fetch(`http://127.0.0.1:${PORT}/`);const body = await r.text();if (r.status === 200 && body === 'ok') {console.log('plain HTTP still answers: 200 ok');} else {fail(`plain HTTP answered ${r.status} ${JSON.stringify(body)}`);}} catch (e) {fail(`plain HTTP request threw: ${e}`);}server.kill('SIGTERM');await sleep(300);if (!server.killed) server.kill('SIGKILL');console.log(failed ? 'FAIL' : 'PASS');process.exit(failed ? 1 : 0);
Branches
- mainmain branch
Latest commits
- c6fbd011calendar mission 001 (1/4): code order — files moved: lib/events.hl, lib/users.hl, components/styles.hl (imports only); gates 78/0 + 18/0, live-data run identicalmre
- d6c59290calendar: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 78/0 + 18/0mre
- 7bd0337ccalendar: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gates 78/0 + 18/0mre
- ff41310ccalendar: Hybriel master 8efba065 (#126 memory, #48 lambda copy; audit: no & needed)mre
- 14ba08c7antcolony#40: mission references point to the moved missionsmre
- 99c73346antcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- 76edaa62calendar: Hybriel master ff51cf46 (re-vendor round, static workaround removed)mre
- 90a3fc2cdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- 6722b72ddeploy.sh: never send .git or .gitignore to Byrodinmre
- be099807State of 2026-09-27, before the move to gitoriamre