HLE net: classify bracketed IPv6 literals as IP literals in reachable_name #3070

Open
github-bot wants to merge 2 commits from github-bot/gh-3070 into main AGit
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 06:17 UTC · original
Dukestar69:fix/net-getnameinfo-and-bracketed-ipv6 → main · +47 −3 · 1 files · 2 commits · open

Summary

Classifies bracketed IPv6 literals (such as [2001:db8::1]) consistently as IP literals in reachable_name so blocked non-loopback bracketed IPv6 connects report WSAENETUNREACH instead of WSAHOST_NOT_FOUND, and tightens bracket stripping in loopback_name to match only a single surrounding [...] pair.

Why

loopback_name in crates/victory-hle/src/modules/net.rs already strips brackets around IPv6 literals ([::1]), but reachable_name immediately below called name.parse::<IpAddr>() on the unstripped string. As a result, a blocked connect to [2001:db8::1] set WSAHOST_NOT_FOUND (11001) instead of WSAENETUNREACH (10051). Using a shared bare_host helper (strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(name)) fixes reachable_name and also avoids accepting malformed/unmatched brackets like [::1 or [[::1]] in loopback_name.

Verification

  • Added unit test modules::net::tests::bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found:
    • Failed on 63bcca4 (left: 11001, right: 10051).
    • Passes with fix.
  • cargo test -p victory-hle net::tests: 3 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 06:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070) `Dukestar69:fix/net-getnameinfo-and-bracketed-ipv6` → `main` · +47 −3 · 1 files · 2 commits · open ## Summary Classifies bracketed IPv6 literals (such as `[2001:db8::1]`) consistently as IP literals in `reachable_name` so blocked non-loopback bracketed IPv6 connects report `WSAENETUNREACH` instead of `WSAHOST_NOT_FOUND`, and tightens bracket stripping in `loopback_name` to match only a single surrounding `[...]` pair. ### Why `loopback_name` in `crates/victory-hle/src/modules/net.rs` already strips brackets around IPv6 literals (`[::1]`), but `reachable_name` immediately below called `name.parse::<IpAddr>()` on the unstripped string. As a result, a blocked connect to `[2001:db8::1]` set `WSAHOST_NOT_FOUND` (11001) instead of `WSAENETUNREACH` (10051). Using a shared `bare_host` helper (`strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(name)`) fixes `reachable_name` and also avoids accepting malformed/unmatched brackets like `[::1` or `[[::1]]` in `loopback_name`. ### Verification - Added unit test `modules::net::tests::bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found`: - Failed on `63bcca4` (`left: 11001, right: 10051`). - Passes with fix. - `cargo test -p victory-hle net::tests`: 3 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:28:03 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 06:31 UTC · original · approved these changes

Verified: bare_host strips exactly one matched bracket pair, so [::1 and ::1 no longer collapse to parseable literals; reachable_name now classifies bracketed literals as IP literals -> WSAENETUNREACH instead of HOST_NOT_FOUND. Test covers all four bracket shapes.

**@⁠kotekompotek** on GitHub · 2026-11-26 06:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6069530310) · **approved these changes** Verified: bare_host strips exactly one matched bracket pair, so [::1 and [[::1]] no longer collapse to parseable literals; reachable_name now classifies bracketed literals as IP literals -> WSAENETUNREACH instead of HOST_NOT_FOUND. Test covers all four bracket shapes.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 08:23 UTC · original

Automated triage for the maintainers.

Verdict: merge candidate. In modules/net.rs, bare_host strips exactly one surrounding [...] pair. loopback_name no longer takes [::1 or [[::1]] for loopback, which only tightens the offline guard: such names were passed to the host before. reachable_name now classes a bracketed literal as an IP literal (WSAENETUNREACH), as the module doc and loopback_name already treat it.

The new test covers both. CI: not run on this head yet (the workflow needs a maintainer's approval for this contributor), so this verdict depends on it passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 08:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070#issuecomment-7186534518) <!-- victory-triage v1 head=64588459a0bb1e9a51fa48db72919ed2645aeb32 verdict=merge-candidate at=2026-11-26T08:18:50Z --> Automated triage for the maintainers. **Verdict: merge candidate.** In `modules/net.rs`, `bare_host` strips exactly one surrounding `[...]` pair. `loopback_name` no longer takes `[::1` or `[[::1]]` for loopback, which only tightens the offline guard: such names were passed to the host before. `reachable_name` now classes a bracketed literal as an IP literal (`WSAENETUNREACH`), as the module doc and `loopback_name` already treat it. The new test covers both. CI: not run on this head yet (the workflow needs a maintainer's approval for this contributor), so this verdict depends on it passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 08:42 UTC · original · requested changes

Verified 64588459 locally on Windows 11 x64:

  • cargo clippy --all-targets --locked -- -D warnings: clean (1.58s).
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 0 failed (0.34s).
  • cargo test -p victory-hle --locked: 155 passed, 0 failed (153 lib + 1 fidelityfx + 1 no_dll_planting, 5.17s).
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: clean.

bare_host (crates/victory-hle/src/modules/net.rs:135-145, 167-176) fixes the error code for [2001:db8::1] and rejects malformed inputs like [::1 and [[::1]], but because it strips any [...] pair before calling parse::<IpAddr>() and comparing "localhost", it also reclassifies bracketed IPv4 [1.2.3.4] from WSAHOST_NOT_FOUND (on main) to WSAENETUNREACH, and still lets [127.0.0.1] and [localhost] pass loopback_name.

Per RFC 3986 section 3.2.2, only IPv6 literals belong inside [...]. Please restrict bracketed stripping to inputs whose inner slice parses as std::net::Ipv6Addr, and add test cases for [1.2.3.4], [127.0.0.1], and [localhost] (plus ::1], [::1%1], and [2001:db8::1]:443).

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6070869982) · **requested changes** Verified `64588459` locally on Windows 11 x64: - `cargo clippy --all-targets --locked -- -D warnings`: clean (`1.58s`). - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: 1 passed, 0 failed (`0.34s`). - `cargo test -p victory-hle --locked`: 155 passed, 0 failed (`153` lib + `1` fidelityfx + `1` no_dll_planting, `5.17s`). - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: clean. `bare_host` (`crates/victory-hle/src/modules/net.rs:135-145, 167-176`) fixes the error code for `[2001:db8::1]` and rejects malformed inputs like `[::1` and `[[::1]]`, but because it strips any `[...]` pair before calling `parse::<IpAddr>()` and comparing `"localhost"`, it also reclassifies bracketed IPv4 `[1.2.3.4]` from `WSAHOST_NOT_FOUND` (on `main`) to `WSAENETUNREACH`, and still lets `[127.0.0.1]` and `[localhost]` pass `loopback_name`. Per RFC 3986 section 3.2.2, only IPv6 literals belong inside `[...]`. Please restrict bracketed stripping to inputs whose inner slice parses as `std::net::Ipv6Addr`, and add test cases for `[1.2.3.4]`, `[127.0.0.1]`, and `[localhost]` (plus `::1]`, `[::1%1]`, and `[2001:db8::1]:443`).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:31 UTC · original

Good catch @⁠fuzeofficlal, thanks! Fixed in 09257ae:

  • Replaced bare_host with parse_ip_literal so [...] stripping only accepts inner slices that parse as std::net::Ipv6Addr (per RFC 3986 section 3.2.2).
  • [1.2.3.4], [127.0.0.1], [localhost], ::1], [::1%1], and [2001:db8::1]:443 are no longer treated as loopback or IP literals and return WSAHOST_NOT_FOUND; all added to bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found.
  • Re-verified rustfmt --edition 2024 --check, cargo test -p victory-hle --locked --lib modules::net:: (3/3 passed), cargo clippy -p victory-hle --all-targets --locked -- -D warnings (clean), and cargo xtask policy (191 files ok).

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070#issuecomment-7188099800) Good catch @⁠fuzeofficlal, thanks! Fixed in `09257ae`: - Replaced `bare_host` with `parse_ip_literal` so `[...]` stripping only accepts inner slices that parse as `std::net::Ipv6Addr` (per RFC 3986 section 3.2.2). - `[1.2.3.4]`, `[127.0.0.1]`, `[localhost]`, `::1]`, `[::1%1]`, and `[2001:db8::1]:443` are no longer treated as loopback or IP literals and return `WSAHOST_NOT_FOUND`; all added to `bracketed_ipv6_literal_fails_with_netunreach_not_host_not_found`. - Re-verified `rustfmt --edition 2024 --check`, `cargo test -p victory-hle --locked --lib modules::net::` (3/3 passed), `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (clean), and `cargo xtask policy` (191 files ok). Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:03 UTC · original · approved these changes

parse_ip_literal cleanly resolves the bracket-stripping regression from 64588459. Bracketed IPv4 inputs ([1.2.3.4], [127.0.0.1]), [localhost], [::1%1], [2001:db8::1]:443, and unmatched/nested brackets now fall through to WSAHOST_NOT_FOUND, while valid [2001:db8::1] returns WSAENETUNREACH and [::1] / [::ffff:127.0.0.1] still pass loopback canonicalization.

Verified locally on Windows 11 x64 (09257ae1):

  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs: clean
  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings (default and --all-features): clean
  • cargo test -p victory-hle --lib --locked modules::net::: 3 passed, 0 failed
  • cargo test -p victory-hle --locked: 153 lib + 2 integration tests passed, 0 failed

Optional: adding [::ffff:127.0.0.1] and [] to the test table would round out the boundary matrix.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3070#pullrequestreview-6072052306) · **approved these changes** `parse_ip_literal` cleanly resolves the bracket-stripping regression from `64588459`. Bracketed IPv4 inputs (`[1.2.3.4]`, `[127.0.0.1]`), `[localhost]`, `[::1%1]`, `[2001:db8::1]:443`, and unmatched/nested brackets now fall through to `WSAHOST_NOT_FOUND`, while valid `[2001:db8::1]` returns `WSAENETUNREACH` and `[::1]` / `[::ffff:127.0.0.1]` still pass loopback canonicalization. Verified locally on Windows 11 x64 (`09257ae1`): - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/net.rs`: clean - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `cargo test -p victory-hle --lib --locked modules::net::`: 3 passed, 0 failed - `cargo test -p victory-hle --locked`: 153 lib + 2 integration tests passed, 0 failed Optional: adding `[::ffff:127.0.0.1]` and `[]` to the test table would round out the boundary matrix.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3070/head:github-bot/gh-3070'
git switch 'github-bot/gh-3070'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3070'
git switch 'github-bot/gh-3070'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3070'
git switch 'github-bot/gh-3070'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3070'
git switch 'main'
git merge --squash 'github-bot/gh-3070'
git switch 'main'
git merge --ff-only 'github-bot/gh-3070'
git switch 'main'
git merge 'github-bot/gh-3070'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3070
No description provided.