nx_pex.nx
buildroot/runtime/nx_pex.nx
about
nx_pex.nx -- BEP-11 Peer Exchange (ut_pex): parse/build the compact peer lists that connected
peers gossip to each other over the BEP-10 extension channel. This is the high-value amplifier
for TRACKERLESS magnets + stuck (99.x%) swarms -- once we hold ONE peer, PEX hands us MORE peers
(often seeders the tracker/DHT never returned), directly attacking the operator's "no seeder /
can't finish" pain. Reuses the universal compact-6B/peer idiom (b0<<24|b1<<16|b2<<8|b3, port
b4<<8|b5) shared with nx_dht's value parse + the nx_bencode DECODE layer. Pure (no network):
"import strips main", so THIS file is BOTH the lib AND a baked-KAT self-gate (deterministic,
sovereign). The live BEP-10 round-trip is proven by nx_pex_gate. license_tier: ORIGINAL
module: nishi-core.torrent.pex
depends: nishi-core.torrent.bencode
dependencies 2 imports · 2 importers
imports: nx_bencode.nxnx_itoa_lib.nx
imported by: nx_pex_gate.nxnx_torrent_get.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 14 | const PEX_MAGIC_6881: i64 = 6881 |
| 15 | const PEX_MAGIC_51413: i64 = 51413 |
| 16 | const PEX_MAGIC_4096: i64 = 4096 |
| 17 | const PEX_MAGIC_6882: i64 = 6882 |
| 21 | const PEX_OUR_ID: i64 = 3 |
functions
| 25 | func px_puts(out: *u8, off: i64, s: *u8) -> i64 |
| 32 | func px_putdec(out: *u8, off: i64, v: i64) -> i64 called by 1: pex_build_added |
| 46 | func pex_build_added(ips: *i64, ports: *i64, cnt: i64, out: *u8) -> i64 |
| 70 | func pex_parse_key(buf: *u8, start: i64, n: i64, key: *u8, keylen: i64, ips: *i64, ports: *i64, max: i64) -> i64 |
| 96 | func pex_parse_added(buf: *u8, start: i64, n: i64, ips: *i64, ports: *i64, max: i64) -> i64 |
| 102 | func pex_peer_id(mb: *u8, start: i64, n: i64) -> i64 |
| 113 | func px_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } called by 1: main |
| 118 | func px_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 120 | func main() -> i64 |