nx_magnet.nx
buildroot/runtime/nx_magnet.nx
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
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
structs
| none |
consts
| 13 | const MG_MAGIC_1024: i64 = 1024 |
| 15 | const MG_NTRK_MAX: i64 = 32 |
functions
| 17 | func 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 |
| 18 | func mg_wn(fd: i64, v: i64) -> i64 |
| 24 | func mg_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 27 | func mg_hexval(c: i64) -> i64 |
| 34 | func mg_b32val(c: i64) -> i64 called by 1: mg_decode_btih |
| 42 | func mg_decode_btih(buf: *u8, a: i64, b: i64, out: *u8) -> i64 |
| 89 | func mg_urldecode(src: *u8, a: i64, b: i64, out: *u8) -> i64 |
| 110 | func mg_keyeq(buf: *u8, a: i64, kb: i64, lit: *u8) -> i64 |
| 119 | func mg_starts(buf: *u8, a: i64, b: i64, lit: *u8) -> i64 |
| 129 | func mg_parse(uri: *u8, ihash: *u8, trk: *i64, trkcap: i64, ntrk: *i64, name: *u8) -> i64 called by 4: mainmainhs_livehs_selftest calls 6: mg_lenmg_startsmg_keyeqmg_decode_btihsys_mmapmg_urldecode |
| 170 | func main() -> i64 |