Draft
Conversation
Collaborator
Author
Collaborator
Author
The server now binds to an AF_INET6 socket with IPV6_V6ONLY=0, which accepts both IPv4 and IPv6 connections simultaneously on a single port. On platforms that do not support dual-stack (e.g. OpenBSD), the server falls back to IPv4-only automatically. Changes: - ServerSocket::bind(): try AF_INET6 + IPV6_V6ONLY=0, fall back to AF_INET - ServerSocket::accept(): use sockaddr_storage; strip ::ffff: prefix from IPv4-mapped addresses so downstream code sees plain IPv4 strings - ClientSocket::connect(): use getaddrinfo(AF_UNSPEC) for name resolution, recreating the socket as AF_INET6 when the server address requires it - Ip class: store address as string (addrStr) to support IPv6 literals; byte array kept for backwards-compatible getByte()/Inet_NtoA() paths - getLocalIPAddressList(): replace deprecated gethostbyname() with getaddrinfo(AF_UNSPEC) to also enumerate IPv6 host addresses - getLocalIPAddressListForPlatform(): add AF_INET6 branches (POSIX getifaddrs and Windows GetAdaptersAddresses) to include global-scope IPv6 addresses - Socket::getIp(): replace gethostbyname() with getaddrinfo() - Socket::socketFamily: new member tracking AF_INET / AF_INET6 Note: FTP file-transfer validation (isValidClientType) still uses uint32 and will not work for pure-IPv6 clients; IPv4-mapped connections are unaffected because accept() strips the ::ffff: prefix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two regressions introduced by the IPv6 dual-stack commit:
1. 127.0.0.1 connect broken: the UI appends '_' as a cursor character
to label text (e.g. "127.0.0.1_"). The old Ip(string) constructor
used atoi() which silently ignored the trailing '_', but the new
constructor stored the raw string verbatim so getaddrinfo() received
"127.0.0.1_" and failed. Fix: strip trailing '_' characters in
Ip(const string&) before storing in addrStr.
2. Entering "::1" reverted to "0.0.0.0": the host:port parser in
MenuStateJoinGame split the text on every ':' character, so "::1"
became host="" → Ip("") → 0.0.0.0. Fix: treat strings with more
than one colon as bare IPv6 addresses (no port), and support the
standard [addr]:port bracket notation for IPv6 with a port override.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The LAN discovery callback builds the server entry as "ip:port" and then appends ":port" again, producing "ip:61357:61357" in the label. The old tokenizer handled this by taking parts[0] and parts[1] whenever size > 1. The new IPv6-aware tokenizer treated size > 2 as an IPv6 address and left the string unchanged, so connectToServer() received "ip:61357:61357" as the host. Fix: when splitting on ':', treat the result as IPv4 host:port if the first segment contains a dot (IPv4 addresses always do; IPv6 hex groups never do). This correctly handles the duplicate-port suffix while still treating bare "::1" and "2001:db8::1" as IPv6 addresses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers the cases fixed by the IPv6 dual-stack work: - IPv4 string round-trip - Trailing '_' cursor character is stripped (UI regression fix) - Byte constructor still works - IPv6 string stored and returned unchanged - IPv6 cursor character stripped - Empty string yields 0.0.0.0 Also adds shared_lib/platform to the test directory glob in source/tests/CMakeLists.txt so new platform tests are picked up automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pass argv[1] to runner.run() so that specific suites or individual tests can be selected from the command line, e.g.: ./megaglest_tests SocketTest ./megaglest_tests SocketTest::test_ip_ipv6_cursor_stripped Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the POST_BUILD auto-run with add_test() + enable_testing() so tests only run when explicitly requested. Build scripts gain a -t flag (Linux/macOS) and -run-tests switch (Windows) for local use. CI runs ctest as a dedicated step after each build on Linux (GCC), macOS, and FreeBSD. macOS non-bundle builds now enable tests by default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The scripts cd into build/ before running make, so --test-dir build resolved to build/build/. Drop --test-dir and let ctest run in the current directory instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Five tests in NetworkTest verify the dual-stack server implementation: - server binds and reports isPortBound() - IPv4 client connects and is accepted - accepted socket reports a plain IPv4 address (not ::ffff:...) - IPv6 client connects and is accepted (skipped if no IPv6 dual-stack) - accepted socket reports the IPv6 client address (skipped likewise) Also adds Socket::getSocketFamily() to query the address family in use, used by the tests to detect whether dual-stack is available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Author
|
Test #1: @Jammyjamjamman, on an ipv4 only network, connected to my dual-stack MG server. We played for about 40 minutes with no problems. |
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.




The server now binds to an AF_INET6 socket with IPV6_V6ONLY=0, which accepts both IPv4 and IPv6 connections simultaneously on a single port. On platforms that do not support dual-stack (e.g. OpenBSD), the server falls back to IPv4-only automatically.
Changes:
Note: FTP file-transfer validation (isValidClientType) still uses uint32 and will not work for pure-IPv6 clients; IPv4-mapped connections are unaffected because accept() strips the ::ffff: prefix.