nx_dht_get_peers.nx
buildroot/runtime/nx_dht_get_peers.nx
about
nx_dht_get_peers.nx -- SOVEREIGN DHT get_peers lookup (X-TORRENT-LIVE-002 R4c): find peers for a
TRACKERLESS info_hash by walking the DHT. Seeds from bootstrap nodes, get_peers each, collects
"values" (peers) and "nodes" (closer nodes to query next), a few BFS rounds. This is what makes the
operator's trackerless magnets (magnet:?xt=urn:btih:..&dn=.. , no tr=) find peers. Composes
nx_dht (KRPC) + nx_dns_a + raw UDP. v1 = BFS (no XOR routing yet); enough for popular swarms.
license_tier: ORIGINAL layer: peer-discovery (trackerless)
module: nishi-core.torrent.dht_get_peers
depends: nishi-core.torrent.dht, nishi-core.dns_a
dependencies 2 imports · 1 importers
imports: nx_dht.nxnx_dns_a.nx
imported by: nx_torrent_get.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 11 | const K_MAGIC_8192: i64 = 8192 |
| 12 | const K_MAGIC_6881: i64 = 6881 |
| 13 | const K_MAGIC_25401: i64 = 25401 |
functions
| 15 | func dgp_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: dgp_p2 |
| 16 | func dgp_p2(s: *u8) -> i64 { sys_write(1, s, dgp_strlen(s)); return 0 } |
| 17 | func dgp_pn2(v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; var k: i64 = 0; if m == 0 { t[0]=48 as u8; k=1 } while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8 = sys_mmap(28); var i: i64=0; while i<k { o[i]=t[k-1-i]; i=i+1 } sys_write(1,o,k); return 0 } |
| 19 | func dgp_sockaddr(out: *u8, port: i64, a: i64, b: i64, c: i64, d: i64) -> i64 |
| 27 | func dgp_query(ipv: i64, port: i64, nid: *u8, ih: *u8, pips: *i64, pports: *i64, pmax: i64, nips: *i64, nports: *i64, nmax: i64, out_nn: *i64) -> i64 |
| 48 | func dgp_find(ih: *u8, nid: *u8, pips: *i64, pports: *i64, pmax: i64) -> i64 |
| 103 | func main() -> i64 |