code wiki / (root) / nx_pages_vhost.nx

nx_pages_vhost.nx

buildroot/runtime/nx_pages_vhost.nx

9079 B239 linesdepth 3pulls 3 transitivereach 6 importersview sourcekind librarytopic pages
docsdependenciesstructsconstsfunctions

about

nx_pages_vhost.nx -- multi-virtual-host routing primitive. D1.1 of the NISHI_DEPLOY_ROADMAP -- the first composition piece that lets one nx_pages_daemon serve multiple domains from one ELF. Replaces the equivalent of nginx's `server { server_name X; root Y; }` blocks. Design contract: - Caller pre-allocates an NxVHostTable with N vhosts. - Each NxVHost binds a domain name to a filesystem doc root. - nx_vhost_dispatch(req_buf, req, table, ...) reads the parsed request's Host header and returns the matched vhost's doc-root range. Case-insensitive match per RFC 7230 ยง5.4. - Wildcard fallback supported via a designated catch-all vhost (used for the default-server-block equivalent). Per [[NISHI_DEPLOY_ROADMAP]] D1.1. Composes nx_http.nx http_get_header. nx_safety_envelope: intended_use: "Multi-vhost HTTP routing for nx_pages_daemon" sil_target: SIL1 asil_target: QM evidence: [case_insensitive_per_RFC_7230_section_5.4, bounded_table_no_recursion, sealed_enum_verdict] hazard_register: [bug-vhost-injection-via-Host-header-CR-LF, bug-default-vhost-shadows-explicit-match] verdict: NOT_YET_EVALUATED

dependencies 3 imports · 6 importers

nx_syscalls.nx nx_tier.nx nx_http.nx nx_pages_vhost.nx nx_pages_config.nx nx_pages_config_test.nx nx_pages_daemon.nx nx_pages_https_daemon.nx nx_pages_vhost_debug.nx nx_pages_vhost_test.nx

imports: nx_syscalls.nxnx_tier.nxnx_http.nx

imported by: nx_pages_config.nxnx_pages_config_test.nxnx_pages_daemon.nxnx_pages_https_daemon.nxnx_pages_vhost_debug.nxnx_pages_vhost_test.nx

structs

54struct NxVHostTable

consts

33const NX_VHOST_OK: nx_int = 0 // matched explicit vhost
34const NX_VHOST_FALLBACK: nx_int = 1 // matched catch-all
35const NX_VHOST_NO_MATCH: nx_int = 2 // no vhost AND no fallback
36const NX_VHOST_NO_HOST_HDR: nx_int = 3 // request had no Host: header
37const NX_VHOST_BAD_ARG: nx_int = 4 // null table / negative count
45const NX_VHOST_STRIDE: i64 = 4
46const NX_VHOST_HNAME_OFF: i64 = 0
47const NX_VHOST_HNAME_LEN: i64 = 1
48const NX_VHOST_ROOT_OFF: i64 = 2
49const NX_VHOST_ROOT_LEN: i64 = 3

functions

65func _vh_lc(b: i64) -> i64
called by 1: _vh_eq_ci
72func _vh_eq_ci(a: *u8, a_off: i64, a_len: i64,
called by 1: nx_vhost_dispatch calls 1: _vh_lc
89func _vh_strip_port(buf: *u8, off: i64, len: i64) -> i64
called by 1: nx_vhost_dispatch
111func nx_vhost_table_init(t: *NxVHostTable, arena: *u8, arena_len: i64,
125func _vh_arena_push_cstr(t: *NxVHostTable, cursor: *i64, s: *u8) -> i64
called by 1: nx_vhost_add
142func nx_vhost_add(t: *NxVHostTable, cursor: *i64,
163func nx_vhost_set_fallback(t: *NxVHostTable, idx: i64) -> i64
176func nx_vhost_dispatch(req_buf: *u8, req: *HttpRequest,