code wiki / (root) / nx_netscope_dns.nx

nx_netscope_dns.nx

buildroot/runtime/nx_netscope_dns.nx

19608 B436 linesdepth 2pulls 3 transitivereach 8 importersview sourcekind librarytopic netscope
docsdependenciesstructsconstsfunctions

about

nx_netscope_dns.nx -- NX-NETSCOPE L0 (timeout-recv keystone) + L1 (DNS multi-path parallel prober). The headline EXCEED + the <5s one-shot diagnosis of the dual-homed split-horizon DNS race that makes nishifamily.com / andelinwest.com resolve slowly (or NXDOMAIN) from the LAN. See docs/NX_NETSCOPE_CHARTER.md sections 2/3/8. REUSES (never reinvents -- standing rule): nx_dns_build_query, nx_dns_parse_response_a, nx_dns_get_u16_be and the DNS flag/RCODE constants from nx_dns.nx; the socket+sockaddr flow from nx_dns_resolve_a_record.nx; the SO_RCVTIMEO timeval pattern from nx_iot_set_rcvtimeo_ms (ported here to avoid dragging the announce module's deps). EXCEED vs dig/nslookup: those query ONE resolver (or the OS resolver, which is the very thing that's broken). This fires a (server x host) MATRIX, each cell SO_RCVTIMEO-bounded (never hangs), dissects the RCODE (NXDOMAIN/SERVFAIL/REFUSED vs A), and flags the two failure modes the OS hides: the WOULD-POISON race (one resolver answers NXDOMAIN while another has the A -> Windows smart-multi-homed accepts the wrong one) and the PUBLIC-vs-RFC1918 hairpin (an owned domain resolving to its public IP instead of the internal 192.168.8.240). license_tier: ORIGINAL genealogy_id: nishi_nx_netscope_l0_l1

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_dns.nx nx_netscope_dns.nx nx_netscope_dns_test.nx nx_netscope_verdict.nx

imports: nx_syscalls.nxnx_dns.nx

imported by: nx_netscope_dns_test.nxnx_netscope_verdict.nx

structs

59struct ProbeCell

consts

28const NXNS_MAGIC_2048: i64 = 2048
32const NXNS_SO_RCVTIMEO: i64 = 20 // Linux SO_RCVTIMEO optname
33const NXNS_DNS_PORT: i64 = 53
34const NXNS_EAGAIN: i64 = 0 - 11 // -EAGAIN/-EWOULDBLOCK = recv timed out
37const NXNS_OK_A: i64 = 0 // got an A record (rcode 0, ancount>0)
38const NXNS_NOERROR_NO_A: i64 = 1 // rcode 0 but no A (ancount 0 / only other types)
39const NXNS_NXDOMAIN: i64 = 2 // rcode 3
40const NXNS_SERVFAIL: i64 = 3 // rcode 2
41const NXNS_REFUSED: i64 = 4 // rcode 5
42const NXNS_RCODE_OTHER: i64 = 5 // rcode 1/4/6+...
43const NXNS_TIMEOUT: i64 = 6 // SO_RCVTIMEO fired -- THE no-hang guarantee
44const NXNS_NOT_RESPONSE: i64 = 7 // QR=0
45const NXNS_TRUNCATED: i64 = 8 // TC=1
46const NXNS_TXID_MISMATCH: i64 = 9 // possible spoof / stale packet
47const NXNS_SOCKET_FAIL: i64 = 10
48const NXNS_SEND_FAIL: i64 = 11
49const NXNS_BAD_HEADER: i64 = 12
50const NXNS_PENDING: i64 = 99 // L1.1 parallel: cell awaiting poll() response
51const NXNS_POLLIN: i64 = 1 // poll() events/revents bit for "readable"
54const NXNS_RCODE_SERVFAIL: i64 = 2
55const NXNS_RCODE_NXDOMAIN: i64 = 3
56const NXNS_RCODE_REFUSED: i64 = 5
70const NXNS_PROBECELL_BYTES: i64 = 64

functions

77func nxns_set_rcvtimeo_ms(fd: i64, ms: i64) -> i64
97func nx_dns_recv_timed(fd: i64, buf: *u8, cap: i64, timeout_ms: i64,
106func nxns_is_rfc1918(ipv4: i64) -> i64
123func nxns_dissect_response(resp: *u8, got: i64, tx_id: i64, cell: *ProbeCell) -> i64
159func nx_dns_probe_one(server_ip: i64, host: *u8, host_len: i64,
221func nx_dns_probe_matrix(servers: *i64, n_servers: i64,
257func nxns_pollfd_set_fd(buf: *u8, i: i64, fd: i64) -> i64
265func nxns_pollfd_get_fd(buf: *u8, i: i64) -> i64
272func nxns_pollfd_set_events(buf: *u8, i: i64, ev: i64) -> i64
278func nxns_pollfd_get_revents(buf: *u8, i: i64) -> i64
289func nx_dns_probe_matrix_parallel(servers: *i64, n_servers: i64,
400func nx_dns_host_would_poison(cells: *ProbeCell, n_servers: i64, n_hosts: i64,
425func nx_dns_host_hairpin_risk(cells: *ProbeCell, n_servers: i64, n_hosts: i64,