[PR #2825] Fix Windows site split tunneling for multi-address hostnames #2966

Open
opened 2026-10-15 04:06:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/2825
Author: @communism420
Created: 7/12/2026
Status: 🔄 Open

Base: dev ← Head: fix/windows-site-split-tunneling-2797


📝 Commits (2)

  • b6fe2ee fix: resolve Windows site split tunnel addresses
  • 30de098 fix: preserve full tunnel during site resolution

📊 Changes

3 files changed (+312 additions, -36 deletions)

View changed files

📝 client/platforms/windows/daemon/wireguardutilswindows.cpp (+6 -2)
📝 client/vpnConnection.cpp (+285 -30)
📝 client/vpnConnection.h (+21 -4)

📄 Description

Summary

Resolve site-based split tunneling hostnames before starting a VPN connection on Windows and pass all unique IPv4 addresses to the VPN configuration.

This prevents a single saved or imported address from being used as the only routing source for hostnames backed by multiple or changing IP addresses.

Root cause

Site split tunneling settings store one IPv4 address per hostname for JSON compatibility.

On Windows, WireGuard and AmneziaWG configurations apply splitTunnelSites while the tunnel is being configured. Their post-connect hostname resolution path is not used, so the stored single address could become the only address included in the routing configuration.

For websites using separate page, API, CDN, and video endpoints, this could result in inconsistent routing and different external IPs being observed by different parts of the website.

Changes

  • Resolve site split tunneling hostnames before connecting on Windows.
  • Collect and deduplicate all returned IPv4 addresses.
  • Limit DNS lookup concurrency and apply an overall timeout.
  • Continue when individual hostnames fail to resolve.
  • Preserve explicit IP/subnet entries.
  • Stop using the persisted single IP as the sole Windows routing source.
  • Preserve the existing settings and JSON format.
  • Refuse to silently fall back to full-tunnel routing when no valid site addresses are available.
  • Route all resolved IPv4 addresses in the post-connect path where it is used.
  • Use safe value captures in asynchronous callbacks.
  • Cancel outstanding DNS lookups when starting a new connection, disconnecting, or destroying the connection.
  • Re-resolve the list when the route mode changes during lookup.
  • Preserve the full-tunnel path if site split tunneling is disabled or switched to VpnAllSites while DNS lookups are in progress.
  • Skip invalid exclusion-route creation when a server IPv4 or IPv6 address is empty.

Testing

  • Built the Windows Release client successfully (AmneziaVPN.exe).
  • Built the Windows Release service successfully (AmneziaVPN-service.exe).
  • git diff --check passed.
  • No CTest tests are registered in the current build configuration.

Diagnostic run:

  • 924 hostnames requested.
  • 913 hostnames resolved successfully.
  • 712 unique IPv4 addresses collected.
  • 152 hostnames returned multiple IPv4 addresses.
  • 11 failed DNS lookups did not cancel the connection.
  • DNS resolution completed without reaching the timeout.

Manual verification

Tested on Windows 11 x64 with a self-hosted AmneziaWG server in the Netherlands and site-based split tunneling enabled in VpnAllExceptSites mode.

Results:

  • VPN connection completed successfully.
  • YouTube remained available with the VPN connected.
  • Ozon opened successfully with the exclusion list enabled.
  • The previously failing episode on griffini.ru played without the geo-restriction error.

Full tunnel

The normal full-tunnel configuration path is unchanged. If settings switch to full tunnel during pre-connect DNS resolution, the resolved split-tunnel list is discarded and the ordinary full-tunnel configuration is used.

During split-tunnel verification, non-excluded traffic remained available through the VPN.

Site-based split tunneling

Windows now builds the site address list from current DNS results before configuring the tunnel. Each new connection performs a new lookup instead of relying on an old persisted address.

Scope

  • Windows site-based split tunneling only.
  • No UI changes.
  • No app-based split tunneling changes.
  • No split-tunnel driver changes.
  • No hard-coded website domains.
  • No wildcard support added.
  • No dependency updates.
  • Non-Windows routing remains single-address.

Risks and limitations

  • Site routing remains IPv4-only.
  • The user-provided domain list must still contain all required page, API, CDN, and video hostnames.
  • Wildcard domain discovery is not implemented.
  • DNS changes during a long-running WireGuard/AmneziaWG connection are applied after disconnecting and starting a new connection; the internal reconnect path reuses the current configuration.
  • Manual verification covered one Windows system and one self-hosted AmneziaWG server.
  • A separate disconnect/new-connection test and external-IP snapshot were not included in the submitted logs.

Fixes #2797


🔄 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/2825 **Author:** [@communism420](https://github.com/communism420) **Created:** 7/12/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/windows-site-split-tunneling-2797` --- ### 📝 Commits (2) - [`b6fe2ee`](https://github.com/amnezia-vpn/amnezia-client/commit/b6fe2ee80f6642698548488f5031990c37d38595) fix: resolve Windows site split tunnel addresses - [`30de098`](https://github.com/amnezia-vpn/amnezia-client/commit/30de0986db77f39e6aed564396345b53e8cccfb8) fix: preserve full tunnel during site resolution ### 📊 Changes **3 files changed** (+312 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `client/platforms/windows/daemon/wireguardutilswindows.cpp` (+6 -2) 📝 `client/vpnConnection.cpp` (+285 -30) 📝 `client/vpnConnection.h` (+21 -4) </details> ### 📄 Description ## Summary Resolve site-based split tunneling hostnames before starting a VPN connection on Windows and pass all unique IPv4 addresses to the VPN configuration. This prevents a single saved or imported address from being used as the only routing source for hostnames backed by multiple or changing IP addresses. ## Root cause Site split tunneling settings store one IPv4 address per hostname for JSON compatibility. On Windows, WireGuard and AmneziaWG configurations apply `splitTunnelSites` while the tunnel is being configured. Their post-connect hostname resolution path is not used, so the stored single address could become the only address included in the routing configuration. For websites using separate page, API, CDN, and video endpoints, this could result in inconsistent routing and different external IPs being observed by different parts of the website. ## Changes - Resolve site split tunneling hostnames before connecting on Windows. - Collect and deduplicate all returned IPv4 addresses. - Limit DNS lookup concurrency and apply an overall timeout. - Continue when individual hostnames fail to resolve. - Preserve explicit IP/subnet entries. - Stop using the persisted single IP as the sole Windows routing source. - Preserve the existing settings and JSON format. - Refuse to silently fall back to full-tunnel routing when no valid site addresses are available. - Route all resolved IPv4 addresses in the post-connect path where it is used. - Use safe value captures in asynchronous callbacks. - Cancel outstanding DNS lookups when starting a new connection, disconnecting, or destroying the connection. - Re-resolve the list when the route mode changes during lookup. - Preserve the full-tunnel path if site split tunneling is disabled or switched to `VpnAllSites` while DNS lookups are in progress. - Skip invalid exclusion-route creation when a server IPv4 or IPv6 address is empty. ## Testing - Built the Windows Release client successfully (`AmneziaVPN.exe`). - Built the Windows Release service successfully (`AmneziaVPN-service.exe`). - `git diff --check` passed. - No CTest tests are registered in the current build configuration. Diagnostic run: - 924 hostnames requested. - 913 hostnames resolved successfully. - 712 unique IPv4 addresses collected. - 152 hostnames returned multiple IPv4 addresses. - 11 failed DNS lookups did not cancel the connection. - DNS resolution completed without reaching the timeout. ## Manual verification Tested on Windows 11 x64 with a self-hosted AmneziaWG server in the Netherlands and site-based split tunneling enabled in `VpnAllExceptSites` mode. Results: - VPN connection completed successfully. - YouTube remained available with the VPN connected. - Ozon opened successfully with the exclusion list enabled. - The previously failing episode on `griffini.ru` played without the geo-restriction error. ## Full tunnel The normal full-tunnel configuration path is unchanged. If settings switch to full tunnel during pre-connect DNS resolution, the resolved split-tunnel list is discarded and the ordinary full-tunnel configuration is used. During split-tunnel verification, non-excluded traffic remained available through the VPN. ## Site-based split tunneling Windows now builds the site address list from current DNS results before configuring the tunnel. Each new connection performs a new lookup instead of relying on an old persisted address. ## Scope - Windows site-based split tunneling only. - No UI changes. - No app-based split tunneling changes. - No split-tunnel driver changes. - No hard-coded website domains. - No wildcard support added. - No dependency updates. - Non-Windows routing remains single-address. ## Risks and limitations - Site routing remains IPv4-only. - The user-provided domain list must still contain all required page, API, CDN, and video hostnames. - Wildcard domain discovery is not implemented. - DNS changes during a long-running WireGuard/AmneziaWG connection are applied after disconnecting and starting a new connection; the internal reconnect path reuses the current configuration. - Manual verification covered one Windows system and one self-hosted AmneziaWG server. - A separate disconnect/new-connection test and external-IP snapshot were not included in the submitted logs. Fixes #2797 --- <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#2966
No description provided.