code wiki / (root) / nx_torrent_daemon.nx

nx_torrent_daemon.nx

buildroot/runtime/nx_torrent_daemon.nx

79296 B1321 linesdepth 4pulls 7 transitivereach 2 importersview sourcekind servicetopic torrent
docsdependenciesstructsconstsfunctions

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

nx_http_server.nx nx_syscalls.nx nx_itoa_lib.nx nx_bencode.nx nx_torrent_access.nx nx_torrent_daemon.nx nx_torrent_area_gate.nx nx_torrent_stream_gate.nx

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

main d_path d_puts sys_mmap sys_mkdir nx_http_server_addr_any nx_http_server_make_sockad d_streq sys_write nx_http_server_listen sys_ignore_sigpipe sys_mmap ↻ sys_socket sys_mmap ↻ sys_setsockopt sys_bind sys_close sys_listen sys_exit

structs

none

consts

24const TORRENT_MAGIC_131072: i64 = 131072
25const TORRENT_MAGIC_1024: i64 = 1024
26const TORRENT_MAGIC_8192: i64 = 8192
27const TORRENT_MAGIC_262144: i64 = 262144
28const TORRENT_MAGIC_4000: i64 = 4000
29const TORRENT_MAGIC_65536: i64 = 65536
30const TORRENT_MAGIC_2000: i64 = 2000
31const TORRENT_MAGIC_1048576: i64 = 1048576
32const TORRENT_MAGIC_4096: i64 = 4096
33const TORRENT_MAGIC_4095: i64 = 4095
34const TORRENT_MAGIC_16384: i64 = 16384
35const TORRENT_MAGIC_4200: i64 = 4200
36const TORRENT_MAGIC_8097: i64 = 8097
37const TORRENT_MAGIC_1000000000: i64 = 1000000000
44const TORRENT_LOCAL_MARKER: *u8 = "/mnt/c/Users/elder/Downloads/nishi-torrents/.local_operator"
49const D_RETRY_INTERVAL_MS: i64 = 600000

functions

52func d_strlen(s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){i=i+1} return i }
54func d_puts(dst: *u8, off: i64, s: *u8) -> i64
64func d_putn(dst: *u8, off: i64, v: i64) -> i64 { return nxi_buf(dst, off, v) }
67func d_read_file(path: *u8, buf: *u8, cap: i64) -> i64
82func d_path(outdir: *u8, suf: *u8, out: *u8) -> *u8
89func d_write_file(path: *u8, s: *u8, n: i64) -> i64
98func d_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
110func d_send_str(cfd: i64, status: *u8, ctype: *u8, s: *u8) -> i64
113func d_serve_file(cfd: i64, path: *u8, ctype: *u8) -> i64
122func d_streq(buf: *u8, off: i64, len: i64, s: *u8) -> i64
called by 2: d_routemain
132func d_starts(buf: *u8, off: i64, len: i64, s: *u8) -> i64
called by 1: d_route
145func d_extract_magnet(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64
called by 1: d_route
169func d_has_progress(outdir: *u8) -> i64
182func d_close_inherited() -> i64
191func d_self_dir() -> *u8
204func d_spawn_worker(magnet: *u8, outdir: *u8, resume: i64) -> i64
222func d_find_val(buf: *u8, n: i64, key: *u8) -> i64
233func d_int_at(buf: *u8, n: i64, pos: i64) -> i64
244func d_copy_line(buf: *u8, n: i64, pos: i64, out: *u8, ocap: i64) -> i64
259func d_status(cfd: i64, statpath: *u8, ctlpath: *u8) -> i64
301func d_extract_url(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64
called by 1: d_route
325func d_spawn_discover(url: *u8, dpath: *u8) -> i64
344func d_url_referer(url: *u8, out: *u8) -> *u8
called by 1: d_route
359func d_spawn_video(url: *u8, outpath: *u8, referer: *u8) -> i64
370func d_spawn_hls(url: *u8, outpath: *u8, referer: *u8) -> i64
381func d_is_hls(url: *u8) -> i64
called by 1: d_route
399func d_hls_outname(url: *u8, outdir: *u8, out: *u8) -> *u8
called by 1: d_route calls 1: d_puts
415func d_vidname(url: *u8, outdir: *u8, out: *u8) -> *u8
called by 1: d_route calls 1: d_puts
427func d_scan_to(buf: *u8, n: i64, from: i64, delim: i64) -> i64
432func d_json_buf(dst: *u8, off: i64, src: *u8, from: i64, to: i64) -> i64
443func d_raw_buf(dst: *u8, off: i64, src: *u8, from: i64, to: i64) -> i64
called by 1: d_discover_result
449func d_discover_result(cfd: i64, dpath: *u8) -> i64
497func d_extract_btih(mag: *u8, n: i64, out: *u8, ocap: i64) -> i64
517func d_hexv(c: i64) -> i64
526func d_extract_name(mag: *u8, n: i64, out: *u8, ocap: i64) -> i64
called by 1: d_route calls 1: d_hexv
557func d_subdir(outdir: *u8, id: *u8, dir: *u8) -> *u8
561func d_ends(buf: *u8, off: i64, len: i64, suf: *u8) -> i64
called by 1: d_route calls 1: d_strlen
569func d_idx_has(buf: *u8, n: i64, id: *u8) -> i64
580func d_idx_add(idxpath: *u8, id: *u8) -> i64
592func d_idx_remove(idxpath: *u8, id: *u8) -> i64
609func d_status_one(out: *u8, o0: i64, id: *u8, dir: *u8) -> i64
640func d_status_all(cfd: i64, outdir: *u8, idxpath: *u8) -> i64
675func d_video_extent(meta: *u8, msize: i64, out: *i64) -> i64
694func d_contig_bytes(dir: *u8) -> i64
712func d_form_magnet(body: *u8, blen: i64, out: *u8, ocap: i64) -> i64
called by 1: d_route calls 1: d_hexv
741func d_filesize(path: *u8) -> i64
called by 1: d_stream calls 2: sys_mmapsys_fstatat
748func d_have_npc(dir: *u8, out: *i64) -> i64
762func d_parse_range(req: *u8, rn: i64, out: *i64) -> i64
called by 2: d_streammain
779func d_stream(cfd: i64, req: *u8, rn: i64, dir: *u8) -> i64
871func d_find_by_btih(outdir: *u8, idxpath: *u8, btih: *u8, btn: i64, out_id: *u8, ocap: i64) -> i64
906func d_autoresume(outdir: *u8, idxpath: *u8) -> i64
958func d_buf_find(buf: *u8, n: i64, pat: *u8) -> i64
called by 1: d_parse_area calls 1: d_strlen
972func d_parse_area(req: *u8, n: i64) -> i64
called by 2: maind_route calls 1: d_buf_find
978func d_marker_present(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
980func d_trusted_level(req: *u8, n: i64) -> i64
called by 1: d_viewer_level
997func d_viewer_level(req: *u8, n: i64) -> i64
1006func 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
1016func d_status_root(out: *u8, o0: i64, first_p: *i64, root: *u8, idxpath: *u8) -> i64
1042func d_status_two(cfd: i64, level: i64, sfw_root: *u8, sfw_idx: *u8, nsfw_root: *u8, nsfw_idx: *u8) -> i64
1054func d_route(cfd: i64, req: *u8, method: i64, po: i64, pl: i64, cl_: i64, bo: i64, rn: i64,
1214func main(argc: i64, argv: *i64) -> i64