code wiki / (root) / nx_peer_meta_live.nx

nx_peer_meta_live.nx

buildroot/runtime/nx_peer_meta_live.nx

10439 B177 linesdepth 6pulls 12 transitivereach 7 importersview sourcekind tooltopic peer
docsdependenciesstructsconstsfunctions

about

nx_peer_meta_live.nx -- fetch the REAL torrent metadata from a REAL peer (X-TORRENT-LIVE-001 L3b): connect a real peer -> BEP-3 handshake -> BEP-10 ext handshake -> BEP-9 ut_metadata fetch (multi- piece) -> sha1(info-dict)==info_hash -> parse name/piece_length/length. Uses a DISPATCH LOOP (real peers interleave bitfield/have/choke -- not lockstep). Bounded connect via fork+parent-kill (L3a). Reuses cl_announce/cl_read_n/cl_write_n/cl_sockaddr (nx_peer_connect_live) + nx_bencode + nx_sha1. GATE = LIVE: any real peer yields a sha1-verified info-dict for Big Buck Bunny. license_tier: ORIGINAL module: nishi-core.torrent.peer_meta_live depends: nishi-core.torrent.peer_connect_live, nishi-core.torrent.bencode, nishi-core.crypto.sha1

dependencies 4 imports · 1 importers

nx_peer_connect_live.nx nx_connect.nx nx_bencode.nx nx_sha1.nx nx_peer_meta_live.nx nx_peer_piece_live.nx

imports: nx_peer_connect_live.nxnx_connect.nxnx_bencode.nxnx_sha1.nx

imported by: nx_peer_piece_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 PW_MAGIC_65536: i64 = 65536
15const PW_MAGIC_262144: i64 = 262144
16const PW_MAGIC_40000: i64 = 40000
17const PW_MAGIC_16383: i64 = 16383
18const PW_MAGIC_16384: i64 = 16384
19const PW_MAGIC_12000: i64 = 12000
21const PW_EXT: i64 = 20

functions

23func pm_bstr(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { buf[off+i]=s[i]; i=i+1 } return off+i }
24func pm_bint(buf: *u8, off: i64, v: i64) -> i64
28func pm_build_ext(ext_id: i64, data: *u8, dlen: i64, out: *u8) -> i64
33func pm_read_msg(fd: i64, mb: *u8, cap: i64) -> i64
43func pm_child(ipv: i64, port: i64, ih: *u8, mypid: *u8, res: *u8) -> i64
133func main() -> i64