code wiki / _hdl_build / nx_sni_router.nx
nx_sni_router.nx
buildroot/runtime/_hdl_build/nx_sni_router.nx
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
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
structs
| none |
consts
| 13 | const NX_MAGIC_65536: i64 = 65536 |
| 14 | const NX_MAGIC_100000000: i64 = 100000000 |
| 16 | const NX_SR_PORT_DEFAULT: i64 = 9450 |
| 17 | const NX_SR_BACKEND_DEFAULT: i64 = 8443 |
| 18 | const NX_SR_PEEK: i64 = 8192 |
| 19 | const NX_SR_RELAY: i64 = 16384 |
| 20 | const NX_SR_MAX_CHILDREN: i64 = 128 |
| 26 | const NX_SR_REGISTRY: *u8 = "/volume1/homes/elderwesto/nishihost/property_registry.conf" as *u8 |
functions
| 22 | func 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 |
| 30 | func sr_route(host: *u8, host_n: i64, cfg: *u8, cfg_n: i64, default_port: i64) -> i64 |
| 35 | func sr_connect(port: i64) -> i64 |
| 48 | func sr_pump(from: i64, to: i64) -> i64 |
| 62 | func sr_relay(client: i64, backend: i64) -> i64 |
| 74 | func sr_handle(cfd: i64, cfg: *u8, cfg_n: i64, bport: i64) -> i64 called by 1: sr_serve calls 9: sys_set_socket_timeoutsys_mmapsys_readsni_extract_hostnamesr_routesr_connect+3 |
| 94 | func sr_serve(port: i64, bport: i64) -> i64 called by 2: mainmain calls 12: sys_mmappr_loadnx_http_server_addr_anynx_http_server_listensys_writesys_set_socket_timeout+6 |
| 126 | func main(argc: i64, argv: *i64) -> i64 |