code wiki / (root) / nx_torrent_mkinfo.nx

nx_torrent_mkinfo.nx

buildroot/runtime/nx_torrent_mkinfo.nx

9857 B164 linesdepth 4pulls 5 transitivereach 2 importersview sourcekind librarytopic torrent
docsdependenciesstructsconstsfunctions

about

nx_torrent_mkinfo.nx -- BUILD a BEP-3 v1 single-file torrent info-dict from a REAL file. The seeder (nx_torrent_seed) can serve any file, but a REAL leecher can only find + verify it if it has the file's v1 info_hash and per-piece SHA-1s -- i.e. a .torrent/magnet. nx_metainfo only PARSES a .torrent; this is the inverse (the "originate/create a torrent" half): read a file, SHA-1 each piece, bencode the info-dict (length/name/piece length/pieces, keys sorted per BEP-3), SHA-1 it -> info_hash, and emit a magnet + a seed_index.conf row. This is what lets the hub SHARE content that any mainstream BitTorrent client (qBittorrent/Transmission/libtorrent) can pull + integrity-check. nx_torrent_mkinfo <file> <name> [piece_length] -> info_hash / magnet / seed row (default plen=262144) nx_torrent_mkinfo -> no-arg = the GATE (round-trips through nx_metainfo) NEVER-BRICK: reads a file + prints; writes no persistent state. license_tier: ORIGINAL module: nishi-core.torrent.mkinfo depends: nishi-core.torrent.metainfo (pulls bencode+sha1+syscalls)

dependencies 1 imports · 2 importers

nx_metainfo.nx nx_torrent_mkinfo.nx nx_torrent_leech_probe.nx nx_unchoke_gate.nx

imports: nx_metainfo.nx

imported by: nx_torrent_leech_probe.nxnx_unchoke_gate.nx

structs

none

consts

16const MK_MAGIC_4096: i64 = 4096
18const MK_PLEN_DEFAULT: i64 = 262144 // 256 KiB (standard)

functions

20func mk_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 2: mk_emitmk_gate
21func mk_wn(fd: i64, v: i64) -> i64
called by 1: mk_emit
26func mk_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: mk_build_info
27func mk_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c<48 {return v} if c>57 {return v} v=v*10+(c-48); i=i+1 } return v }
called by 1: main
28func mk_read_n(fd: i64, buf: *u8, n: i64) -> i64 { var got: i64=0; while got<n { let r: i64=sys_read(fd, buf+got, n-got); if r<=0 { return got } got=got+r } return got }
called by 1: mk_build_info calls 1: sys_read
31func mk_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i];o=o+1;i=i+1} return o }
called by 1: mk_build_info
32func mk_catbytes(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=src[i];o=o+1;i=i+1} return o }
called by 1: mk_bstr
33func mk_catn(dst: *u8, off: i64, v: i64) -> i64
called by 2: mk_bstrmk_bint
39func mk_bstr(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=mk_catn(dst,off,n); dst[o]=58 as u8; o=o+1; o=mk_catbytes(dst,o,src,n); return o }
called by 1: mk_build_info calls 2: mk_catnmk_catbytes
41func mk_bint(dst: *u8, off: i64, v: i64) -> i64 { dst[off]=105 as u8; var o: i64=mk_catn(dst,off+1,v); dst[o]=101 as u8; return o+1 }
called by 1: mk_build_info calls 1: mk_catn
43func mk_hex(dst: *u8, off: i64, bytes: *u8, n: i64) -> i64
called by 2: lp_livemk_emit
51func mk_filesize(path: *u8) -> i64
called by 1: mk_emit calls 1: sys_fstatat
60func mk_build_info(path: *u8, name: *u8, plen: i64, total: i64, npc: i64, info: *u8, pieces: *u8, ih_out: *u8) -> i64
86func mk_emit(path: *u8, name: *u8, plen: i64) -> i64
109func mk_gate() -> i64
156func main(argc: i64, argv: *i64) -> i64