[PR #3427] fix: handle dual-stack WireGuard addresses and IPv6 endpoints #3295

Open
opened 2026-11-07 17:59:01 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3427
Author: @icntswm
Created: 11/6/2026
Status: 🔄 Open

Base: dev ← Head: fix/macos-dual-stack-endpoints


📝 Commits (3)

  • 42fd628 fix(macos): handle dual-stack WireGuard addresses
  • d887ec6 fix(apple): bracket IPv6 WireGuard endpoints in network extensions
  • 775526b fix(wireguard): allow IPv6 transport through the kill switch

📊 Changes

14 files changed (+286 additions, -28 deletions)

View changed files

📝 client/daemon/interfaceconfig.cpp (+4 -8)
➕ client/daemon/wireguardaddressutils.h (+41 -0)
📝 client/mozilla/localsocketcontroller.cpp (+18 -8)
📝 client/platforms/ios/WGConfig.swift (+7 -1)
📝 client/platforms/linux/daemon/linuxfirewall.cpp (+23 -1)
📝 client/platforms/linux/daemon/linuxfirewall.h (+3 -0)
📝 client/platforms/linux/daemon/wireguardutilslinux.cpp (+4 -1)
📝 client/platforms/macos/daemon/macosfirewall.h (+16 -0)
📝 client/platforms/macos/daemon/wireguardutilsmacos.cpp (+11 -9)
📝 client/tests/CMakeLists.txt (+8 -0)
➕ client/tests/appleWireguardAddresses/CMakeLists.txt (+22 -0)
➕ client/tests/appleWireguardAddresses/testWGConfig.swift (+38 -0)
➕ client/tests/wireguardAddresses/CMakeLists.txt (+14 -0)
➕ client/tests/wireguardAddresses/testWireguardAddresses.cpp (+77 -0)

📄 Description

WireGuard/AmneziaWG profiles containing both IPv4 and IPv6 interface addresses are passed to the desktop daemon as a single IPv4 address. On macOS this fails with Failed to set IPv4: Destination address required. Resolved IPv6 server addresses are also assigned to IPv4 fields, and the macOS backend emits an unbracketed IPv6 endpoint, failing with IPC error -22.

The iOS/macOS Network Extension has a separate config serializer which also emits IPv6 endpoints without brackets, causing WireGuardKit to reject the generated config before starting the tunnel.

This change:

  • Separates interface addresses by family before constructing desktop daemon requests, preserving an explicit IPv6 address and retaining the existing fallback for IPv4-only profiles.
  • Assigns resolved server addresses and gateways to the correct address-family fields for macOS, Windows and Linux.
  • Formats IPv6 endpoints with brackets in the macOS backend, shared config export, and the iOS/macOS Network Extension serializer.
  • Permits only UDP to the configured IPv6 server address and port through the macOS/Linux kill switch, retaining the default IPv6 block. Linux replaces stale endpoint exceptions while keeping a blocking rule installed.
  • Adds C++ regression tests and Apple serialization tests using the real WireGuardKit endpoint parser.

Validation:

  • 18 Qt Test checks passed, including dual-stack address order, invalid/duplicate addresses, IPv4, IPv6, scoped IPv6, NAT64 and hostname endpoints, plus narrow IPv6 firewall exceptions and invalid endpoint/port rejection.
  • 10 Apple config combinations passed (IPv4, IPv6, already bracketed IPv6, NAT64, hostname; IPv4-only and dual-stack interface addresses). The parser also rejects the original malformed IPv6 endpoint.
  • Changed Swift sources type-checked against the iPhoneOS SDK for arm64.
  • Windows/Linux endpoint and interface consumers were reviewed: they already support separate address-family fields, and now receive them correctly from the shared controller. The changed Linux firewall translation unit also compiled with Qt on macOS; native Linux integration was not run.
  • Android was reviewed: it already splits interface addresses and brackets IPv6 endpoints, so no Android change is needed.
  • Full macOS arm64 application, daemon and test targets built successfully.
  • Full CTest run: 32/33 suites passed. OpenSSLLibraryTest fails its Qt/app version equality assertion because Homebrew Qt uses OpenSSL 4 while Conan dependencies use OpenSSL 3. A separate HTTPS probe linking the same Qt and Conan libraries completed TLS verification and returned HTTP 200.
  • Installed the macOS app and updated privileged service, then verified a real connection using a hostname resolving to IPv6 with the kill switch enabled. The UI reports Connected, the separate CLI tunnel is stopped, the default IPv4 route uses the app tunnel, and an HTTPS request through it returned HTTP 200.
  • Ordinary IPv6 Internet traffic remains blocked by the existing kill-switch policy; the new exception is limited to the VPN transport.
  • Windows/Linux/Android application builds and a real-device iOS connection have not been run locally.

Fixes #1630.
Fixes #3374.


🔄 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/amnezia-vpn/amnezia-client/pull/3427 **Author:** [@icntswm](https://github.com/icntswm) **Created:** 11/6/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/macos-dual-stack-endpoints` --- ### 📝 Commits (3) - [`42fd628`](https://github.com/amnezia-vpn/amnezia-client/commit/42fd628843bc52ee3cde9bd466a46a1fbe07525c) fix(macos): handle dual-stack WireGuard addresses - [`d887ec6`](https://github.com/amnezia-vpn/amnezia-client/commit/d887ec63b39a4c9bf0b48ce947ef3f01618c67de) fix(apple): bracket IPv6 WireGuard endpoints in network extensions - [`775526b`](https://github.com/amnezia-vpn/amnezia-client/commit/775526b1283b3e7152ebbb4b45332b83d418136b) fix(wireguard): allow IPv6 transport through the kill switch ### 📊 Changes **14 files changed** (+286 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `client/daemon/interfaceconfig.cpp` (+4 -8) ➕ `client/daemon/wireguardaddressutils.h` (+41 -0) 📝 `client/mozilla/localsocketcontroller.cpp` (+18 -8) 📝 `client/platforms/ios/WGConfig.swift` (+7 -1) 📝 `client/platforms/linux/daemon/linuxfirewall.cpp` (+23 -1) 📝 `client/platforms/linux/daemon/linuxfirewall.h` (+3 -0) 📝 `client/platforms/linux/daemon/wireguardutilslinux.cpp` (+4 -1) 📝 `client/platforms/macos/daemon/macosfirewall.h` (+16 -0) 📝 `client/platforms/macos/daemon/wireguardutilsmacos.cpp` (+11 -9) 📝 `client/tests/CMakeLists.txt` (+8 -0) ➕ `client/tests/appleWireguardAddresses/CMakeLists.txt` (+22 -0) ➕ `client/tests/appleWireguardAddresses/testWGConfig.swift` (+38 -0) ➕ `client/tests/wireguardAddresses/CMakeLists.txt` (+14 -0) ➕ `client/tests/wireguardAddresses/testWireguardAddresses.cpp` (+77 -0) </details> ### 📄 Description WireGuard/AmneziaWG profiles containing both IPv4 and IPv6 interface addresses are passed to the desktop daemon as a single IPv4 address. On macOS this fails with `Failed to set IPv4: Destination address required`. Resolved IPv6 server addresses are also assigned to IPv4 fields, and the macOS backend emits an unbracketed IPv6 endpoint, failing with IPC error -22. The iOS/macOS Network Extension has a separate config serializer which also emits IPv6 endpoints without brackets, causing WireGuardKit to reject the generated config before starting the tunnel. This change: - Separates interface addresses by family before constructing desktop daemon requests, preserving an explicit IPv6 address and retaining the existing fallback for IPv4-only profiles. - Assigns resolved server addresses and gateways to the correct address-family fields for macOS, Windows and Linux. - Formats IPv6 endpoints with brackets in the macOS backend, shared config export, and the iOS/macOS Network Extension serializer. - Permits only UDP to the configured IPv6 server address and port through the macOS/Linux kill switch, retaining the default IPv6 block. Linux replaces stale endpoint exceptions while keeping a blocking rule installed. - Adds C++ regression tests and Apple serialization tests using the real WireGuardKit endpoint parser. Validation: - 18 Qt Test checks passed, including dual-stack address order, invalid/duplicate addresses, IPv4, IPv6, scoped IPv6, NAT64 and hostname endpoints, plus narrow IPv6 firewall exceptions and invalid endpoint/port rejection. - 10 Apple config combinations passed (IPv4, IPv6, already bracketed IPv6, NAT64, hostname; IPv4-only and dual-stack interface addresses). The parser also rejects the original malformed IPv6 endpoint. - Changed Swift sources type-checked against the iPhoneOS SDK for arm64. - Windows/Linux endpoint and interface consumers were reviewed: they already support separate address-family fields, and now receive them correctly from the shared controller. The changed Linux firewall translation unit also compiled with Qt on macOS; native Linux integration was not run. - Android was reviewed: it already splits interface addresses and brackets IPv6 endpoints, so no Android change is needed. - Full macOS arm64 application, daemon and test targets built successfully. - Full CTest run: 32/33 suites passed. OpenSSLLibraryTest fails its Qt/app version equality assertion because Homebrew Qt uses OpenSSL 4 while Conan dependencies use OpenSSL 3. A separate HTTPS probe linking the same Qt and Conan libraries completed TLS verification and returned HTTP 200. - Installed the macOS app and updated privileged service, then verified a real connection using a hostname resolving to IPv6 with the kill switch enabled. The UI reports Connected, the separate CLI tunnel is stopped, the default IPv4 route uses the app tunnel, and an HTTPS request through it returned HTTP 200. - Ordinary IPv6 Internet traffic remains blocked by the existing kill-switch policy; the new exception is limited to the VPN transport. - Windows/Linux/Android application builds and a real-device iOS connection have not been run locally. Fixes #1630. Fixes #3374. --- <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
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
amnezia-vpn/amnezia-client#3295
No description provided.