code wiki / _hdl_build / nx_clean_serve_daemon.nx
nx_clean_serve_daemon.nx
buildroot/runtime/_hdl_build/nx_clean_serve_daemon.nx
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
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
structs
| none |
consts
| 21 | const CSD_MAGIC_33554432: i64 = 33554432 |
| 22 | const CSD_MAGIC_8388608: i64 = 8388608 |
| 23 | const CSD_MAGIC_1048576: i64 = 1048576 |
| 24 | const CSD_MAGIC_4096: i64 = 4096 |
| 25 | const CSD_MAGIC_1024: i64 = 1024 |
| 26 | const CSD_MAGIC_16384: i64 = 16384 |
| 27 | const CSD_MAGIC_8192: i64 = 8192 |
| 28 | const CSD_MAGIC_8320: i64 = 8320 |
| 29 | const CSD_MAGIC_65536: i64 = 65536 |
| 30 | const CSD_MAGIC_8102: i64 = 8102 |
| 31 | const CSD_MAGIC_4194304: i64 = 4194304 |
| 211 | const CSD_REQ_TIMEOUT_SECS: i64 = 25 |
functions
| 33 | func 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 } |
| 34 | func 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 } |
| 35 | func 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 |
| 36 | func 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 |
| 37 | func 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 |
| 38 | func csd_esc(dst: *u8, off: i64, s: *u8, sl: i64) -> i64 |
| 44 | func csd_query_url(q: *u8, qlen: i64, out: *u8, cap: i64) -> i64 calls 1: csd_hexval |
| 55 | func csd_body_off(buf: *u8, n: i64) -> i64 |
| 59 | func 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 } |
| 60 | func send_html(cfd: i64, body: *u8, blen: i64) -> i64 |
| 67 | func send_json(cfd: i64, body: *u8, blen: i64) -> i64 |
| 74 | func csd_head(page: *u8, o: i64) -> i64 |
| 78 | func csd_banner(page: *u8, o: i64, rc: *i64) -> i64 |
| 89 | func csd_home(page: *u8) -> i64 |
| 99 | func csd_lc2(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c } |
| 100 | func 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 } |
| 101 | func csd_url_safe(url: *u8, ulen: i64) -> i64 |
| 122 | func csd_media_ext(url: *u8, ul: i64) -> i64 |
| 129 | func csd_find_media(html: *u8, hn: i64, out: *u8, cap: i64) -> i64 |
| 146 | func csd_clean(cfd: i64, t: *i64, store: *TrustStore, url: *u8, ulen: i64) -> i64 |
| 193 | func csd_receipt(cfd: i64, t: *i64, store: *TrustStore, url: *u8, ulen: i64) -> i64 |
| 214 | func csd_norm_url(inp: *u8, inlen: i64, out: *u8, cap: i64) -> i64 |
| 223 | func csd_handle_conn(cfd: i64, t: *i64, store: *TrustStore) -> i64 |
| 244 | func main(argc: i64, argv: *i64) -> i64 |