fix: #811 — net.isIP/isIPv4/isIPv6 + auto-select-family defaults#818
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
net.isIP,net.isIPv4,net.isIPv6, and the four*DefaultAutoSelectFamily*accessors in perry-ext-net.NATIVE_MODULE_TABLE(NA_STR/NA_F64 → NR_F64, since the runtime fns return already-NaN-boxed JSValue bits) and adds matchingperry-api-manifestentries so the Compile-time error for unimplemented Node / Web APIs #463 strict-API gate accepts them.is_ipv6_strrejects bracketed and zone-id (%) forms to match Node'snet.isIPv6.autoSelectFamilyAttemptTimeoutis 500ms — Node v20+ default; byte-for-byte parity required this.Test plan
isIP 127.0.0.1: 4,isIP ::1: 6,isIPv4: true,isIPv6: true,getDefaultAutoSelectFamily: true).setDefault*(getDefault*())runs without error, attempt-timeout default = 500.cargo build --release -p perry-ext-net -p perrysucceeds.Notes
net.BlockList,net.SocketAddress,net.Serverclass — those are the larger socket-layer gap fromtest_parity_net.ts. Only the pure string/global-flag helpers from the issue are implemented here.Closes #811.