code wiki / _hdl_build / nx_aw_sni_router.nx

nx_aw_sni_router.nx

buildroot/runtime/_hdl_build/nx_aw_sni_router.nx

12556 B268 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic aw
docsdependenciesstructsconstsfunctions

about

nx_aw_sni_router.nx -- SOVEREIGN SNI router for .240:443 (TLS PASSTHROUGH, no termination). Peeks the ClientHello's SNI, picks a backend by domain (apex nishifamily.com -> :8443 sovereign sites daemon; EVERYTHING else -> local Synology nginx :443 fallback), connects, REPLAYS the ClientHello, splices the raw TLS stream. Each backend completes its own TLS with the shared LE cert (SAN covers both domains), so the router never holds a key. Fork-per-connection, bounded + reaped; splice via a second fork (one process per direction) with socket timeouts so no connection can hang a slot. DNAT .240:443 -> NX_RT_PORT. argv[1] (optional) = listen port (default 7443). license_tier: ORIGINAL (spine from nx_aw_tlsproxy)

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_connect.nx nx_sni_route.nx nx_aw_sni_router.nx

imports: nx_syscalls.nxnx_connect.nxnx_sni_route.nx

imported by: nobody (leaf or entry point)

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

main rt_atoi sys_socket rt_puts sys_write sys_mmap sys_setsockopt sys_bind sys_listen sys_set_socket_timeout sys_mmap ↻ sys_setsockopt ↻ sys_munmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close rt_load_registry sys_mmap ↻ rt_field rt_next_line rt_atoi ↻ rt_statsig sys_fstatat sys_wait4 sys_accept_with_addr sys_fork sys_close ↻ sys_read ↻ sni_extract sni_be16 rt_lookup rt_label_match sni_backend sni_dom sni_eq rt_connect sys_socket ↻

structs

none

consts

11const NX_MAGIC_1000000000: i64 = 1000000000
13const NX_RT_PORT: i64 = 7443
14const NX_RT_MAX: i64 = 64
15const NX_RT_BUF: i64 = 16384
37const NX_RT_REGISTRY: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8
38const NX_RT_REG_MAX: i64 = 64

functions

17func rt_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 }
18func rt_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
21func rt_connect(port: i64) -> i64
40func rt_field(buf: *u8, pos: i64, end: i64, out: *u8, cap: i64) -> i64
called by 1: rt_load_registry
64func rt_next_line(buf: *u8, pos: i64, end: i64) -> i64
called by 1: rt_load_registry
72func rt_label_match(host: *u8, hn: i64, dom: *u8, dom_n: i64) -> i64
called by 1: rt_lookup
91func rt_load_registry(buf: *u8, n: i64, doms: *i64, dlens: *i64, ports: *i64, max: i64) -> i64
117func rt_lookup(host: *u8, hn: i64, doms: *i64, dlens: *i64, ports: *i64, count: i64) -> i64
called by 1: main calls 1: rt_label_match
129func rt_statsig(path: *u8, statb: *u8, out2: *i64) -> i64
called by 1: main calls 1: sys_fstatat
137func main(argc: i64, argv: *i64) -> i64