nx_torrent_daemon.nx
buildroot/runtime/nx_torrent_daemon.nx
about
nx_torrent_daemon.nx -- the UI enabler (X-TORRENT-UI-001): an HTTP daemon that
serves the operator's torrent page and wires it to the LIVE download worker.
GET /torrent -> sites/nishifamily/torrent/index.html
GET /torrent/app.js -> the page's last-mile JS (renders REAL state only)
GET /torrent/api/me -> {"user":"local"} (local single-operator)
POST /torrent/api/login -> {"ok":true}
POST /torrent/api/add {magnet} -> fork+execve the worker elf -> {"id":"1"}
GET /torrent/api/status -> reads outdir/download.status -> {downloads:[...]}
POST /torrent/api/<id>/<action> -> {"ok":true} (pause/resume/remove noop)
Sovereign: composes nx_http_server (bind/listen/accept) + the worker elf the team
already built. NO mocked numbers -- /status emits exactly what the worker wrote to
disk; before any download the worker file is absent -> {downloads:[]} (honest empty).
license_tier: ORIGINAL kind: last-mile-ui-bridge layer: L6 (over L4 http + L5 worker)
module: nishi-core.torrent.daemon
depends: nishi-core.http_server, nishi-core.syscalls
dependencies 5 imports · 2 importers
imports: nx_http_server.nxnx_syscalls.nxnx_itoa_lib.nxnx_bencode.nxnx_torrent_access.nx
imported by: nx_torrent_area_gate.nxnx_torrent_stream_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 24 | const TORRENT_MAGIC_131072: i64 = 131072 |
| 25 | const TORRENT_MAGIC_1024: i64 = 1024 |
| 26 | const TORRENT_MAGIC_8192: i64 = 8192 |
| 27 | const TORRENT_MAGIC_262144: i64 = 262144 |
| 28 | const TORRENT_MAGIC_4000: i64 = 4000 |
| 29 | const TORRENT_MAGIC_65536: i64 = 65536 |
| 30 | const TORRENT_MAGIC_2000: i64 = 2000 |
| 31 | const TORRENT_MAGIC_1048576: i64 = 1048576 |
| 32 | const TORRENT_MAGIC_4096: i64 = 4096 |
| 33 | const TORRENT_MAGIC_4095: i64 = 4095 |
| 34 | const TORRENT_MAGIC_16384: i64 = 16384 |
| 35 | const TORRENT_MAGIC_4200: i64 = 4200 |
| 36 | const TORRENT_MAGIC_8097: i64 = 8097 |
| 37 | const TORRENT_MAGIC_1000000000: i64 = 1000000000 |
| 44 | const TORRENT_LOCAL_MARKER: *u8 = "/mnt/c/Users/elder/Downloads/nishi-torrents/.local_operator" |
| 49 | const D_RETRY_INTERVAL_MS: i64 = 600000 |
functions
| 52 | func d_strlen(s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){i=i+1} return i } |
| 54 | func d_puts(dst: *u8, off: i64, s: *u8) -> i64 |
| 64 | func d_putn(dst: *u8, off: i64, v: i64) -> i64 { return nxi_buf(dst, off, v) } |
| 67 | func d_read_file(path: *u8, buf: *u8, cap: i64) -> i64 called by 16: d_serve_filed_statusd_discover_resultd_idx_addd_idx_removed_status_one+10 calls 3: sys_openat_rdsys_readsys_close |
| 82 | func d_path(outdir: *u8, suf: *u8, out: *u8) -> *u8 called by 13: d_spawn_workerd_spawn_discoverd_spawn_videod_spawn_hlsd_status_oned_contig_bytes+7 calls 1: d_puts |
| 89 | func d_write_file(path: *u8, s: *u8, n: i64) -> i64 |
| 98 | func d_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64 |
| 110 | func d_send_str(cfd: i64, status: *u8, ctype: *u8, s: *u8) -> i64 |
| 113 | func d_serve_file(cfd: i64, path: *u8, ctype: *u8) -> i64 |
| 122 | func d_streq(buf: *u8, off: i64, len: i64, s: *u8) -> i64 |
| 132 | func d_starts(buf: *u8, off: i64, len: i64, s: *u8) -> i64 called by 1: d_route |
| 145 | func d_extract_magnet(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64 called by 1: d_route |
| 169 | func d_has_progress(outdir: *u8) -> i64 |
| 182 | func d_close_inherited() -> i64 |
| 191 | func d_self_dir() -> *u8 |
| 204 | func d_spawn_worker(magnet: *u8, outdir: *u8, resume: i64) -> i64 called by 2: d_autoresumed_route calls 8: d_pathd_self_dirsys_mmapsys_forkd_close_inheritedsys_execve+2 |
| 222 | func d_find_val(buf: *u8, n: i64, key: *u8) -> i64 |
| 233 | func d_int_at(buf: *u8, n: i64, pos: i64) -> i64 |
| 244 | func d_copy_line(buf: *u8, n: i64, pos: i64, out: *u8, ocap: i64) -> i64 |
| 259 | func d_status(cfd: i64, statpath: *u8, ctlpath: *u8) -> i64 |
| 301 | func d_extract_url(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64 called by 1: d_route |
| 325 | func d_spawn_discover(url: *u8, dpath: *u8) -> i64 |
| 344 | func d_url_referer(url: *u8, out: *u8) -> *u8 called by 1: d_route |
| 359 | func d_spawn_video(url: *u8, outpath: *u8, referer: *u8) -> i64 |
| 370 | func d_spawn_hls(url: *u8, outpath: *u8, referer: *u8) -> i64 |
| 381 | func d_is_hls(url: *u8) -> i64 called by 1: d_route |
| 399 | func d_hls_outname(url: *u8, outdir: *u8, out: *u8) -> *u8 |
| 415 | func d_vidname(url: *u8, outdir: *u8, out: *u8) -> *u8 |
| 427 | func d_scan_to(buf: *u8, n: i64, from: i64, delim: i64) -> i64 |
| 432 | func d_json_buf(dst: *u8, off: i64, src: *u8, from: i64, to: i64) -> i64 |
| 443 | func d_raw_buf(dst: *u8, off: i64, src: *u8, from: i64, to: i64) -> i64 called by 1: d_discover_result |
| 449 | func d_discover_result(cfd: i64, dpath: *u8) -> i64 |
| 497 | func d_extract_btih(mag: *u8, n: i64, out: *u8, ocap: i64) -> i64 |
| 517 | func d_hexv(c: i64) -> i64 |
| 526 | func d_extract_name(mag: *u8, n: i64, out: *u8, ocap: i64) -> i64 |
| 557 | func d_subdir(outdir: *u8, id: *u8, dir: *u8) -> *u8 called by 6: d_status_alld_find_by_btihd_autoresumed_resolve_dird_status_rootd_route calls 1: d_puts |
| 561 | func d_ends(buf: *u8, off: i64, len: i64, suf: *u8) -> i64 |
| 569 | func d_idx_has(buf: *u8, n: i64, id: *u8) -> i64 |
| 580 | func d_idx_add(idxpath: *u8, id: *u8) -> i64 |
| 592 | func d_idx_remove(idxpath: *u8, id: *u8) -> i64 |
| 609 | func d_status_one(out: *u8, o0: i64, id: *u8, dir: *u8) -> i64 called by 2: d_status_alld_status_root calls 10: d_pathsys_mmapd_read_filed_int_atd_find_vald_copy_line+4 |
| 640 | func d_status_all(cfd: i64, outdir: *u8, idxpath: *u8) -> i64 |
| 675 | func d_video_extent(meta: *u8, msize: i64, out: *i64) -> i64 |
| 694 | func d_contig_bytes(dir: *u8) -> i64 |
| 712 | func d_form_magnet(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64 |
| 741 | func d_filesize(path: *u8) -> i64 |
| 748 | func d_have_npc(dir: *u8, out: *i64) -> i64 |
| 762 | func d_parse_range(req: *u8, rn: i64, out: *i64) -> i64 |
| 779 | func d_stream(cfd: i64, req: *u8, rn: i64, dir: *u8) -> i64 |
| 871 | func d_find_by_btih(outdir: *u8, idxpath: *u8, btih: *u8, btn: i64, out_id: *u8, ocap: i64) -> i64 |
| 906 | func d_autoresume(outdir: *u8, idxpath: *u8) -> i64 |
| 958 | func d_buf_find(buf: *u8, n: i64, pat: *u8) -> i64 |
| 972 | func d_parse_area(req: *u8, n: i64) -> i64 |
| 978 | func d_marker_present(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } |
| 980 | func d_trusted_level(req: *u8, n: i64) -> i64 called by 1: d_viewer_level |
| 997 | func d_viewer_level(req: *u8, n: i64) -> i64 |
| 1006 | func d_resolve_dir(id: *u8, level: i64, sfw_root: *u8, sfw_idx: *u8, nsfw_root: *u8, nsfw_idx: *u8, out_dir: *u8, out_area: *i64) -> i64 |
| 1016 | func d_status_root(out: *u8, o0: i64, first_p: *i64, root: *u8, idxpath: *u8) -> i64 |
| 1042 | func d_status_two(cfd: i64, level: i64, sfw_root: *u8, sfw_idx: *u8, nsfw_root: *u8, nsfw_idx: *u8) -> i64 |
| 1054 | func d_route(cfd: i64, req: *u8, method: i64, po: i64, pl: i64, cl_: i64, bo: i64, rn: i64, |
| 1214 | func main(argc: i64, argv: *i64) -> i64 |