code wiki / _hdl_build / nx_clean_serve_daemon.nx

nx_clean_serve_daemon.nx

buildroot/runtime/_hdl_build/nx_clean_serve_daemon.nx

22654 B272 linesdepth 21pulls 152 transitivereach 0 importersview sourcekind servicetopic clean
docsdependenciesstructsconstsfunctions

about

nx_clean_serve_daemon.nx -- the LIVE, testable face of the ethical clean-serve engine. The operator (or the search engine) points it at ANY site; it fetches the page over our own sovereign TLS, runs the nx_clean_serve policy (neutralize every attack vector, KEEP ads as inert static creatives, deliver the content + native HTML5 media), and serves the safe clean view with a SAFETY RECEIPT banner. This is the win-win-win, live: USER safe (no active content) · SITE monetizes (safe static ads survive) · SEARCH neutral (served, not deranked). Self-contained (its own file -- no collision with the concurrently-edited nx_archive_daemon). Bind 0.0.0.0 so WSL2/edge can reach it. Run from nxc2 root (certdata is relative). Endpoints: / home form (enter a URL) /clean?url= fetch + clean-serve + safe view (receipt banner + native <video> + cleaned body) /receipt?url= the machine-readable safety receipt (application/json) -- for API testing license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_http_server.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_media_signal.nx nx_web_filter.nx nx_clean_serve.nx nx_kvs.nx nx_clean_serve_daemon.nx

imports: nx_syscalls.nxnx_http_server.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_media_signal.nxnx_web_filter.nxnx_clean_serve.nxnx_kvs.nx

imported by: nobody (leaf or entry point)

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

main csd_datoi nx_trust_store_load_from_c sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_nss_certdata_parse sys_mmap ↻ _pat_class_cert _pat_value_octal _pat_end _find_newline _starts_with _parse_octal_line sys_mmap ↻ _is_space _decode_octal_escape _is_octal trust_store_alloc sys_mmap ↻ nx_x509_trust_store_load sys_mmap ↻ x509_parse sys_mmap ↻ asn1_cursor_init asn1_expect_tag sys_mmap ↻ asn1_read_tlv_header asn1_read_tag asn1_read_length asn1_read_length ↻ x509_read_tlv sys_mmap ↻ asn1_expect_tag ↻ x509_read_alg_id sys_mmap ↻

structs

none

consts

21const CSD_MAGIC_33554432: i64 = 33554432
22const CSD_MAGIC_8388608: i64 = 8388608
23const CSD_MAGIC_1048576: i64 = 1048576
24const CSD_MAGIC_4096: i64 = 4096
25const CSD_MAGIC_1024: i64 = 1024
26const CSD_MAGIC_16384: i64 = 16384
27const CSD_MAGIC_8192: i64 = 8192
28const CSD_MAGIC_8320: i64 = 8320
29const CSD_MAGIC_65536: i64 = 65536
30const CSD_MAGIC_8102: i64 = 8102
31const CSD_MAGIC_4194304: i64 = 4194304
211const CSD_REQ_TIMEOUT_SECS: i64 = 25

functions

33func csd_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 }
34func csd_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 }
35func csd_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 }
called by 1: main
36func csd_hexval(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: csd_query_url
37func csd_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: csd_find_media
38func csd_esc(dst: *u8, off: i64, s: *u8, sl: i64) -> i64
called by 1: csd_clean calls 1: csd_put
44func csd_query_url(q: *u8, qlen: i64, out: *u8, cap: i64) -> i64
calls 1: csd_hexval
55func csd_body_off(buf: *u8, n: i64) -> i64
59func csd_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 }
called by 2: send_htmlsend_json calls 1: sys_write
60func send_html(cfd: i64, body: *u8, blen: i64) -> i64
67func send_json(cfd: i64, body: *u8, blen: i64) -> i64
74func csd_head(page: *u8, o: i64) -> i64
called by 2: csd_homecsd_clean calls 1: csd_put
78func csd_banner(page: *u8, o: i64, rc: *i64) -> i64
called by 1: csd_clean calls 2: csd_putcsd_putn
89func csd_home(page: *u8) -> i64
99func csd_lc2(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c }
100func csd_pfx_ci(s: *u8, sl: i64, p: *u8) -> i64 { var i: i64=0; while p[i]!=(0 as u8) { if i>=sl { return 0 } if csd_lc2(s[i]&0xff)!=csd_lc2(p[i]&0xff) { return 0 } i=i+1 } return 1 }
101func csd_url_safe(url: *u8, ulen: i64) -> i64
122func csd_media_ext(url: *u8, ul: i64) -> i64
129func csd_find_media(html: *u8, hn: i64, out: *u8, cap: i64) -> i64
146func csd_clean(cfd: i64, t: *i64, store: *TrustStore, url: *u8, ulen: i64) -> i64
193func csd_receipt(cfd: i64, t: *i64, store: *TrustStore, url: *u8, ulen: i64) -> i64
214func csd_norm_url(inp: *u8, inlen: i64, out: *u8, cap: i64) -> i64
223func csd_handle_conn(cfd: i64, t: *i64, store: *TrustStore) -> i64
244func main(argc: i64, argv: *i64) -> i64