nx_stun_server.nx
buildroot/runtime/nx_stun_server.nx
about
nx_stun_server.nx -- SOVEREIGN STUN server (reflexive-address responder), NishiLang, composing nx_stun.
Rung 3 of the Nishi P2P interop stack (rung1 STUN codec, rung2 ICE). A Nishi endpoint behind a NAT sends
a STUN Binding Request to this server; the server replies with a Binding Response whose XOR-MAPPED-ADDRESS
is the sender's PUBLIC reflexive IP:port exactly as the server observed it on the wire. That is how an
endpoint learns its server-reflexive (srflx) candidate -- the address a peer must use to reach it through
the NAT -- WITHOUT any third-party STUN server (no stun.l.google.com). Every byte is ours.
ss_handle is PURE (given a datagram + its source sockaddr -> a response), so it is gate-testable without
sockets; main() is the UDP daemon that binds and services requests forever. No third-party code.
license_tier: INDEPENDENT_REDERIVE genealogy_id: international-research-sources/ietf/rfc_5389
dependencies 2 imports · 1 importers
imports: nx_syscalls.nxnx_stun.nx
imported by: nx_stun_server_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 14 | const SS_MAGIC_3478: i64 = 3478 |
| 15 | const SS_MAGIC_2048: i64 = 2048 |
| 17 | const SS_PORT: i64 = 3478 // the IANA-assigned STUN port |
functions
| 20 | func ss_src_port(sa: *u8) -> i64 { return ((((sa[2] as i64)&0xff)<<8) | ((sa[3] as i64)&0xff)) } called by 1: ss_handle |
| 21 | func ss_src_addr(sa: *u8) -> i64 called by 1: ss_handle |
| 26 | func ss_build_response(buf: *u8, txid: *u8, port: i64, addr: i64) -> i64 |
| 41 | func ss_handle(req: *u8, reqlen: i64, src: *u8, out: *u8) -> i64 |
| 49 | func ssp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 50 | func ss_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64 |
| 58 | func main() -> i64 |