code wiki / _hdl_build / nx_host_router.nx
nx_host_router.nx
buildroot/runtime/_hdl_build/nx_host_router.nx
about
nx_host_router.nx -- S-class sovereign multi-site host router (pure Nishi, no TLS, no crypto).
Config-driven vhost table + PER-REQUEST file serving = HOT CONTENT LOADING: push a file, it is
live on the next request, NO recompile. Path-traversal-safe. This is L5 (content) of the sovereign
hosting design (knowledge/research/2026-06-05-sovereign-web-hosting.md). Composed into the TLS
daemon, which supplies L3/L4. license_tier: ORIGINAL
dependencies 1 imports · 6 importers
imports: nx_syscalls.nx
imported by: nx_host_router2_test.nxnx_host_router_gate.nxnx_host_router_test.nxnx_hr_serve3_slot_gate.nxnx_sites_daemon.nxnx_sites_daemon_v2.nx
structs
| none |
consts
| 7 | const HR_MAGIC_1024: i64 = 1024 |
| 8 | const HR_MAGIC_4096: i64 = 4096 |
| 9 | const HR_MAGIC_5120: i64 = 5120 |
| 10 | const HR_MAGIC_2048: i64 = 2048 |
| 11 | const HR_MAGIC_4095: i64 = 4095 |
| 319 | const HR_ASSET_MAXAGE: i64 = 3600 |
| 375 | const HR_S2_MISS: i64 = 0 // host known but file absent -> caller falls through to legacy routing |
| 376 | const HR_S2_OK: i64 = 1 // 200 written |
| 377 | const HR_S2_BAD: i64 = 2 // 400 written (traversal/malformed) |
| 378 | const HR_S2_TOOBIG: i64 = 3 // 500 written (file exceeds outcap) |
| 433 | const HR_S2_REDIR: i64 = 4 // 301 written to out (out_n set); caller must NOT fall through |
| 434 | const HR_S2_STREAM: i64 = 5 // headers written to out; BODY handed via hr_stream_body/bodyn -- the |
| 608 | const HR_SLOT_MARK: *u8 = "<!--nx-ad-slot-->" as *u8 |
functions
| 13 | func hr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 15 | func hr_copy(dst: *u8, src: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { dst[i] = src[i]; i = i + 1 } return n } called by 1: hr_lookup_root |
| 17 | func hr_eq(a: *u8, b: *u8, n: i64) -> i64 |
| 23 | func hr_lower(c: u8) -> u8 |
| 28 | func hr_ieq(a: *u8, b: *u8, n: i64) -> i64 |
| 35 | func hr_putdec(out: *u8, v: i64) -> i64 |
| 53 | func hr_req_path(req: *u8, reqn: i64, out: *u8, cap: i64) -> i64 |
| 72 | func hr_req_query(req: *u8, reqn: i64, out: *u8, cap: i64) -> i64 |
| 98 | func hr_req_host(req: *u8, reqn: i64, out: *u8, cap: i64) -> i64 |
| 124 | func hr_lookup_root(cfg: *u8, cfgn: i64, host: *u8, hostn: i64, out: *u8, cap: i64) -> i64 |
| 158 | func hr_path_safe(path: *u8, pathn: i64) -> i64 |
| 171 | func hr_resolve(root: *u8, rootn: i64, path: *u8, pathn: i64, out: *u8, cap: i64) -> i64 |
| 207 | func hr_ctype(file: *u8, filen: i64) -> *u8 |
| 246 | func hr_emit(out: *u8, statusline: *u8, ctype: *u8, body: *u8, bodyn: i64) -> i64 |
| 265 | func hr_known_host(cfg: *u8, cfgn: i64, req: *u8, reqn: i64) -> i64 |
| 276 | func hr_serve(cfg: *u8, cfgn: i64, req: *u8, reqn: i64, out: *u8, outcap: i64) -> i64 |
| 321 | func hr_emit_b(out: *u8, outcap: i64, statusline: *u8, ctype: *u8, body: *u8, bodyn: i64) -> i64 called by 6: hr_serve3_slothr_serve3sd2_circle_uploadsd2_circle_listsd2_circle_playmain calls 1: hr_putdec |
| 385 | func hr_serve2(cfg: *u8, cfgn: i64, req: *u8, reqn: i64, out: *u8, outcap: i64, out_n: *i64) -> i64 |
| 418 | func hr_emit_404(out: *u8, outcap: i64) -> i64 |
| 443 | func hr_stream_body() -> i64 { return hr_stream_p } |
| 444 | func hr_stream_bodyn() -> i64 { return hr_stream_n } |
| 448 | func hr_emit_head(out: *u8, outcap: i64, statusline: *u8, ctype: *u8, bodyn: i64) -> i64 |
| 479 | func hr_ends2(s: *u8, n: i64, suf: *u8, sufn: i64) -> i64 |
| 488 | func hr_canon(path: *u8, pn: i64, loc: *u8) -> i64 |
| 508 | func hr_join(root: *u8, rn: i64, path: *u8, pn: i64, suffix: *u8, file: *u8, cap: i64) -> i64 |
| 525 | func hr_resolve_read(root: *u8, rn: i64, path: *u8, pn: i64, file: *u8, cap: i64, fnlen: *i64, dn: *i64) -> *u8 |
| 551 | func hr_emit_redirect(out: *u8, outcap: i64, loc: *u8, locn: i64) -> i64 |
| 568 | func hr_ct_is_html(ct: *u8) -> i64 |
| 573 | func hr_find_close_body(body: *u8, bn: i64) -> i64 |
| 586 | func hr_has_optout(body: *u8, bn: i64) -> i64 |
| 610 | func hr_find_slot_anchor(d: *u8, n: i64) -> i64 |
| 622 | func hr_serve3_slot(cfg: *u8, cfgn: i64, req: *u8, reqn: i64, out: *u8, outcap: i64, out_n: *i64, slot: *u8, slot_n: i64, injected: *i64) -> i64 |
| 711 | func hr_serve3(cfg: *u8, cfgn: i64, req: *u8, reqn: i64, out: *u8, outcap: i64, out_n: *i64) -> i64 |