code wiki / (root) / nx_fetch_any.nx

nx_fetch_any.nx

buildroot/runtime/nx_fetch_any.nx

9741 B201 linesdepth 22pulls 151 transitivereach 79 importersview sourcekind tooltopic fetch
docsdependenciesstructsconstsfunctions

about

nx_fetch_any.nx -- EAT THE FETCH DEBT (operator 2026-07-14): the ONE intelligent fetch DISPATCHER the researcher / census / adversary / critic route through, so they "use and switch and be intelligent about" the ~200 fetch organs "as we gather information so we dont get errors and return nothing without informing the user." Rule-15 DRY: this does NOT add a new fetcher -- it COMPOSES the proven primitives into ONE classify->cascade->always-inform entry point. THE TWO SILENT FAILURES THIS KILLS (both proven live this session): * SILENT-EMPTY : a handshake/host failure returned 0 and the researcher banked NOTHING, with no record. * SILENT-BAD : nx_https_fetch_follow_best returns a Cloudflare 403 CHALLENGE PAGE with n>0, and the old rf_fetch_bank banked that challenge HTML as if it were real research (garbage in the corpus). THE CONTRACT (what "informing the user" means mechanically): nx_fetch_any ALWAYS writes a human-readable per-strategy attempts log into `att` (never left empty), and returns the byte count of a VERIFIED-REAL page (2xx, non-challenge, >= FA_MIN_BYTES) or 0. On 0 the caller MUST surface `att` (rf_fetch_bank banks it as <name>.fail) -- absence becomes DATA, never silence. THE CASCADE (each rung a real, existing, gated primitive): S1 nx_https_fetch_follow_best -- sovereign TLS-1.3 (2 hellos) -> TLS-1.2, redirects, cookie-jar+age-gate S2 nx_https_get_spoof -- real Firefox UA + browser Accept (+ cf_clearance cookie when supplied); beats UA-gating and Cloudflare walls the raw sovereign JA3 does not. (v2 rungs, wired next: nx_http_fetch plaintext:80 for HTTP-only hosts; nx_browser_fetch meta-refresh/JS.) 100% sovereign (own TLS, nx_cc->nxasm, no curl/wget/gcc). license_tier: ORIGINAL

dependencies 6 imports · 4 importers

nx_syscalls.nx nx_csprng.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_fetch_follow.nx nx_https_get_spoof.nx nx_fetch_any.nx nx_fetch_any_gate.nx nx_nist_ingest.nx nx_nvd_ingest.nx nx_research_engine.nx

imports: nx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_https_get_spoof.nx

imported by: nx_fetch_any_gate.nxnx_nist_ingest.nxnx_nvd_ingest.nxnx_research_engine.nx

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

main fa_puts sys_write 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

structs

none

consts

30const FA_MAGIC_4194304: i64 = 4194304
31const FA_MAGIC_8388608: i64 = 8388608
32const FA_MAGIC_8192: i64 = 8192
35const FA_MIN_BYTES: i64 = 256

functions

37func fa_puts(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
38func fa_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
47func fa_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: fa_has
50func fa_find(hay: *u8, hl: i64, needle: *u8, nl: i64) -> i64
62func fa_has(hay: *u8, hl: i64, lit: *u8) -> i64
called by 1: fa_challenge calls 2: fa_findfa_slen
68func fa_status(buf: *u8, n: i64) -> i64
called by 2: nx_fetch_anymain calls 1: fa_find
82func fa_challenge(buf: *u8, n: i64) -> i64
called by 3: fa_is_realnx_fetch_anymain calls 1: fa_has
94func fa_is_real(status: i64, buf: *u8, n: i64) -> i64
called by 2: nx_fetch_anymain calls 1: fa_challenge
103func fa_body_off(buf: *u8, n: i64) -> i64
called by 2: fa_to_bodymain calls 1: fa_find
111func fa_to_body(buf: *u8, n: i64) -> i64
called by 1: main calls 1: fa_body_off
120func fa_log(att: *u8, off: i64, cap: i64, s: *u8) -> i64
called by 1: nx_fetch_any
126func fa_logn(att: *u8, off: i64, cap: i64, v: i64) -> i64
called by 1: nx_fetch_any calls 1: sys_mmap
141func nx_fetch_any(url: *u8, store: *TrustStore, out: *u8, out_cap: i64, max_hops: i64, out_status: *i64,
185func main(argc: i64, argv: *i64) -> i64