code wiki / (root) / nx_peer_metadata.nx

nx_peer_metadata.nx

buildroot/runtime/nx_peer_metadata.nx

10540 B182 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tooltopic peer
docsdependenciesstructsconstsfunctions

about

nx_peer_metadata.nx -- BEP-9 ut_metadata FETCH + sha1-verify the info-dict (X-TORRENT-LIVE-001 R3b): COMPLETES the engine. A magnet has no .torrent, so the client fetches the info-dict from a peer over BEP-10/BEP-9: ext handshake -> learn ut_metadata id + metadata_size -> request each metadata piece -> peer replies a bencoded header + RAW info-dict bytes -> assemble -> the BEP-9 integrity check sha1(info-dict)==info_hash -> nx_bc_dict_get the piece map (name/piece length/ length). Reuses nx_peerwire + nx_bencode + nx_sha1. GATE = SOVEREIGN LOOPBACK: a synthetic info-dict whose sha1 IS the handshake info_hash; the mock serves it; the client fetches, assembles, verifies, and parses. license_tier: ORIGINAL module: nishi-core.torrent.peer_metadata depends: nishi-core.torrent.peerwire, nishi-core.torrent.bencode, nishi-core.crypto.sha1

dependencies 4 imports · 0 importers

nx_peerwire.nx nx_connect.nx nx_bencode.nx nx_sha1.nx nx_peer_metadata.nx

imports: nx_peerwire.nxnx_connect.nxnx_bencode.nxnx_sha1.nx

imported by: nobody (leaf or entry point)

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

main md_bstr sha1 sys_mmap sha1_process_block if_ge md_sockaddr sys_socket sys_setsockopt sys_set_socket_timeout sys_mmap ↻ sys_setsockopt ↻ sys_munmap sys_bind sys_listen md_w sys_fork sys_accept md_read_n sys_read nx_pw_build_handshake md_write_n md_read_msg md_read_n ↻ _pw_get_u32 md_bint md_build_ext nx_pw_build_msg _pw_put_u32 nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll nx_pw_parse_handshake nx_pw_msg_id nx_bc_dict_get sys_mmap ↻ nx_bc_str _bc_is_digit

structs

none

consts

16const PW_MAGIC_65536: i64 = 65536
17const PW_MAGIC_53461: i64 = 53461
18const PW_MAGIC_1024: i64 = 1024
19const PW_MAGIC_2048: i64 = 2048
21const PW_EXTENDED: i64 = 20

functions

23func md_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
24func md_wn(fd: i64, v: i64) -> i64
called by 1: main
29func md_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 }
called by 1: main
30func md_bint(buf: *u8, off: i64, v: i64) -> i64
called by 1: main
34func md_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64
called by 1: main
41func md_read_n(fd: i64, buf: *u8, n: i64) -> i64
called by 2: md_read_msgmain calls 1: sys_read
46func md_write_n(fd: i64, buf: *u8, n: i64) -> i64
called by 1: main
51func md_read_msg(fd: i64, mb: *u8, cap: i64) -> i64
called by 1: main calls 2: md_read_n_pw_get_u32
60func md_build_ext(ext_id: i64, data: *u8, dlen: i64, out: *u8) -> i64
called by 1: main calls 1: nx_pw_build_msg
67func main() -> i64