code wiki / (root) / nx_magnet.nx

nx_magnet.nx

buildroot/runtime/nx_magnet.nx

8922 B217 linesdepth 2pulls 2 transitivereach 8 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_magnet.nx -- BEP-9 magnet-URI parser (the live-client ENTRY point: add_magnet's first step, X-TORRENT-LIVE-001). Pure/deterministic, no network: parse "magnet:?xt=urn:btih:<hash>&dn=..&tr=.." into the 20-byte info_hash + tracker URL list + display name. The info_hash is the identity used by tracker announces (nx_udp_tracker) + peer handshakes (BEP-3); trackers seed peer discovery; the name is the NAS target. Handles BOTH btih forms: 40-hex and 32-char base32 (RFC4648), and %XX / '+' URL-decoding of tr/dn. Sovereign (raw syscalls only); BitTorrent magnet = last-mile interop, the parse is Nishi-native. Self-gating (main = baked KAT). license_tier: ORIGINAL module: nishi-core.torrent.magnet depends: nishi-core.sys.syscalls capability: TORRENT_MAGNET_PARSE

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_magnet.nx nx_magnet_discover.nx nx_torrent_get.nx nx_torrent_health.nx

imports: nx_syscalls.nx

imported by: nx_magnet_discover.nxnx_torrent_get.nxnx_torrent_health.nx

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

main sys_mmap mg_parse mg_len mg_starts mg_len ↻ mg_keyeq mg_len ↻ mg_decode_btih mg_hexval mg_b32val sys_mmap ↻ mg_urldecode mg_hexval ↻ mg_starts ↻ mg_len ↻

structs

none

consts

13const MG_MAGIC_1024: i64 = 1024
15const MG_NTRK_MAX: i64 = 32

functions

17func mg_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 }
calls 1: sys_write
18func mg_wn(fd: i64, v: i64) -> i64
24func mg_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
27func mg_hexval(c: i64) -> i64
34func mg_b32val(c: i64) -> i64
called by 1: mg_decode_btih
42func mg_decode_btih(buf: *u8, a: i64, b: i64, out: *u8) -> i64
called by 1: mg_parse calls 2: mg_hexvalmg_b32val
89func mg_urldecode(src: *u8, a: i64, b: i64, out: *u8) -> i64
called by 1: mg_parse calls 1: mg_hexval
110func mg_keyeq(buf: *u8, a: i64, kb: i64, lit: *u8) -> i64
called by 1: mg_parse calls 1: mg_len
119func mg_starts(buf: *u8, a: i64, b: i64, lit: *u8) -> i64
called by 2: mg_parsemain calls 1: mg_len
129func mg_parse(uri: *u8, ihash: *u8, trk: *i64, trkcap: i64, ntrk: *i64, name: *u8) -> i64
170func main() -> i64