Skip to content

fix: #811 — net.isIP/isIPv4/isIPv6 + auto-select-family defaults#818

Merged
proggeramlug merged 2 commits into
mainfrom
worktree-fix-811-net-isip
May 16, 2026
Merged

fix: #811 — net.isIP/isIPv4/isIPv6 + auto-select-family defaults#818
proggeramlug merged 2 commits into
mainfrom
worktree-fix-811-net-isip

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • Implements net.isIP, net.isIPv4, net.isIPv6, and the four *DefaultAutoSelectFamily* accessors in perry-ext-net.
  • Wires them into NATIVE_MODULE_TABLE (NA_STR/NA_F64 → NR_F64, since the runtime fns return already-NaN-boxed JSValue bits) and adds matching perry-api-manifest entries so the Compile-time error for unimplemented Node / Web APIs #463 strict-API gate accepts them.
  • is_ipv6_str rejects bracketed and zone-id (%) forms to match Node's net.isIPv6.
  • Default autoSelectFamilyAttemptTimeout is 500ms — Node v20+ default; byte-for-byte parity required this.

Test plan

  • 6-line repro from the issue matches Node (isIP 127.0.0.1: 4, isIP ::1: 6, isIPv4: true, isIPv6: true, getDefaultAutoSelectFamily: true).
  • Extended round-trip — setDefault*(getDefault*()) runs without error, attempt-timeout default = 500.
  • cargo build --release -p perry-ext-net -p perry succeeds.

Notes

  • Out of scope: net.BlockList, net.SocketAddress, net.Server class — those are the larger socket-layer gap from test_parity_net.ts. Only the pure string/global-flag helpers from the issue are implemented here.

Closes #811.

`net.isIP`, `net.isIPv4`, `net.isIPv6`, `net.getDefaultAutoSelectFamily`,
`net.setDefaultAutoSelectFamily`, `net.getDefaultAutoSelectFamilyAttemptTimeout`,
and `net.setDefaultAutoSelectFamilyAttemptTimeout` previously returned
`undefined` because they had no NATIVE_MODULE_TABLE entries and no
perry-ext-net runtime implementations.

Adds:

- perry-ext-net runtime fns:
  - `js_net_is_ip` — returns 0/4/6 via `std::net::Ipv4Addr` /
    `std::net::Ipv6Addr` parse. `is_ipv6_str` rejects bracketed and
    zone-id (`%`) forms to match Node.
  - `js_net_is_ipv4` / `js_net_is_ipv6` — boolean.
  - `js_net_get_default_auto_select_family` /
    `js_net_set_default_auto_select_family` — read/write
    `AUTO_SELECT_FAMILY` (AtomicBool, default `true`).
  - `js_net_get_default_auto_select_family_attempt_timeout` /
    `js_net_set_default_auto_select_family_attempt_timeout` — read/write
    `AUTO_SELECT_FAMILY_ATTEMPT_TIMEOUT_MS` (AtomicI32, default 500ms
    to match Node v20+).
- NATIVE_MODULE_TABLE entries dispatch `net.<method>(args)` to the new
  runtime fns via the standard NA_STR/NA_F64 + NR_F64 protocol (return
  values are already NaN-boxed JSValues).
- perry-api-manifest entries flip the #463 strict-API gate from "not
  implemented" to "supported".

6-line repro from the issue now matches Node byte-for-byte; full
auto-select-family round-trip works.
cargo fmt --all and ./scripts/regen_api_docs.sh — fixes the lint and
api-docs-drift checks on PR #818.
@proggeramlug proggeramlug merged commit e18cdb0 into main May 16, 2026
9 checks passed
@proggeramlug proggeramlug deleted the worktree-fix-811-net-isip branch May 16, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

net.isIP / net.isIPv4 / net.isIPv6 / net.getDefaultAutoSelectFamily return undefined

1 participant