nx_peer_ext_handshake.nx
buildroot/runtime/nx_peer_ext_handshake.nx
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
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
structs
| none |
consts
| 15 | const PW_MAGIC_53431: i64 = 53431 |
| 16 | const PW_MAGIC_1234: i64 = 1234 |
| 18 | const PW_EXTENDED: i64 = 20 |
functions
| 20 | func 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 |
| 21 | func eh_wn(fd: i64, v: i64) -> i64 called by 1: main |
| 26 | func 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 |
| 27 | func eh_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64 called by 1: main |
| 34 | func eh_read_n(fd: i64, buf: *u8, n: i64) -> i64 |
| 39 | func eh_write_n(fd: i64, buf: *u8, n: i64) -> i64 called by 1: main |
| 44 | func eh_read_msg(fd: i64, mb: *u8, cap: i64) -> i64 |
| 53 | func eh_build_ext(ext_id: i64, ben: *u8, out: *u8) -> i64 |
| 61 | func main() -> i64 |