AtlatestRepositorysigil-http3
sigil-http3 / tree / scriptsprepare-continuous-punch.mjs
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))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');