[PR #3407] fix(daemon): clear host bits in allowed IP ranges #3283

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3407
Author: @OverFitted
Created: 11/5/2026
Status: 🔄 Open

Base: dev ← Head: fix/daemon-mask-allowed-ranges


📝 Commits (1)

  • b9565fd fix(daemon): clear host bits in allowed IP ranges

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 client/daemon/daemon.cpp (+1 -1)

📄 Description

Summary

Clear the host bits of allowed IP ranges when the daemon parses the activation config, so a split tunneling entry such as 104.16.0.1/12 no longer breaks WireGuard/AmneziaWG connections on Windows.

Problem

Site split tunneling accepts entries like 192.168.1.10/24: NetworkUtilities::checkIpSubnetFormat() only checks the syntax, and LocalSocketController::activate() splits address/range and sends both parts unchanged. Daemon::parseConfig() then builds each range with IPAddress(QHostAddress, int), which keeps the host bits.

On Windows such a range reaches CreateIpForwardEntry2 as is. Windows rejects a destination prefix with host bits set:

198.51.100.7/24 -> CreateIpForwardEntry2 = 87 (ERROR_INVALID_PARAMETER)
198.51.100.0/24 -> CreateIpForwardEntry2 = 0

updateRoutePrefix() returns false, and Daemon::activate() aborts the whole connection because of that one entry. With the kill switch on, WindowsFirewall::blockTrafficTo() also uses address() as the lower bound of the WFP range, so the block for 1.2.3.4/24 starts at .4 instead of .0.

excludedAddresses already go through IPAddress(QString), which uses QHostAddress::parseSubnet() and clears the host bits.

Changes

  • Build allowed ranges with IPAddress(QString) so they are normalized the same way as excluded addresses:
104.16.0.1/12  -> 104.16.0.0/12
192.168.1.10/24 -> 192.168.1.0/24
8.8.8.8/32     -> 8.8.8.8/32
2001:db8::1/32 -> 2001:db8::/32

Backward compatibility

Ranges without host bits are unchanged. The UAPI allowed_ip lines, routes and firewall ranges now describe the same network.

Verification

  • Built the Windows x64 client, service and tests in Release mode (MSVC 19.35, Qt 6.10.1) against dev at ac175c8; ctest passes.
  • Checked the parseSubnet results above and the CreateIpForwardEntry2 results above with standalone programs (the test route was added on the loopback interface and removed).

🔄 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/3407 **Author:** [@OverFitted](https://github.com/OverFitted) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/daemon-mask-allowed-ranges` --- ### 📝 Commits (1) - [`b9565fd`](https://github.com/amnezia-vpn/amnezia-client/commit/b9565fd62d88ce626297c36cded2792f4de6c258) fix(daemon): clear host bits in allowed IP ranges ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `client/daemon/daemon.cpp` (+1 -1) </details> ### 📄 Description ## Summary Clear the host bits of allowed IP ranges when the daemon parses the activation config, so a split tunneling entry such as `104.16.0.1/12` no longer breaks WireGuard/AmneziaWG connections on Windows. ## Problem Site split tunneling accepts entries like `192.168.1.10/24`: `NetworkUtilities::checkIpSubnetFormat()` only checks the syntax, and `LocalSocketController::activate()` splits `address/range` and sends both parts unchanged. `Daemon::parseConfig()` then builds each range with `IPAddress(QHostAddress, int)`, which keeps the host bits. On Windows such a range reaches `CreateIpForwardEntry2` as is. Windows rejects a destination prefix with host bits set: ```text 198.51.100.7/24 -> CreateIpForwardEntry2 = 87 (ERROR_INVALID_PARAMETER) 198.51.100.0/24 -> CreateIpForwardEntry2 = 0 ``` `updateRoutePrefix()` returns `false`, and `Daemon::activate()` aborts the whole connection because of that one entry. With the kill switch on, `WindowsFirewall::blockTrafficTo()` also uses `address()` as the lower bound of the WFP range, so the block for `1.2.3.4/24` starts at `.4` instead of `.0`. `excludedAddresses` already go through `IPAddress(QString)`, which uses `QHostAddress::parseSubnet()` and clears the host bits. ## Changes - Build allowed ranges with `IPAddress(QString)` so they are normalized the same way as excluded addresses: ```text 104.16.0.1/12 -> 104.16.0.0/12 192.168.1.10/24 -> 192.168.1.0/24 8.8.8.8/32 -> 8.8.8.8/32 2001:db8::1/32 -> 2001:db8::/32 ``` ## Backward compatibility Ranges without host bits are unchanged. The UAPI `allowed_ip` lines, routes and firewall ranges now describe the same network. ## Verification - Built the Windows x64 client, service and tests in Release mode (MSVC 19.35, Qt 6.10.1) against `dev` at ac175c8; `ctest` passes. - Checked the `parseSubnet` results above and the `CreateIpForwardEntry2` results above with standalone programs (the test route was added on the loopback interface and removed). --- <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#3283
No description provided.