[PR #3155] fix(windows): keep on-link routes off VPN capture #3104

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3155
Author: @HeisLuka
Created: 9/11/2026
Status: 🔄 Open

Base: dev ← Head: fix/issue-2830-upstream


📝 Commits (2)

  • b353f4e fix(windows): keep on-link routes off VPN capture
  • 90a69ee fix(windows): keep local static routes off VPN capture

📊 Changes

2 files changed (+252 additions, -15 deletions)

View changed files

➕ client/platforms/windows/daemon/windowsroutecapturepolicy.h (+211 -0)
📝 client/platforms/windows/daemon/windowsroutemonitor.cpp (+41 -15)

📄 Description

Summary

This PR addresses the Windows route-capture part of #2830.

When default route capture is enabled, directly connected/on-link routes can be cloned onto the AmneziaVPN interface with metric 0. This may override the physical LAN route and make local hosts unreachable while the VPN is active.

The change prevents directly connected/on-link routes from being captured into the VPN tunnel.

What changed

Route capture now skips routes that:

  • belong to the VPN interface;
  • are default routes;
  • were created by the route monitor itself;
  • are explicitly excluded;
  • are directly connected/on-link routes:
    • IPv4 next hop 0.0.0.0;
    • IPv6 next hop ::;
    • AF_UNSPEC.

Ordinary routed IPv4 and IPv6 prefixes remain eligible for capture.

The patch also keeps two adjacent correctness fixes:

  • GetIpForwardTable2() output is only used after a successful call;
  • a newly added exclusion is registered before captured-route reconciliation.

Relation to #2835

The core implementation is based on and intentionally follows #2835.

This PR is not meant to claim the route-capture fix as independent work. It brings that approach onto the current dev branch and validates it against the newer reproduction described in #2830.

In that reproduction, Windows creates a competing LAN /32 route on the AmneziaVPN interface with metric 0. Removing that route restores selection of the physical interface. Preventing on-link routes from being captured avoids creating that competing route in the first place.

Scope

This PR intentionally contains only the Windows route-capture fix.

It does not include the broader changes from #3030. Those changes are complementary, particularly for the KillSwitch / site-exclusion part of #2830.

Verification

The change has been exercised in Windows CI, including the Windows dependency build and full Windows build pipeline.

Related validation runs:


🔄 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/3155 **Author:** [@HeisLuka](https://github.com/HeisLuka) **Created:** 9/11/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/issue-2830-upstream` --- ### 📝 Commits (2) - [`b353f4e`](https://github.com/amnezia-vpn/amnezia-client/commit/b353f4e125a7f6951b9a2e0db936bdb02bd4a460) fix(windows): keep on-link routes off VPN capture - [`90a69ee`](https://github.com/amnezia-vpn/amnezia-client/commit/90a69eee73597be8d9a1f81e4e17d777195cebd1) fix(windows): keep local static routes off VPN capture ### 📊 Changes **2 files changed** (+252 additions, -15 deletions) <details> <summary>View changed files</summary> ➕ `client/platforms/windows/daemon/windowsroutecapturepolicy.h` (+211 -0) 📝 `client/platforms/windows/daemon/windowsroutemonitor.cpp` (+41 -15) </details> ### 📄 Description ## Summary This PR addresses the Windows route-capture part of #2830. When default route capture is enabled, directly connected/on-link routes can be cloned onto the AmneziaVPN interface with metric 0. This may override the physical LAN route and make local hosts unreachable while the VPN is active. The change prevents directly connected/on-link routes from being captured into the VPN tunnel. ## What changed Route capture now skips routes that: - belong to the VPN interface; - are default routes; - were created by the route monitor itself; - are explicitly excluded; - are directly connected/on-link routes: - IPv4 next hop `0.0.0.0`; - IPv6 next hop `::`; - `AF_UNSPEC`. Ordinary routed IPv4 and IPv6 prefixes remain eligible for capture. The patch also keeps two adjacent correctness fixes: - `GetIpForwardTable2()` output is only used after a successful call; - a newly added exclusion is registered before captured-route reconciliation. ## Relation to #2835 The core implementation is based on and intentionally follows #2835. This PR is not meant to claim the route-capture fix as independent work. It brings that approach onto the current `dev` branch and validates it against the newer reproduction described in #2830. In that reproduction, Windows creates a competing LAN `/32` route on the AmneziaVPN interface with metric 0. Removing that route restores selection of the physical interface. Preventing on-link routes from being captured avoids creating that competing route in the first place. ## Scope This PR intentionally contains only the Windows route-capture fix. It does not include the broader changes from #3030. Those changes are complementary, particularly for the KillSwitch / site-exclusion part of #2830. ## Verification The change has been exercised in Windows CI, including the Windows dependency build and full Windows build pipeline. Related validation runs: - https://github.com/HeisLuka/amnezia-client2/actions/runs/34650009472 - https://github.com/HeisLuka/amnezia-client2/actions/runs/34643999872 - https://github.com/HeisLuka/amnezia-client2/actions/runs/34644870746 --- <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#3104
No description provided.