ws2_offline: connect an IPv6-only socket to localhost at ::1 (WS2-CONNECT-BY-NAME-V6) #2242

Closed
syfyra wants to merge 2 commits from upstream-pr/2242 into main
syfyra commented 2026-11-26 10:11:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T10:11:06Z.


Claimed in the coordination issue as: WS2-CONNECT-BY-NAME-V6 (claim comment to follow)

What and why

runtime/shims/ws2_offline.cpp hands "localhost" to the host's WSAConnectByNameA/W as the literal 127.0.0.1, so the hosts file is never read. Windows itself resolves the name to ::1 and 127.0.0.1 and tries them in turn. An IPv6 socket with IPV6_V6ONLY set, which is Windows' default for AF_INET6, can reach only ::1: given 127.0.0.1, the host fails with WSAHOST_NOT_FOUND. A title that creates an IPv6 socket and connects it to "localhost" by name therefore always failed under the shim.

Measured with a small probe on Windows 11, with TCP listeners on ::1 and 127.0.0.1 at one port:

socket "localhost" "127.0.0.1" "::1"
AF_INET6, default (V6ONLY) connects to ::1 WSAHOST_NOT_FOUND connects to ::1
AF_INET6, V6ONLY off connects to ::1 connects to ::ffff:127.0.0.1 connects to ::1
AF_INET connects to 127.0.0.1 connects to 127.0.0.1 WSAHOST_NOT_FOUND

The shim now asks the host for the socket's family (SO_PROTOCOL_INFOW) and IPV6_V6ONLY, and gives an IPv6-only socket the ::1 literal. IPv4 and dual-mode IPv6 sockets keep 127.0.0.1, which both reach. A dual-mode socket whose server listens on ::1 only still differs from Windows, as on main: one literal cannot fall back like the host's resolver does.

Tested

Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:

  • ws2_offline_test gets a section 8: WSAConnectByNameA connects an IPv4 socket to localhost at 127.0.0.1, WSAConnectByNameA and WSAConnectByNameW connect a default IPv6 socket at ::1, and a dual-mode IPv6 socket at ::ffff:127.0.0.1 (skipped where IPv6 loopback is unavailable).
    • main: the two IPv6-only checks fail.
    • this branch: 76 of 76 checks pass, in 3 of 3 runs.
  • ctest -j 8 over the 168 CPU tests, with this branch and WS2-UDP-DISCONNECT (#2241) merged: all pass except xmem_no_write_watch, whose split-reader check is the start race #2131 fixes (it passes on its own).
  • scripts/check_no_game_data.py on both files.

Not tested under Wine.

This and WS2-UDP-DISCONNECT (#2241) both change ws2_offline.cpp and its test, in different places; they merge cleanly in either order.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5508043139 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2242). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T10:11:06Z. --- Claimed in the coordination issue as: WS2-CONNECT-BY-NAME-V6 (claim comment to follow) ### What and why `runtime/shims/ws2_offline.cpp` hands "localhost" to the host's `WSAConnectByNameA/W` as the literal `127.0.0.1`, so the hosts file is never read. Windows itself resolves the name to `::1` and `127.0.0.1` and tries them in turn. An IPv6 socket with `IPV6_V6ONLY` set, which is Windows' default for `AF_INET6`, can reach only `::1`: given `127.0.0.1`, the host fails with `WSAHOST_NOT_FOUND`. A title that creates an IPv6 socket and connects it to "localhost" by name therefore always failed under the shim. Measured with a small probe on Windows 11, with TCP listeners on `::1` and `127.0.0.1` at one port: | socket | `"localhost"` | `"127.0.0.1"` | `"::1"` | |---|---|---|---| | `AF_INET6`, default (V6ONLY) | connects to `::1` | `WSAHOST_NOT_FOUND` | connects to `::1` | | `AF_INET6`, V6ONLY off | connects to `::1` | connects to `::ffff:127.0.0.1` | connects to `::1` | | `AF_INET` | connects to `127.0.0.1` | connects to `127.0.0.1` | `WSAHOST_NOT_FOUND` | The shim now asks the host for the socket's family (`SO_PROTOCOL_INFOW`) and `IPV6_V6ONLY`, and gives an IPv6-only socket the `::1` literal. IPv4 and dual-mode IPv6 sockets keep `127.0.0.1`, which both reach. A dual-mode socket whose server listens on `::1` only still differs from Windows, as on `main`: one literal cannot fall back like the host's resolver does. ### Tested Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo: - `ws2_offline_test` gets a section 8: `WSAConnectByNameA` connects an IPv4 socket to localhost at `127.0.0.1`, `WSAConnectByNameA` and `WSAConnectByNameW` connect a default IPv6 socket at `::1`, and a dual-mode IPv6 socket at `::ffff:127.0.0.1` (skipped where IPv6 loopback is unavailable). - `main`: the two IPv6-only checks fail. - this branch: 76 of 76 checks pass, in 3 of 3 runs. - `ctest -j 8` over the 168 CPU tests, with this branch and WS2-UDP-DISCONNECT (#2241) merged: all pass except `xmem_no_write_watch`, whose split-reader check is the start race #2131 fixes (it passes on its own). - `scripts/check_no_game_data.py` on both files. Not tested under Wine. This and WS2-UDP-DISCONNECT (#2241) both change `ws2_offline.cpp` and its test, in different places; they merge cleanly in either order. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-11-26 10:58:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T10:58:26Z.

Review: COMMENTED


Built ws2_offline_test at this head with MSVC on Windows 11. CTest passed with 76 checks and zero failures, including IPv6-only WSAConnectByNameA/W against an ::1 listener and the IPv4 and dual-mode controls. No findings from these checks.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6072924525 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2242#pullrequestreview-6072924525). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T10:58:26Z. **Review:** COMMENTED --- Built `ws2_offline_test` at this head with MSVC on Windows 11. CTest passed with 76 checks and zero failures, including IPv6-only `WSAConnectByNameA/W` against an `::1` listener and the IPv4 and dual-mode controls. No findings from these checks. AI-assisted.
syfyra commented 2026-11-26 14:33:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T14:33:29Z.


Follow-up commit 664a6fc84: the Winsock2 section of docs/runtime_imports.md still said WSAConnectByNameA/W pass localhost as 127.0.0.1. It now says ::1 for an IPv6 socket with IPV6_V6ONLY set and 127.0.0.1 for an IPv4 or dual-mode socket, and its test summary names the new check. Docs only; tests/test_docs_links.py and tests/test_docs_cli_flags.py pass. It merges cleanly with #2241 and #2341, which edit the same section on other lines.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7194991162 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2242#issuecomment-7194991162). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T14:33:29Z. --- Follow-up commit 664a6fc84: the Winsock2 section of `docs/runtime_imports.md` still said `WSAConnectByNameA/W` pass `localhost` as `127.0.0.1`. It now says `::1` for an IPv6 socket with `IPV6_V6ONLY` set and `127.0.0.1` for an IPv4 or dual-mode socket, and its test summary names the new check. Docs only; `tests/test_docs_links.py` and `tests/test_docs_cli_flags.py` pass. It merges cleanly with #2241 and #2341, which edit the same section on other lines.
aslan2142 commented 2026-12-01 12:27:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:27:27Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311158735 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2242#issuecomment-7311158735). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:27:27Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:43:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:43:20Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318102704 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2242#issuecomment-7318102704). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:43:20Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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
ProjectLeonida/mandy!2242
No description provided.