code wiki / (root) / nx_peer_ext_handshake.nx

nx_peer_ext_handshake.nx

buildroot/runtime/nx_peer_ext_handshake.nx

7110 B138 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic peer
docsdependenciesstructsconstsfunctions

about

nx_peer_ext_handshake.nx -- BEP-10 extension-protocol handshake (X-TORRENT-LIVE-001 R3a): the gateway to BEP-9 ut_metadata (fetch the info-dict for a magnet). After the BEP-3 handshake with the extension bit set (reserved[5] |= 0x10), peers exchange an extended message id=20, ext-id=0, payload = a bencoded dict advertising their extensions: {m:{ut_metadata:<id>}, metadata_size:N}. This rung exchanges them over loopback and PARSES the peer's ut_metadata ext-id + metadata_size (via nx_bencode: nx_bc_dict_get + nx_bc_int). Reuses nx_peerwire (BEP-3 + nx_pw_build_msg) + nx_bencode (DECODE). GATE = SOVEREIGN LOOPBACK; the small bencoded dicts are built BY HAND (no encoder needed). license_tier: ORIGINAL module: nishi-core.torrent.peer_ext_handshake depends: nishi-core.torrent.peerwire, nishi-core.torrent.bencode

dependencies 3 imports · 0 importers

nx_peerwire.nx nx_connect.nx nx_bencode.nx nx_peer_ext_handshake.nx

imports: nx_peerwire.nxnx_connect.nxnx_bencode.nx

imported by: nobody (leaf or entry point)

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

main eh_sockaddr sys_socket sys_setsockopt sys_set_socket_timeout sys_mmap sys_setsockopt ↻ sys_munmap sys_bind sys_listen eh_w sys_fork sys_accept eh_read_n sys_read nx_pw_build_handshake eh_write_n eh_read_msg eh_read_n ↻ _pw_get_u32 eh_build_ext eh_len 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 _bc_bytes_eq nx_bc_skip _bc_is_digit ↻ nx_bc_int _bc_is_digit ↻

structs

none

consts

15const PW_MAGIC_53431: i64 = 53431
16const PW_MAGIC_1234: i64 = 1234
18const PW_EXTENDED: i64 = 20

functions

20func eh_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
21func eh_wn(fd: i64, v: i64) -> i64
called by 1: main
26func eh_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: eh_build_ext
27func eh_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64
called by 1: main
34func eh_read_n(fd: i64, buf: *u8, n: i64) -> i64
called by 2: eh_read_msgmain calls 1: sys_read
39func eh_write_n(fd: i64, buf: *u8, n: i64) -> i64
called by 1: main
44func eh_read_msg(fd: i64, mb: *u8, cap: i64) -> i64
called by 1: main calls 2: eh_read_n_pw_get_u32
53func eh_build_ext(ext_id: i64, ben: *u8, out: *u8) -> i64
called by 1: main calls 2: eh_lennx_pw_build_msg
61func main() -> i64