code wiki / (root) / nx_stun_client.nx

nx_stun_client.nx

buildroot/runtime/nx_stun_client.nx

6074 B133 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind tooltopic stun
docsdependenciesstructsconstsfunctions

about

nx_stun_client.nx -- SOVEREIGN STUN client (server-reflexive address discovery), NishiLang, composing nx_stun. The gather side of ICE: send a Binding Request to a STUN server, read the Binding Response, and extract the XOR-MAPPED-ADDRESS -- your PUBLIC reflexive IP:port as the server saw it. Works against ANY standard STUN server (ours OR a third-party one), proving byte-level interop, with ZERO third-party code. sc_query(...) is the reusable primitive (real UDP socket round-trip, bounded by a timeout so it never hangs). main() is a CLI that prints the reflexive address as JSON -- registered as the MCP tool `nx_stun_probe` so an agent/operator can discover a public address over the wire. license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_5389

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_stun.nx nx_stun_client.nx nx_stun_client_gate.nx

imports: nx_syscalls.nxnx_stun.nx

imported by: nx_stun_client_gate.nx

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

main cp sys_write sys_exit sys_mmap cp_parse_ip cp_atoi sc_query sys_mmap ↻ sc_sockaddr sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_now_realtime_ms sys_mmap ↻ sys_clock_gettime_real st_write_header st_put16 st_put32 sys_sendto sys_recvfrom sys_close st_type st_get16 sc_find_xma st_len st_get16 ↻ st_get16 ↻ st_xma_addr st_get32 st_xma_port st_get16 ↻ cpn sys_mmap ↻ sys_write ↻

structs

none

consts

12const K_MAGIC_2048: i64 = 2048

functions

16func sc_find_xma(resp: *u8, n: i64) -> i64
called by 2: sc_querymain calls 2: st_lenst_get16
31func sc_sockaddr(sa: *u8, i0: i64, i1: i64, i2: i64, i3: i64, port: i64) -> i64
called by 1: sc_query
41func sc_query(i0: i64, i1: i64, i2: i64, i3: i64, port: i64, out_ip: *i64, out_port: *i64) -> i64
69func cp(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
70func cpn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
76func cp_parse_ip(s: *u8, oct: *i64) -> i64
called by 2: mainmain
104func cp_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 & 0xff; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v }
called by 1: main
106func main(argc: i64, argv: *i64) -> i64