code wiki / _hdl_build / _h2_multistream_curl_daemon.nx

_h2_multistream_curl_daemon.nx

buildroot/runtime/_hdl_build/_h2_multistream_curl_daemon.nx

13835 B278 linesdepth 15pulls 84 transitivereach 0 importersview sourcekind servicetopic h2
docsdependenciesstructsconstsfunctions

about

_h2_multistream_curl_daemon.nx -- TUTOR-BOOTSTRAP SCAFFOLD (Claude, authored under the B1 rung(6) PERSISTENT-MULTI-STREAM external-curl interop step of the R4-H2 HTTP/2-transport ladder), NOT credited as team self-authoring (back-fill via the emitter-of-emitters once the daemon-from-spec organ exists). THE PERSISTENT MULTI-STREAM ALPN-h2 SERVE DAEMON: stands up OUR sovereign ALPN-h2 TLS 1.3 server on 127.0.0.1:9444 and serves an EXTERNAL, INDEPENDENT h2 client (curl --http2 with libnghttp2/OpenSSL) that issues MULTIPLE same-origin GETs. Unlike _h2_serve_curl_daemon.nx (which ACCEPTS HCD_N=3 SEPARATE connections because its single-stream driver GOAWAYs after each request), this daemon ACCEPTS EXACTLY ONE connection and serves up to MCD_MAX request streams on it via the persistent driver h2_serve_connection_multi (runtime/ nx_h2_serve_multi.nx). An external curl given K same-origin URLs therefore REUSES that ONE TCP connection (total num_connects across the K transfers = 1). MEASURED EXCEED + DISCRIMINATION (the gate): POS (this daemon, persistent): curl url1 url2 ... urlK on 127.0.0.1:9444 -> all K transfers HTTP/2 200, TOTAL num_connects = 1 (the connection is REUSED across streams 1,3,5,...,2K-1). NEG control (_h2_serve_curl_daemon, single-stream, port 9443): the SAME K URLs -> each transfer opens a FRESH connection (total num_connects = K), because the single-stream driver GOAWAYs + closes after each request. The num_connects measurement DISCRIMINATES persistent multi-stream from connection-per-request -- it is not a tautology. FLOW (main): - mint a self-signed Ed25519 X.509 leaf (SAN=localhost) -- the SAME sovereign cert path the proven daemon uses (mcd_make_cert). - EXPORT that DER cert to a PEM file (/tmp/nx_h2_ms_cert.pem) so an external curl can trust it via --cacert (composes nx_base64 b64_encode). - socket / SO_REUSEADDR / bind 127.0.0.1:9444 / listen; print "BOUND 127.0.0.1:9444" so the orchestrator's readiness gate fires. - ONE accept -> fresh handshake entropy -> h2_serve_connection_multi (MCD_MAX cap) -> close -> exit 0; the driver returns the COUNT of streams served (>=1), else an honest negative -> stop-on-RED, no fake-green. HONEST verdict discipline: this organ's job is to BIND + SERVE >1 external h2 request STREAM on ONE connection. GREEN (server side) iff the handshake completed and >=2 request streams were parsed + answered :status 200 on the SAME connection. The EXTERNAL curl judgement ("using HTTP/2" + "Re-using existing

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_h2_serve_multi.nx nx_x25519_ephemeral.nx nx_csprng.nx nx_ed25519_signature.nx nx_x509_build.nx nx_x509.nx nx_x509_trust_store.nx nx_base64.nx _h2_multistream_curl_daemon.nx

imports: nx_syscalls.nxnx_h2_serve_multi.nxnx_x25519_ephemeral.nxnx_csprng.nxnx_ed25519_signature.nxnx_x509_build.nxnx_x509.nxnx_x509_trust_store.nxnx_base64.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_write sys_mmap mcd_make_cert nx_csprng_fill sys_mmap ↻ nx_csprng_urandom_path sys_openat_rd sys_read sys_close sys_mmap ↻ ed25519_pub_from_priv sys_mmap ↻ ed25519_sha512 sys_mmap ↻ sha512_init sha512_update sha512_blk_set_byte blk_get_i64 blk_set_i64 sha512_compress sys_mmap ↻ blk_get_i64 ↻ sha512_gamma0 sha512_gamma1 sha512_sigma1 sha512_ch sha512_k sha512_sigma0 sha512_maj sha512_final sha512_blk_set_byte ↻ sha512_compress ↻ ge_p3_alloc sys_mmap ↻ fe_alloc nx_scratch nx_scratch_init nx_scratch_oom sys_mmap ↻

structs

none

consts

72const MCD_MAX: i64 = 16
76const MCD_PORT_REAL: i64 = 9444

functions

80func mcd_civil_from_days(days: i64, out_y: *i64, out_m: *i64, out_d: *i64) -> i64
96func mcd_format_generalized_time(unix_sec: i64, out_15: *u8) -> i64
126func mcd_addr(out: *u8, port: i64) -> i64
called by 1: main
137func mcd_make_cert(out_cert_der: *u8, out_cert_len: *i64, out_priv: *u8) -> i64
162func mcd_write_pem(cert_der: *u8, der_len: i64, path_z: *u8) -> i64
186func mcd_log(verdict_green: i64, served_or_code: i64) -> i64
209func main() -> i64