nx_torrent_mkinfo.nx
buildroot/runtime/nx_torrent_mkinfo.nx
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
imports: nx_metainfo.nx
imported by: nx_torrent_leech_probe.nxnx_unchoke_gate.nx
structs
| none |
consts
| 16 | const MK_MAGIC_4096: i64 = 4096 |
| 18 | const MK_PLEN_DEFAULT: i64 = 262144 // 256 KiB (standard) |
functions
| 20 | func 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 } |
| 21 | func mk_wn(fd: i64, v: i64) -> i64 called by 1: mk_emit |
| 26 | func 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 |
| 27 | func 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 |
| 28 | func 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 } |
| 31 | func 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 |
| 32 | func 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 |
| 33 | func mk_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 39 | func 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 } |
| 41 | func 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 } |
| 43 | func mk_hex(dst: *u8, off: i64, bytes: *u8, n: i64) -> i64 |
| 51 | func mk_filesize(path: *u8) -> i64 |
| 60 | func mk_build_info(path: *u8, name: *u8, plen: i64, total: i64, npc: i64, info: *u8, pieces: *u8, ih_out: *u8) -> i64 |
| 86 | func mk_emit(path: *u8, name: *u8, plen: i64) -> i64 |
| 109 | func mk_gate() -> i64 |
| 156 | func main(argc: i64, argv: *i64) -> i64 |