code wiki / _hdl_build / nx_archive_daemon.nx

nx_archive_daemon.nx

buildroot/runtime/_hdl_build/nx_archive_daemon.nx

43955 B504 linesdepth 24pulls 189 transitivereach 0 importersview sourcekind orphan librarytopic archive
docsdependenciesstructsconstsfunctions

about

nx_archive_daemon.nx -- the LIVE preservation service, expanded per operator: a TRUE archive (keeps the clean PAGE and the MEDIA), rated so SFW lands on /media and NSFW on /gallery, with in-browser playback (Range-aware so a 562MB film streams+seeks). Endpoints: / home: preserve form (URL + SFW/NSFW) + links to the two libraries /preserve?url=&rating= fetch as a browser (archive.org details -> resolve to the real file), STRIP tracking/ ad/redirect junk from HTML, archive the clean page AND the media under the rating /media list SFW preserved items (play/view/download) /gallery list NSFW preserved items /play?url= in-browser player page /archive?url= raw byte-exact serve, Range/206 aware (streams big video) Durable: the WARC persists to disk + reloads at startup. Run from nxc2 root. license_tier: ORIGINAL

dependencies 13 imports · 0 importers

nx_syscalls.nx nx_http_server.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_csprng.nx nx_browser_fetch.nx nx_web_archive.nx nx_ia_resolve.nx nx_media_extract.nx nx_video_sniff_fetch.nx nx_archive_daemon.nx

diagram shows first 10 each side; +3 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_http_server.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_csprng.nxnx_browser_fetch.nxnx_web_archive.nxnx_ia_resolve.nxnx_media_extract.nxnx_video_sniff_fetch.nxnx_surrogate.nxnx_web_harden.nxnx_kvs.nx

imported by: nobody (leaf or entry point)

structs

none

consts

25const K_MAGIC_12288: i64 = 12288
26const K_MAGIC_8192: i64 = 8192
27const K_MAGIC_1024: i64 = 1024
28const K_MAGIC_4096: i64 = 4096
29const K_MAGIC_8101: i64 = 8101
30const K_MAGIC_4194304: i64 = 4194304
31const K_MAGIC_1610612736: i64 = 1610612736
32const K_MAGIC_838860800: i64 = 838860800
33const K_MAGIC_2097152: i64 = 2097152
34const K_MAGIC_16777216: i64 = 16777216
35const K_MAGIC_16384: i64 = 16384
36const K_MAGIC_65536: i64 = 65536
37const K_MAGIC_2560: i64 = 2560
38const K_MAGIC_2048: i64 = 2048

functions

40func ad_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
41func ad_put(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off]=s[i];off=off+1;i=i+1} return off }
42func ad_putn(dst: *u8, off: i64, v: i64) -> i64 { var m: i64=v; if m==0 { dst[off]=48 as u8; return off+1 } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var j: i64=0; while j<k { dst[off]=t[k-1-j]; off=off+1; j=j+1 } return off }
called by 2: send_htmlad_home calls 1: sys_mmap
43func ad_datoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while (s[i]&0xff)>=48 { if (s[i]&0xff)>57 { i=i } else { v=v*10+((s[i]&0xff)-48); i=i+1 } if (s[i]&0xff)<48 { i=i } } return v }
44func ad_hex(c: i64) -> i64 { if c>=48 { if c<=57 { return c-48 } } if c>=97 { if c<=102 { return c-87 } } if c>=65 { if c<=70 { return c-55 } } return 0 }
called by 1: ad_query_param
45func ad_dstarts(p: *u8, plen: i64, pre: *u8) -> i64 { var i: i64=0; while pre[i]!=(0 as u8) { if i>=plen { return 0 } if (p[i]&0xff)!=(pre[i]&0xff) { return 0 } i=i+1 } return 1 }
called by 1: ad_home
46func ad_find(hay: *u8, hl: i64, needle: *u8, nl: i64, from: i64) -> i64 { if nl==0 { return from } var i: i64=from; let last: i64=hl-nl; while i<=last { var j: i64=0; var m: i64=1; while j<nl { if (hay[i+j]&0xff)!=(needle[j]&0xff){m=0;j=nl} else {j=j+1} } if m==1 {return i} i=i+1 } return 0-1 }
47func ad_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while 1==1 { let x: i64=a[i]&0xff; let y: i64=b[i]&0xff; if x!=y { return 0 } if x==0 { return 1 } i=i+1 } return 0 }
called by 1: ad_home
48func ad_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c }
called by 1: ad_ci_at
49func ad_ci_at(src: *u8, slen: i64, pos: i64, lit: *u8, litlen: i64) -> i64 { if pos+litlen>slen { return 0 } var i: i64=0; while i<litlen { if ad_lc(src[pos+i]&0xff)!=ad_lc(lit[i]&0xff) { return 0 } i=i+1 } return 1 }
52func rat_memeq(buf: *u8, off: i64, s: *u8, slen: i64) -> i64 { var i: i64=0; while i<slen { if (buf[off+i]&0xff)!=(s[i]&0xff) { return 0 } i=i+1 } return 1 }
called by 1: rat_lookup
53func rat_lookup(buf: *u8, off: i64, url: *u8, ulen: i64, out: *u8, cap: i64) -> i64
calls 1: rat_memeq
64func ad_query_param(q: *u8, qlen: i64, name: *u8, namelen: i64, out: *u8, cap: i64) -> i64
called by 1: ad_home calls 1: ad_hex
79func ad_urlenc(s: *u8, slen: i64, out: *u8, cap: i64) -> i64
88func ad_esc(dst: *u8, off: i64, s: *u8, sl: i64) -> i64
called by 1: ad_clean_view calls 1: ad_put
94func ad_write_all(fd: i64, buf: *u8, n: i64) -> i64 { var off: i64=0; while off<n { let w: i64=sys_write(fd, ((buf as i64)+off) as *u8, n-off); if w<=0 { return off } off=off+w } return off }
calls 1: sys_write
96func ad_skip_block(src: *u8, slen: i64, from: i64, close: *u8, closelen: i64) -> i64
called by 1: ad_strip_junk_into calls 1: ad_ci_at
101func ad_putb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var i: i64=0; while i<n { dst[off]=src[i]; off=off+1; i=i+1 } return off }
called by 1: ad_clean_view
104func ad_strip_junk_into(out: *u8, off: i64, cap: i64, src: *u8, slen: i64) -> i64
122func ad_strip_junk(src: *u8, slen: i64, out: *u8, cap: i64) -> i64 { let o: i64 = ad_strip_junk_into(out, 0, cap, src, slen); out[o]=0 as u8; return o }
125func ad_clean_view(out: *u8, cap: i64, body: *u8, blen: i64, page_url: *u8, ulen: i64, media_url: *u8, mlen: i64, is_html: i64, ocss: *u8, ocss_len: i64) -> i64
145func ad_origin_ctype(resp: *u8, boff: i64, out: *u8, cap: i64) -> i64
called by 1: ad_home calls 2: ad_findad_put
154func ad_plan_url(plan: *u8, out: *u8, cap: i64) -> i64
called by 1: ad_home calls 2: ad_findad_slen
164func ad_is_html(ct: *u8) -> i64 { if ad_find(ct, ad_slen(ct), "text/html" as *u8, 9, 0) >= 0 { return 1 } return 0 }
called by 1: ad_home calls 2: ad_findad_slen
165func ad_is_video(ct: *u8) -> i64 { if ad_find(ct, ad_slen(ct), "video/" as *u8, 6, 0) >= 0 { return 1 } return 0 }
called by 1: ad_home calls 2: ad_findad_slen
166func ad_is_image(ct: *u8) -> i64 { if ad_find(ct, ad_slen(ct), "image/" as *u8, 6, 0) >= 0 { return 1 } return 0 }
calls 2: ad_findad_slen
168func ad_parse_range(req: *u8, reqlen: i64, out_start: *i64, out_end: *i64) -> i64
calls 1: ad_find
183func send_html(cfd: i64, body: *u8, blen: i64) -> i64
191func ad_head(page: *u8, o: i64, title: *u8) -> i64
called by 1: ad_home calls 1: ad_put
197func ad_home(page: *u8, warc: *u8, warc_off: i64) -> i64
209func ad_listing(page: *u8, warc: *u8, warc_off: i64, want: *u8, title: *u8, other: *u8, otherlabel: *u8, rat_buf: *u8, rat_off: i64) -> i64
249func ad_play(page: *u8, url: *u8, ulen: i64) -> i64
258func ad_serve_archive(cfd: i64, warc: *u8, warc_off: i64, url: *u8, ulen: i64, req: *u8, reqlen: i64) -> i64
291func ad_serve_stream(cfd: i64, store: *TrustStore, cr: *u8, pk: *u8, url: *u8, ulen: i64, req: *u8, reqlen: i64, resp: *u8, cap: i64) -> i64
323func ad_preserve_one(warc: *u8, warc_off: i64, fetch_url: *u8, store_url: *u8, rating: *u8, store: *TrustStore, cr: *u8, pk: *u8, resp: *u8, cap: i64, out_bytes: *i64, out_ct: *u8) -> i64
342func main(argc: i64, argv: *i64) -> i64