[PR #3030] fix(windows): apply exclusion routes transactionally #3060

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3030
Author: @makkoar
Created: 8/24/2026
Status: 🔄 Open

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


📝 Commits (2)

  • 832fefd fix(windows): apply exclusion routes transactionally
  • 9299608 docs: restore upstream split tunneling comments

📊 Changes

7 files changed (+513 additions, -103 deletions)

View changed files

📝 client/daemon/daemon.cpp (+66 -13)
📝 client/daemon/daemon.h (+3 -1)
📝 client/daemon/wireguardutils.h (+21 -1)
📝 client/platforms/windows/daemon/windowsroutemonitor.cpp (+244 -86)
📝 client/platforms/windows/daemon/windowsroutemonitor.h (+15 -2)
📝 client/platforms/windows/daemon/wireguardutilswindows.cpp (+161 -0)
📝 client/platforms/windows/daemon/wireguardutilswindows.h (+3 -0)

📄 Description

Summary

Make Windows WG/AWG exclusion-route installation batched and transactional, and stabilize route reconciliation.

Fixes #3377.
Tracking issue: #3378.

This PR has been narrowed to the Windows route-application portion of the original combined patch. The other parts are now #3379 (AllowedIPs/site allowlist) and #3380 (CIDRs, hostnames and DNS lifecycle).

Problem

I encountered exclusions remaining visible in settings while their destinations still used the tunnel, and slow/intermittent connectivity with a large exclusion list.

The daemon previously ignored individual exclusion-route installation failures. Activation or server switching could proceed with a partial list. Windows also fetched and scanned the growing route table separately for each prefix, while route notifications could trigger repeated reconciliations.

Changes

  • Introduce a batch exclusion API, with a rollback-capable fallback for non-Windows backends.
  • Update daemon reference counts only after the requested additions succeed.
  • Roll back additions when activation or server switching fails; propagate installation errors.
  • Preserve the previous peer when switching fails and clean up newly installed prefixes.
  • Reuse routing-table/interface information for a batch and select the physical route for each exclusion.
  • Preserve equivalent pre-existing routes without claiming ownership; clean up only owned routes.
  • Deduplicate destinations and skip non-routable entries.
  • Debounce route-change bursts, handle notifications without a route row, and avoid retrying the same conflicting captured route within one pass.
  • Use type-safe address copies in the Windows route monitor.

The existing large-batch optimization is retained: for batches of at least 500 entries, the code attempts to suspend the process hosting wcmSvc while applying routes, then resume it on scope exit. This uses NT process APIs and is process-wide, not a service-only pause. Missing APIs/privileges fall back to ordinary batch installation. This behavior deserves explicit review; it is not a claim that every Windows configuration or failure path has been tested.

Scope

Seven changed files: the common daemon/batch interface and Windows route-monitor/backend implementation. No hostname/DNS or AllowedIPs parser changes remain in this PR. Application-based split-tunneling behavior and the application version are unchanged.

Verification

Previous full-build/live results

  • Built the Windows x64 client, service and IFW installer on upstream 94b51df2 (5.0.3.1); the route implementation was used in my local 5.0.3.2 build.
  • Earlier checks covered a mixed domain/CIDR exclusion list and disconnect/reconnect behavior.
  • A later read-only route audit of that installed build sampled 2,784 addresses, including subnet boundaries, from 1,104 IPv4 exclusions: none selected the VPN interface. Representative excluded HTTPS destinations used the physical interface and a non-excluded control used the tunnel.

Original split

  • Based directly on dev 3f6ecacf.
  • git diff --check passes.
  • All three independent branches merge without conflicts and reconstruct the previous complete patch, apart from moving an unchanged helper in the AllowedIPs sibling.
  • No full rebuild was performed at the initial split. The subsequent combined rebuild is recorded below. Earlier live checks do not establish every rollback/failure path, IPv6 topology or real application-bypass behavior.

5.1.0.6 refresh

  • Rebased onto release 5.1.0.6 (ac175c8a); git range-diff confirms that the patch commits are unchanged.
  • A clean Windows x64 configuration and combined Release client/service/installer build include #3030, #3379, #3380 and #3383, using Qt 6.10.1 and MSVC 19.53.
  • Five isolated suites passed: local-socket route serialization, domain routing with the actual bundled core, engine ownership, mocked Windows route monitoring and offscreen settings QML.
  • The domain suite had an unexplained initial CTest failure, followed by passing diagnostic and full-suite reruns; details are recorded in #3383.
  • These are combined-build results, not separate full builds of each PR. The installed VPN was not stopped or replaced. Real TUN/WG/AWG activation, WFP/kill-switch behavior, network transitions and disconnect cleanup still require on-device acceptance.
  • #2248: slow/unstable Windows connection setup with large split-tunneling lists.
  • #3020: quadratic per-prefix route setup. The batch path addresses that scaling mechanism; the separately reported access-violation crash has not been proven to share that exact cause.
  • #3021: overlapping Windows batching implementation. This alternative also includes transactional daemon activation/server switching, ownership handling and reconciliation changes.

The former AllowedIPs overlap with #3011/#3097 belongs in #3379 now, and the hostname/DNS overlap with #2825/#3018 belongs in #3380. This PR targets dev directly and does not require either sibling to merge first.


🔄 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/3030 **Author:** [@makkoar](https://github.com/makkoar) **Created:** 8/24/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/windows-site-split-tunneling` --- ### 📝 Commits (2) - [`832fefd`](https://github.com/amnezia-vpn/amnezia-client/commit/832fefd9ebe541ebb223ad48a1cf7c7e01d41f18) fix(windows): apply exclusion routes transactionally - [`9299608`](https://github.com/amnezia-vpn/amnezia-client/commit/92996089e909738818457779c465764b59a13e27) docs: restore upstream split tunneling comments ### 📊 Changes **7 files changed** (+513 additions, -103 deletions) <details> <summary>View changed files</summary> 📝 `client/daemon/daemon.cpp` (+66 -13) 📝 `client/daemon/daemon.h` (+3 -1) 📝 `client/daemon/wireguardutils.h` (+21 -1) 📝 `client/platforms/windows/daemon/windowsroutemonitor.cpp` (+244 -86) 📝 `client/platforms/windows/daemon/windowsroutemonitor.h` (+15 -2) 📝 `client/platforms/windows/daemon/wireguardutilswindows.cpp` (+161 -0) 📝 `client/platforms/windows/daemon/wireguardutilswindows.h` (+3 -0) </details> ### 📄 Description ## Summary Make Windows WG/AWG exclusion-route installation batched and transactional, and stabilize route reconciliation. Fixes #3377. Tracking issue: #3378. This PR has been narrowed to the Windows route-application portion of the original combined patch. The other parts are now #3379 (AllowedIPs/site allowlist) and #3380 (CIDRs, hostnames and DNS lifecycle). ## Problem I encountered exclusions remaining visible in settings while their destinations still used the tunnel, and slow/intermittent connectivity with a large exclusion list. The daemon previously ignored individual exclusion-route installation failures. Activation or server switching could proceed with a partial list. Windows also fetched and scanned the growing route table separately for each prefix, while route notifications could trigger repeated reconciliations. ## Changes - Introduce a batch exclusion API, with a rollback-capable fallback for non-Windows backends. - Update daemon reference counts only after the requested additions succeed. - Roll back additions when activation or server switching fails; propagate installation errors. - Preserve the previous peer when switching fails and clean up newly installed prefixes. - Reuse routing-table/interface information for a batch and select the physical route for each exclusion. - Preserve equivalent pre-existing routes without claiming ownership; clean up only owned routes. - Deduplicate destinations and skip non-routable entries. - Debounce route-change bursts, handle notifications without a route row, and avoid retrying the same conflicting captured route within one pass. - Use type-safe address copies in the Windows route monitor. The existing large-batch optimization is retained: for batches of at least 500 entries, the code attempts to suspend the process hosting `wcmSvc` while applying routes, then resume it on scope exit. This uses NT process APIs and is process-wide, not a service-only pause. Missing APIs/privileges fall back to ordinary batch installation. This behavior deserves explicit review; it is not a claim that every Windows configuration or failure path has been tested. ## Scope Seven changed files: the common daemon/batch interface and Windows route-monitor/backend implementation. No hostname/DNS or AllowedIPs parser changes remain in this PR. Application-based split-tunneling behavior and the application version are unchanged. ## Verification ### Previous full-build/live results - Built the Windows x64 client, service and IFW installer on upstream `94b51df2` (5.0.3.1); the route implementation was used in my local 5.0.3.2 build. - Earlier checks covered a mixed domain/CIDR exclusion list and disconnect/reconnect behavior. - A later read-only route audit of that installed build sampled 2,784 addresses, including subnet boundaries, from 1,104 IPv4 exclusions: none selected the VPN interface. Representative excluded HTTPS destinations used the physical interface and a non-excluded control used the tunnel. ### Original split - Based directly on dev `3f6ecacf`. - `git diff --check` passes. - All three independent branches merge without conflicts and reconstruct the previous complete patch, apart from moving an unchanged helper in the AllowedIPs sibling. - No full rebuild was performed at the initial split. The subsequent combined rebuild is recorded below. Earlier live checks do not establish every rollback/failure path, IPv6 topology or real application-bypass behavior. ### 5.1.0.6 refresh - Rebased onto release `5.1.0.6` (`ac175c8a`); `git range-diff` confirms that the patch commits are unchanged. - A clean Windows x64 configuration and combined Release client/service/installer build include #3030, #3379, #3380 and #3383, using Qt 6.10.1 and MSVC 19.53. - Five isolated suites passed: local-socket route serialization, domain routing with the actual bundled core, engine ownership, mocked Windows route monitoring and offscreen settings QML. - The domain suite had an unexplained initial CTest failure, followed by passing diagnostic and full-suite reruns; details are recorded in #3383. - These are combined-build results, not separate full builds of each PR. The installed VPN was not stopped or replaced. Real TUN/WG/AWG activation, WFP/kill-switch behavior, network transitions and disconnect cleanup still require on-device acceptance. ## Related issues and overlapping PRs - #2248: slow/unstable Windows connection setup with large split-tunneling lists. - #3020: quadratic per-prefix route setup. The batch path addresses that scaling mechanism; the separately reported access-violation crash has not been proven to share that exact cause. - #3021: overlapping Windows batching implementation. This alternative also includes transactional daemon activation/server switching, ownership handling and reconciliation changes. The former AllowedIPs overlap with #3011/#3097 belongs in #3379 now, and the hostname/DNS overlap with #2825/#3018 belongs in #3380. This PR targets dev directly and does not require either sibling to merge first. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #3030] fix(windows): stabilize site split tunneling to [PR #3030] fix(windows): apply exclusion routes transactionally 2026-11-07 17:58:37 +07:00
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#3060
No description provided.