code wiki / _hdl_build / nx_sni_router.nx

nx_sni_router.nx

buildroot/runtime/_hdl_build/nx_sni_router.nx

6026 B133 linesdepth 5pulls 9 transitivereach 1 importersview sourcekind tooltopic sni
docsdependenciesstructsconstsfunctions

about

nx_sni_router.nx -- sovereign TCP SNI-passthrough router = the :443 FRONT of the multi-tenant hosting platform. Accept -> peek the cleartext ClientHello -> sni_extract_hostname -> route the RAW TCP to the matching per- property backend -> splice bytes BOTH ways (replaying the peeked ClientHello first). Does NOT terminate TLS -- each backend daemon terminates its OWN (so mTLS lives only in the personal daemon; clients never see a prompt). Fork-per-connection (bounded); the duplex splice forks one direction + runs the other. No /bin/sh, no poll dep. argv[1] = listen port (default 9450); argv[2] = default backend port (default 8443 = today's sites.elf) license_tier: ORIGINAL

dependencies 5 imports · 1 importers

nx_syscalls.nx nx_connect.nx nx_http_server.nx nx_sni_extract.nx nx_property_registry.nx nx_sni_router.nx nx_sni_router_gate.nx

imports: nx_syscalls.nxnx_connect.nxnx_http_server.nxnx_sni_extract.nxnx_property_registry.nx

imported by: nx_sni_router_gate.nx

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

main sr_atoi sr_serve sys_mmap pr_load sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_http_server_addr_any nx_http_server_make_sockad nx_http_server_listen sys_ignore_sigpipe sys_mmap ↻ sys_socket sys_mmap ↻ sys_setsockopt sys_bind sys_close ↻ sys_listen sys_write sys_set_socket_timeout sys_mmap ↻ sys_setsockopt ↻ sys_munmap sys_wait4 sys_accept_with_addr sys_fork sys_close ↻ sr_handle sys_set_socket_timeout ↻ sys_mmap ↻ sys_read ↻ sni_extract_hostname sni_u16 sr_route pr_lookup

structs

none

consts

13const NX_MAGIC_65536: i64 = 65536
14const NX_MAGIC_100000000: i64 = 100000000
16const NX_SR_PORT_DEFAULT: i64 = 9450
17const NX_SR_BACKEND_DEFAULT: i64 = 8443
18const NX_SR_PEEK: i64 = 8192
19const NX_SR_RELAY: i64 = 16384
20const NX_SR_MAX_CHILDREN: i64 = 128
26const NX_SR_REGISTRY: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8

functions

22func sr_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v }
called by 1: main
30func sr_route(host: *u8, host_n: i64, cfg: *u8, cfg_n: i64, default_port: i64) -> i64
called by 2: sr_handlemain calls 1: pr_lookup
35func sr_connect(port: i64) -> i64
48func sr_pump(from: i64, to: i64) -> i64
called by 1: sr_relay calls 3: sys_mmapsys_readsys_write
62func sr_relay(client: i64, backend: i64) -> i64
74func sr_handle(cfd: i64, cfg: *u8, cfg_n: i64, bport: i64) -> i64
94func sr_serve(port: i64, bport: i64) -> i64
126func main(argc: i64, argv: *i64) -> i64
calls 2: sr_atoisr_serve