code wiki / (root) / nx_archive_server.nx

nx_archive_server.nx

buildroot/runtime/nx_archive_server.nx

22935 B311 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind servicetopic archive
docsdependenciesstructsconstsfunctions

about

nx_archive_server.nx -- sovereign localhost HTTP server for the time machine (R5 serve side). Binds 0.0.0.0:18801 (ARCSRV_PORT -- the bind DERIVES from that const, see below), serves files under web_assets/ (path-traversal rejected), Content-Type by extension. "/" -> a landing page. Also hosts the SUPERVISED do-not-recover blocklist: GET /blocklist renders it live from seg_store (justification + per-entry action), GET /blocklist/approve?id=N and /blocklist/retract?id=N are the operator ACTIONS (flip status on seg_store, then 303 back to /blocklist). Pending entries never block until approved here. Fetch stack. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_blocklist_view.nx nx_archive_server.nx

imports: nx_syscalls.nxnx_blocklist_view.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_socket sw sys_write sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ apn sys_mmap ↻ sys_bind sys_listen

structs

none

consts

17const ARCSRV_PORT: i64 = 18801
18const K_MAGIC_8192: i64 = 8192
19const K_MAGIC_2048: i64 = 2048
20const K_MAGIC_2097152: i64 = 2097152
37const ARC_TOGGLE: *u8 = "<div style='position:fixed;top:0;right:0;z-index:99999;background:#111;color:#eee;font:13px system-ui;padding:6px 11px;opacity:.92;border-radius:0 0 0 8px'><label><input type=checkbox onchange='nxT(this.checked)'> enhanced</label></div><script>function nxT(on){var a=document.images,i;for(i=0;i<a.length;i++){var m=a[i];if(!m.getAttribute('data-nxo'))m.setAttribute('data-nxo',m.getAttribute('src'));var o=m.getAttribute('data-nxo');if(on){m.onerror=function(){this.onerror=null;this.src=this.getAttribute('data-nxo')};m.src=o+'.enh.png'}else{m.onerror=null;m.src=o}}}</script>" as *u8
49const AS_RECLEN_OFF: i64 = 16
50const AS_NAME_OFF: i64 = 19
51const AS_DIRBUF: i64 = 262144
52const AS_DT_DIR: i64 = 4

functions

22func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
23func ap(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8) { buf[off+i]=s[i]; i=i+1 } return off+i }
called by 1: as_dirlist
24func apn(buf: *u8, off: i64, v: i64) -> i64 { if v==0 { buf[off]=0x30 as u8; return off+1 } var m: i64=v; 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 o: i64=off; var q: i64=k-1; while q>=0 { buf[o]=t[q]; o=o+1; q=q-1 } return o }
called by 2: as_dirlistmain calls 1: sys_mmap
25func endswith(path: *u8, plen: i64, ext: *u8, elen: i64) -> i64 { if plen<elen { return 0 } var i: i64=0; while i<elen { if (path[plen-elen+i] as i64) != (ext[i] as i64) { return 0 } i=i+1 } return 1 }
called by 1: ctype
56func as_dirlist(path: *u8, req: *u8, pst: i64, pen: i64, out: *u8) -> i64
123func ctype(path: *u8, plen: i64) -> *u8
calls 1: endswith
164func has_dotdot(buf: *u8, off: i64, len: i64) -> i64 { var i: i64=off; while i+1<off+len { if (buf[i] as i64)==0x2e { if (buf[i+1] as i64)==0x2e { return 1 } } i=i+1 } return 0 }
166func path_eq(req: *u8, pst: i64, plen: i64, lit: *u8, litlen: i64) -> i64 { if plen!=litlen { return 0 } var i: i64=0; while i<litlen { if (req[pst+i] as i64)!=(lit[i] as i64) { return 0 } i=i+1 } return 1 }
167func path_starts(req: *u8, pst: i64, plen: i64, lit: *u8, litlen: i64) -> i64 { if plen<litlen { return 0 } var i: i64=0; while i<litlen { if (req[pst+i] as i64)!=(lit[i] as i64) { return 0 } i=i+1 } return 1 }
169func qid(req: *u8, qst: i64, qen: i64, idbuf: *u8) -> i64
181func main() -> i64