HLE: resolve the local machine name to loopback #1999

Open
necrobytes wants to merge 2 commits from upstream-pr/2001 into main
necrobytes commented 2026-11-25 02:38:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by necrobytes on 2026-11-25T02:38:34Z.


A title could call Winsock’s gethostname() successfully, then get WSAHOST_NOT_FOUND when it passed that same name to getaddrinfo(). This fixes VIC-BT-039 in #1249.

The title still sees the machine’s own hostname. When a forward lookup matches that name, the HLE passes a static localhost string to Winsock. This covers the ANSI, Unicode, extended and legacy lookup APIs, including asynchronous requests. The original machine name never goes to the address resolver, and the change adds no names to the connection allowlist.

The Windows regression reads the real ANSI and Unicode hostnames, resolves them through the HLE, and checks every returned address for loopback. It also checks the legacy lookup with a case-varied ASCII name and verifies that an unrelated name still returns WSAHOST_NOT_FOUND.

I ran the Windows regression under Wine. On upstream 940d32f the first lookup returned 11001. With the patch, the regression and the existing blocked-name test both passed. The remaining network test fails on both revisions because Wine lacks WSAConnectByList. Native Linux compilation also stops on both revisions at victory-gpu’s missing host_resource. Strict Windows MSVC-target Clippy passed for all victory-hle targets and features. The asset-policy check passed for all 182 tracked files.

Claim in #1633

Implemented and tested with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6595919934 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001). Originally posted by [necrobytes](https://github.com/necrobytes) on 2026-11-25T02:38:34Z. --- A title could call Winsock’s `gethostname()` successfully, then get `WSAHOST_NOT_FOUND` when it passed that same name to `getaddrinfo()`. This fixes `VIC-BT-039` in #1249. The title still sees the machine’s own hostname. When a forward lookup matches that name, the HLE passes a static `localhost` string to Winsock. This covers the ANSI, Unicode, extended and legacy lookup APIs, including asynchronous requests. The original machine name never goes to the address resolver, and the change adds no names to the connection allowlist. The Windows regression reads the real ANSI and Unicode hostnames, resolves them through the HLE, and checks every returned address for loopback. It also checks the legacy lookup with a case-varied ASCII name and verifies that an unrelated name still returns `WSAHOST_NOT_FOUND`. I ran the Windows regression under Wine. On upstream `940d32f` the first lookup returned `11001`. With the patch, the regression and the existing blocked-name test both passed. The remaining network test fails on both revisions because Wine lacks `WSAConnectByList`. Native Linux compilation also stops on both revisions at `victory-gpu`’s missing `host_resource`. Strict Windows MSVC-target Clippy passed for all `victory-hle` targets and features. The asset-policy check passed for all 182 tracked files. [Claim in #1633](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7150685096) Implemented and tested with Codex.
catminou4 commented 2026-11-25 03:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T02:48:47Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

Resolve the local machine name to loopback — fixes services that bind/connect by hostname in sandboxed/network-restricted environments; small, safe.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051088512 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001#pullrequestreview-6051088512). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T02:48:47Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. Resolve the local machine name to loopback — fixes services that bind/connect by hostname in sandboxed/network-restricted environments; small, safe.
DesertGamer commented 2026-11-25 03:03:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:40:12Z.


`### VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.`

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151023978 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001#issuecomment-7151023978). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-25T02:40:12Z. --- `### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*`
Calvix2k commented 2026-11-25 03:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T02:47:04Z.


Independent run on Windows 10 19045: cargo test -p victory-hle --lib — 144 passed, 0 failed, including your new hostname round-trip test. Nothing else in victory-hle regressed here.

On the change: resolving the machine name to 127.0.0.1 keeps the title’s own hostname working while not leaking DNS, which is the right side of the offline rule; the test that an unrelated name still fails is the part worth keeping.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151182851 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001#issuecomment-7151182851). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T02:47:04Z. --- Independent run on Windows 10 19045: `cargo test -p victory-hle --lib` — **144 passed, 0 failed**, including your new `hostname` round-trip test. Nothing else in `victory-hle` regressed here. On the change: resolving the machine name to `127.0.0.1` keeps the title’s own hostname working while not leaking DNS, which is the right side of the offline rule; the test that an unrelated name still fails is the part worth keeping.
AgneyaK commented 2026-11-25 03:03:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T02:52:06Z.


Native Windows result, since the description's runs were under Wine. Windows 11 26300, Rust 1.98.1 MSVC, b478965 merged onto main 940d32f.

Unit tests: cargo test -p victory-hle --lib -- net passes all 3 net tests, including only_loopback_is_reachable, the one that fails under Wine for lack of WSAConnectByList. Also passing: the_local_hostname_resolves_only_to_loopback and blocked_name_lookups_clear_the_result.

In the title (1.0.2.1, Series X profile, diag build): an RTX 3050 laptop, so the tree also has #1763 (NVIDIA stops at boot without it) and a local adapter patch. One 55 s run each from launch through the boot screens, with VICTORY_LOG=victory_hle::modules::net=debug,info:

net log lines what they are
without this PR 1 network name lookup blocked destination=<this machine's name>, about 60 s in
with this PR 0 the lookup of the machine's own name no longer fails (the PR doesn't log the loopback mapping)

So the title does look up its own hostname during boot, and that's the only name lookup it makes in that window. With the PR it gets an answer, and nothing else in the net module fired: no blocked connections, no other lookups. Frames reached in 55 s: 613 vs 627, the same within noise.

Not tested: past the first ~55 s (this laptop runs out of memory in the story load), and whether the title then connects to the loopback address it got.

AI use: Claude Code (Claude Opus 5.5) ran these builds and wrote this; the results are from the runs described. The machine name is left out on purpose.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151290881 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001#issuecomment-7151290881). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-25T02:52:06Z. --- Native Windows result, since the description's runs were under Wine. Windows 11 26300, Rust 1.98.1 MSVC, `b478965` merged onto `main` `940d32f`. **Unit tests:** `cargo test -p victory-hle --lib -- net` passes all 3 `net` tests, including `only_loopback_is_reachable`, the one that fails under Wine for lack of `WSAConnectByList`. Also passing: `the_local_hostname_resolves_only_to_loopback` and `blocked_name_lookups_clear_the_result`. **In the title (1.0.2.1, Series X profile, diag build):** an RTX 3050 laptop, so the tree also has #1763 (NVIDIA stops at boot without it) and a local adapter patch. One 55 s run each from launch through the boot screens, with `VICTORY_LOG=victory_hle::modules::net=debug,info`: | | `net` log lines | what they are | |---|---|---| | without this PR | 1 | `network name lookup blocked destination=<this machine's name>`, about 60 s in | | with this PR | 0 | the lookup of the machine's own name no longer fails (the PR doesn't log the loopback mapping) | So the title does look up its own hostname during boot, and that's the only name lookup it makes in that window. With the PR it gets an answer, and nothing else in the `net` module fired: no blocked connections, no other lookups. Frames reached in 55 s: 613 vs 627, the same within noise. Not tested: past the first ~55 s (this laptop runs out of memory in the story load), and whether the title then connects to the loopback address it got. AI use: Claude Code (Claude Opus 5.5) ran these builds and wrote this; the results are from the runs described. The machine name is left out on purpose.
Marvisak commented 2026-11-25 10:07:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:17:05Z.


Automated triage for the maintainers.

Needs work: this needs the maintainer's decision (unchanged). The new head eec4037 is only a merge of main. The PR's own diff is identical to the previously triaged head b478965.

The substance is the same. In crates/victory-hle/src/modules/net.rs, resolvable becomes lookup_node/lookup_node_a/lookup_node_w. A forward lookup of the machine's own hostname now succeeds: the name is replaced with the literal localhost before Winsock sees it, in getaddrinfo, GetAddrInfoW, GetAddrInfoEx{A,W}, gethostbyname and WSAAsyncGetHostByName. The real name never reaches a resolver, the connect checks are unchanged, and other names still fail with WSAHOST_NOT_FOUND. By my reading the title still gets only loopback answers and stays offline. The native Windows run in the thread shows the title does look up its own name at boot (#1249, VIC-BT-039).

It still needs the maintainer for two reasons:

  • It relaxes the name-lookup guard in the net module, even if only to a loopback answer.
  • It adds a [target.'cfg(windows)'.dev-dependencies] windows-sys entry to crates/victory-hle/Cargo.toml.

If the maintainer accepts this relaxation, the code looks sound to me.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158123669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2001#issuecomment-7158123669). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:17:05Z. --- <!-- victory-triage v1 head=eec4037d1884180408fbfbd6e8d1c71ad8d31817 verdict=needs-work at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. **Needs work: this needs the maintainer's decision (unchanged).** The new head `eec4037` is only a merge of `main`. The PR's own diff is identical to the previously triaged head `b478965`. The substance is the same. In `crates/victory-hle/src/modules/net.rs`, `resolvable` becomes `lookup_node`/`lookup_node_a`/`lookup_node_w`. A forward lookup of the machine's own hostname now succeeds: the name is replaced with the literal `localhost` before Winsock sees it, in `getaddrinfo`, `GetAddrInfoW`, `GetAddrInfoEx{A,W}`, `gethostbyname` and `WSAAsyncGetHostByName`. The real name never reaches a resolver, the connect checks are unchanged, and other names still fail with `WSAHOST_NOT_FOUND`. By my reading the title still gets only loopback answers and stays offline. The native Windows run in the thread shows the title does look up its own name at boot (#1249, `VIC-BT-039`). It still needs the maintainer for two reasons: - It relaxes the name-lookup guard in the `net` module, even if only to a loopback answer. - It adds a `[target.'cfg(windows)'.dev-dependencies]` `windows-sys` entry to `crates/victory-hle/Cargo.toml`. If the maintainer accepts this relaxation, the code looks sound to me. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2001:upstream-pr/2001'
git switch 'upstream-pr/2001'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2001'
git switch 'upstream-pr/2001'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2001'
git switch 'upstream-pr/2001'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2001'
git switch 'main'
git merge --squash 'upstream-pr/2001'
git switch 'main'
git merge --ff-only 'upstream-pr/2001'
git switch 'main'
git merge 'upstream-pr/2001'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1999
No description provided.