ident
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
- 5fdbb6b2ident mission 009: report — scratch folder notemre
- 74235815ident mission 009 (4/4): docs (README files map + same-output test, STATUS, LOG), report, tests/letcount.py + realdata-baseline/comparemre
- fe183516ident mission 009 (3/4): let only where reassigned — 293 never-reassigned lets are plain declarations; kept: reassigned, loop bodies, names of a file member, a name declared twice in one function; same outputmre
- d2e7f91bident mission 009 (2/4): one lib file per topic (login, accounts, identities, apps, invites, selector, notify + helpers, util), function routes as thin wrappers in lib/api.hl, project.hl = the map; same outputmre
- 91017164ident mission 009 (1/4): file moves — the root .hl files into lib/ (api.hl → lib/api-helpers.hl), styles.hl → components/styles.hl; imports adjusted, no other changemre
- f8bdcbc2ident: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); all gates greenmre
- ff78726cident: Hybriel master 190aa11d (fc838894 GC correctness, #127, #126 closure scopes); gates all greenmre
- a3a7d21aident: Hybriel master 8efba065 (#126 GC by bytes, #48 lambda params copy); session-writing lambdas take &sessionmre
- 98226b41antcolony#40: mission references point to the moved missionsmre
- ff805b9aantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
- 51a7bcdfident: Hybriel master 73267707 (#122); /code uses the new page() signature; pending address passed as parameter; once-checksmre
- 836f644fident#24: installable app (manifest, service worker, data-free offline /start), own iconmre
- 8bebbbf2deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
- cc063ea2deploy.sh: never send .git or .gitignore to Byrodinmre
- 81b15b7bState of 2026-09-27, before the move to gitoriamre