code wiki / (root) / nx_https_url_connect.nx

nx_https_url_connect.nx

buildroot/runtime/nx_https_url_connect.nx

9210 B220 linesdepth 5pulls 10 transitivereach 495 importersview sourcekind tooltopic https
docsdependenciesstructsconstsfunctions

about

nx_https_url_connect.nx -- step 2 of the nx_https_client orchestrator wiring arc. Takes an already-validated NxHttpsTarget (from nx_https_url_for_fetch step 1) PLUS the URL buffer it was parsed from, resolves the host via DNS, builds a sockaddr, and TCP-connects to host:port. Returns a connected file descriptor ready for the TLS handshake (step 3). Composes 3 shipped primitives: nx_https_url_for_fetch (c0117caa) -- already-parsed target nx_dns_resolve_default -- hostname -> packed IPv4 sys_socket / sys_connect / sys_close -- BSD socket primitives Public API: nx_https_url_connect(target, url_buf, now_unix, out_fd) -> verdict nx_https_connect_verdict_is_valid(v) -> 0|1 Why the url_buf parameter is separate: NxHttpsTarget.url.host_off is an OFFSET into the URL string the caller originally passed to nx_https_url_for_fetch. This primitive needs the resolved host bytes, so the caller must pass the same url_buf. An alternative API would have NxHttpsTarget carry the url_buf pointer itself -- that's a refactor for a future commit; for now we keep the explicit parameter to avoid breaking step 1's existing API. Sealed verdict enum: NX_HTTPS_CONNECT_OK socket connected; *out_fd valid NX_HTTPS_CONNECT_DNS_FAIL DNS resolution returned no IPv4 NX_HTTPS_CONNECT_SOCKET_FAIL sys_socket returned negative NX_HTTPS_CONNECT_CONNECT_FAIL sys_connect returned negative On any non-OK return, *out_fd is set to -1 and any socket already allocated is closed. Callers don't need to clean up on failure verdicts. Per Cardinals 9 (single-responsibility -- step 2 only; TLS + HTTP are separate primitives), 12 (defensive at boundaries -- close fd on every failure path to avoid descriptor leaks), 23

dependencies 4 imports · 86 importers

nx_syscalls.nx nx_connect.nx nx_dns_resolve_a_record.nx nx_https_url_for_fetch.nx nx_https_url_connect.nx _dlr_probe.nx _h2_fetch_google.nx _h2_fetch_rumble.nx _h2_probe_imgsearch.nx _h2_probe_imgsearch_ua.nx _h2_reach_probe.nx nx_acme_directory_live.nx nx_acme_directory_live_real_ca_tes nx_acme_http.nx nx_app_monitor.nx

diagram shows first 10 each side; +0 more imports, +76 more importers in the complete lists below.

imports: nx_syscalls.nxnx_connect.nxnx_dns_resolve_a_record.nxnx_https_url_for_fetch.nx

imported by: _dlr_probe.nx_h2_fetch_google.nx_h2_fetch_rumble.nx_h2_probe_imgsearch.nx_h2_probe_imgsearch_ua.nx_h2_reach_probe.nxnx_acme_directory_live.nxnx_acme_directory_live_real_ca_test.nxnx_acme_http.nxnx_app_monitor.nxnx_aw_verify_gate.nxnx_browser_image_demo_test.nxnx_browser_own_site_live_test.nxnx_browser_page_demo_test.nxnx_cad_verify_gate.nxnx_chrome_fetch_probe.nxnx_connect_live_verify.nxnx_crew_live_verify.nxnx_dev_api_build_probe.nxnx_edge_watchdog.nxnx_fetch_jellyfin_test.nxnx_funcheck.nxnx_gallery_auth_research_fetch.nxnx_hf_probe.nxnx_hifigan_stream_fetch.nxnx_hls_live_probe.nxnx_https_fetch.nxnx_https_fetch_file.nxnx_https_fetch_follow.nxnx_https_fetch_lib.nxnx_https_get.nxnx_https_get_cli.nxnx_https_get_cli2.nxnx_https_get_live_demo_test.nxnx_https_get_live_google_test.nxnx_https_get_live_real_ca_test.nxnx_https_ka_probe.nxnx_https_url_connect_test.nxnx_hub_lib_verify_gate.nxnx_hub_verify_gate.nxnx_iot_fetch_probe.nxnx_iot_verify_gate.nxnx_lib_fetch.nxnx_lib_fetch_cookie.nxnx_library_fetch.nxnx_login_e2e_probe.nxnx_mcp_call.nxnx_mgmt_client.nxnx_model_fetch.nxnx_night_fetch_test.nxnx_nist_verify_gate.nxnx_office_live_verify.nxnx_onsite_frontier_fetch.nxnx_onsite_research_fetch.nxnx_orch_verify_gate.nxnx_page_verify.nxnx_porkbun_ping_probe.nxnx_research_fetch_wiki_test.nxnx_research_ka.nxnx_room_live_gate.nxnx_room_perf_gate.nxnx_scilib_verify_gate.nxnx_sclass_ux_research_fetch.nxnx_semantic_research_fetch.nxnx_site_probe.nxnx_sovgit_push.nxnx_survey_live_verify.nxnx_tls12_client.nxnx_tls12_handshake_gate.nxnx_tls12_mutant.nxnx_tls12_probe.nxnx_tls12_probe_test.nxnx_tls12_req.nxnx_tls13_ch_compat_test.nxnx_tls13_recv_hs_diff_test.nxnx_tls13_recv_hs_probe_test.nxnx_tls13_sh_probe_test.nxnx_url_probe.nxnx_url_truth_gate.nxnx_uxf_fetch_avro.nxnx_uxf_fetch_protobuf.nxnx_web_crawl_breadth.nxnx_web_crawl_index.nxnx_webpub_fetch.nxnx_ws_client_session.nxnx_zerodt_fetch.nx

structs

none

consts

57const NX_MAGIC_65535: i64 = 65535
59const NX_HTTPS_CONNECT_OK: i64 = 1
60const NX_HTTPS_CONNECT_DNS_FAIL: i64 = 2
61const NX_HTTPS_CONNECT_SOCKET_FAIL: i64 = 3
62const NX_HTTPS_CONNECT_CONNECT_FAIL: i64 = 4
63const NX_HTTPS_CONNECT_VERDICT_N: i64 = 5
65const NX_HTTPS_AF_INET: i64 = 2
66const NX_HTTPS_SOCK_STREAM: i64 = 1

functions

68func nx_https_connect_verdict_is_valid(v: i64) -> i64
called by 1: main
82func nx_https_build_sockaddr(out: *u8, ipv4_packed: i64, port: i64) -> i64
107func nx_https_parse_ipport(s: *u8, ip_out: *i64, port_out: *i64) -> i64
138func nx_https_connect_override_set(spec: *u8) -> i64
150func nx_https_url_connect(
218func main() -> i64