code wiki / (root) / nx_dns_a.nx

nx_dns_a.nx

buildroot/runtime/nx_dns_a.nx

5763 B126 linesdepth 3pulls 3 transitivereach 15 importersview sourcekind tooltopic dns
docsdependenciesstructsconstsfunctions

about

nx_dns_a.nx -- minimal DNS A-record resolver on the nx_syscalls layer (X-TORRENT-LIVE-001 L1): resolve a tracker hostname -> IPv4 so we can reach a LIVE tracker. The existing nx_dns_resolve_a_record rides nx_syscalls_x86_64 (layer conflict with the torrent organs), so this is a self-contained UDP A-query to a public resolver (8.8.8.8:53): build the query, send/recv over the proven sovereign UDP plumbing, parse the first A answer (handles name-compression pointers). GATE = LIVE (needs internet, like the H2 arc): resolve a real host -> a valid public IPv4. Reusable fn nx_dns_a_resolve(host, out_ip4). license_tier: ORIGINAL module: nishi-core.torrent.dns_a depends: nishi-core.sys.syscalls

dependencies 2 imports · 6 importers

nx_syscalls.nx nx_itoa_lib.nx nx_dns_a.nx nx_dht_announce.nx nx_dht_get_peers.nx nx_dht_ping.nx nx_http_tracker.nx nx_peer_connect_live.nx nx_tracker_live.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nx_dht_announce.nxnx_dht_get_peers.nxnx_dht_ping.nxnx_http_tracker.nxnx_peer_connect_live.nxnx_tracker_live.nx

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

main sys_mmap nx_dns_a_resolve sys_socket sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_mmap ↻ da_sockaddr da_build_query da_qname sys_sendto sys_close sys_recvfrom da_parse da_u16 da_skip_name da_w sys_write da_wn nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap ↻ sys_exit

structs

none

consts

13const K_MAGIC_4660: i64 = 4660
14const K_MAGIC_2048: i64 = 2048

functions

16func da_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
21func da_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
22func da_u16(buf: *u8, o: i64) -> i64 { return ((buf[o] as i64) << 8) | (buf[o+1] as i64) }
called by 1: da_parse
25func da_qname(host: *u8, out: *u8, off: i64) -> i64
called by 1: da_build_query
42func da_build_query(host: *u8, qid: i64, out: *u8) -> i64
called by 1: nx_dns_a_resolve calls 1: da_qname
56func da_skip_name(buf: *u8, off: i64, n: i64) -> i64
called by 1: da_parse
68func da_parse(buf: *u8, n: i64, out_ip: *u8) -> i64
called by 1: nx_dns_a_resolve calls 2: da_u16da_skip_name
91func da_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64
called by 1: nx_dns_a_resolve
100func nx_dns_a_resolve(host: *u8, out_ip: *u8) -> i64
113func main() -> i64