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

Open
opened 2026-11-26 21:20:33 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2242
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/ws2-connect-by-name-v6


📝 Commits (2)

  • 75bda1d ws2_offline: connect an IPv6-only socket to localhost at ::1 (WS2-CONNECT-BY-NAME-V6)
  • 664a6fc docs: runtime_imports describes the WS2-CONNECT-BY-NAME-V6 behaviour

📊 Changes

3 files changed (+125 additions, -8 deletions)

View changed files

📝 docs/runtime_imports.md (+5 -3)
📝 runtime/shims/ws2_offline.cpp (+26 -4)
📝 runtime/test/ws2_offline_test.cpp (+94 -1)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2242 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ws2-connect-by-name-v6` --- ### 📝 Commits (2) - [`75bda1d`](https://github.com/ubiquitarianism/leonida/commit/75bda1dd706c15e5747fd6fc3852925644d84541) ws2_offline: connect an IPv6-only socket to localhost at ::1 (WS2-CONNECT-BY-NAME-V6) - [`664a6fc`](https://github.com/ubiquitarianism/leonida/commit/664a6fc84a389b265704bf2e4140ef022282867c) docs: runtime_imports describes the WS2-CONNECT-BY-NAME-V6 behaviour ### 📊 Changes **3 files changed** (+125 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/runtime_imports.md` (+5 -3) 📝 `runtime/shims/ws2_offline.cpp` (+26 -4) 📝 `runtime/test/ws2_offline_test.cpp` (+94 -1) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#2248
No description provided.