code wiki / (root) / nx_net_governor.nx

nx_net_governor.nx

buildroot/runtime/nx_net_governor.nx

2847 B70 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic net
docsdependenciesstructsconstsfunctions

about

nx_net_governor.nx -- general network traffic-shaping governor (ISP-safe). module: nishi-core.net.governor depends: nx_syscalls.nx capability: CORE_COMPUTE wired_status: FULLY_WIRED A REUSABLE bits-up primitive for ANY network client that must not look like abuse to an ISP/IDS (which penalize BitTorrent-like / scan-like behavior: many rapid connections to many IPs, sustained high bandwidth, DNS floods). It shapes aggregate activity to a slow, ordinary profile: * GLOBAL min-interval between ANY two requests/connections (low steady rate) * total request/connection cap + total byte budget per run (low volume) * per-transfer size cap (no huge transfers) Pair with: standard ports, GET-only / no-seed, sequential concurrency, DNS caching. Used by the crawler today; the SAME governor will pace the future torrent client (per-peer connection rate + upload/download byte budgets) and any other network worker. Deterministic; the caller passes the clock.

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_net_governor.nx nx_crawl_https.nx nx_crawl_main.nx nx_net_governor_test.nx

imports: nx_syscalls.nx

imported by: nx_crawl_https.nxnx_crawl_main.nxnx_net_governor_test.nx

structs

22struct NxNetGov

consts

31const NX_NETGOV_BYTES: i64 = 56 // 7 * 8

functions

33func nx_gov_init(g: *NxNetGov, min_interval_ms: i64, max_requests: i64,
called by 2: mainmain
46func nx_gov_can_fetch(g: *NxNetGov) -> i64
called by 2: mainmain
54func nx_gov_wait_ms(g: *NxNetGov, now_ms: i64) -> i64
called by 2: mainmain
61func nx_gov_record(g: *NxNetGov, now_ms: i64, bytes: i64) -> i64
called by 2: mainmain
70func nx_gov_resp_cap(g: *NxNetGov) -> i64 { return g.max_resp_bytes }
called by 1: main