code wiki / _hdl_build / nx_aw_sni_router.nx
nx_aw_sni_router.nx
buildroot/runtime/_hdl_build/nx_aw_sni_router.nx
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
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
structs
| none |
consts
| 11 | const NX_MAGIC_1000000000: i64 = 1000000000 |
| 13 | const NX_RT_PORT: i64 = 7443 |
| 14 | const NX_RT_MAX: i64 = 64 |
| 15 | const NX_RT_BUF: i64 = 16384 |
| 37 | const NX_RT_REGISTRY: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8 |
| 38 | const NX_RT_REG_MAX: i64 = 64 |
functions
| 17 | func 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 } |
| 18 | func 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 } |
| 21 | func rt_connect(port: i64) -> i64 |
| 40 | func rt_field(buf: *u8, pos: i64, end: i64, out: *u8, cap: i64) -> i64 called by 1: rt_load_registry |
| 64 | func rt_next_line(buf: *u8, pos: i64, end: i64) -> i64 called by 1: rt_load_registry |
| 72 | func rt_label_match(host: *u8, hn: i64, dom: *u8, dom_n: i64) -> i64 called by 1: rt_lookup |
| 91 | func rt_load_registry(buf: *u8, n: i64, doms: *i64, dlens: *i64, ports: *i64, max: i64) -> i64 |
| 117 | func rt_lookup(host: *u8, hn: i64, doms: *i64, dlens: *i64, ports: *i64, count: i64) -> i64 |
| 129 | func rt_statsig(path: *u8, statb: *u8, out2: *i64) -> i64 |
| 137 | func main(argc: i64, argv: *i64) -> i64 |