code wiki / (root) / nx_peer_connect_live.nx

nx_peer_connect_live.nx

buildroot/runtime/nx_peer_connect_live.nx

8061 B145 linesdepth 5pulls 9 transitivereach 8 importersview sourcekind tooltopic peer
docsdependenciesstructsconstsfunctions

about

nx_peer_connect_live.nx -- LIVE BEP-3 handshake with a REAL peer (X-TORRENT-LIVE-001 L3a): announce -> real peers -> TCP connect + handshake each, validate info_hash. BOUNDED CONNECT (no- hang law): blocking connect() to an unreachable peer hangs ~127s, so each attempt runs in a FORK and the PARENT bounds it (WNOHANG poll loop + nx_kill on timeout) -- reliable, no fcntl needed. Composes nx_dns_a + nx_udp_tracker (announce) + nx_peerwire (handshake). Test = Big Buck Bunny. GATE = LIVE: any real peer completes the BEP-3 handshake (info_hash matches). license_tier: ORIGINAL module: nishi-core.torrent.peer_connect_live depends: nishi-core.torrent.dns_a, nishi-core.torrent.udp_tracker, nishi-core.torrent.peerwire

dependencies 4 imports · 1 importers

nx_dns_a.nx nx_connect.nx nx_udp_tracker.nx nx_peerwire.nx nx_peer_connect_live.nx nx_peer_meta_live.nx

imports: nx_dns_a.nxnx_connect.nxnx_udp_tracker.nxnx_peerwire.nx

imported by: nx_peer_meta_live.nx

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

main cl_announce 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 sys_socket ↻ sys_set_socket_timeout ↻ cl_sockaddr nx_udp_build_connect _ut_put_u64 _ut_put_u32 sys_sendto ↻ sys_recvfrom ↻ nx_udp_parse_connect_resp _ut_get_u32 _ut_get_u64 nx_udp_build_announce _ut_put_u64 ↻ _ut_put_u32 ↻ _ut_put_u16 nx_udp_parse_announce_resp _ut_get_u32 ↻ cl_w cl_wn sys_openat_wr cl_write_n sys_fork

structs

none

consts

14const K_MAGIC_305419896: i64 = 305419896
15const K_MAGIC_1000000000: i64 = 1000000000
16const K_MAGIC_6881: i64 = 6881
17const K_MAGIC_2048: i64 = 2048
18const K_MAGIC_6000: i64 = 6000

functions

20func cl_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 2: mainmain
21func cl_wn(fd: i64, v: i64) -> i64
called by 2: mainmain
26func cl_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64
33func cl_read_n(fd: i64, buf: *u8, n: i64) -> i64
38func cl_write_n(fd: i64, buf: *u8, n: i64) -> i64
45func cl_announce(ih: *u8, pid: *u8, ips: *i64, ports: *i64, max: i64) -> i64
67func cl_child(ipv: i64, port: i64, ih: *u8, mypid: *u8, respath: *u8) -> i64
93func main() -> i64