[PR #3365] feat(split-tunneling): support live IPv4 rule additions for WG/AWG #3266

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3365
Author: @ariran5
Created: 11/1/2026
Status: 🔄 Open

Base: dev ← Head: feat/live-split-tunneling-additions


📝 Commits (3)

  • c484032 feat(split-tunneling): support live IPv4 rule additions for WG/AWG
  • ff9054d fix(split-tunneling): preserve firewall protection and recover route state
  • ee9875f feat(apple): wire confirmed live routing updates through Network Extension

📊 Changes

75 files changed (+4501 additions, -876 deletions)

View changed files

📝 client/CMakeLists.txt (+1 -0)
➕ client/cmake/appleLiveRouting.cmake (+23 -0)
📝 client/cmake/ios.cmake (+1 -1)
📝 client/cmake/macos_ne.cmake (+1 -1)
📝 client/cmake/sources.cmake (+13 -0)
📝 client/core/controllers/connectionController.cpp (+9 -0)
📝 client/core/controllers/connectionController.h (+3 -0)
📝 client/core/controllers/coreSignalHandlers.cpp (+8 -0)
➕ client/core/controllers/splitTunnelingUpdateController.cpp (+124 -0)
➕ client/core/controllers/splitTunnelingUpdateController.h (+42 -0)
📝 client/core/protocols/vpnProtocol.cpp (+8 -0)
📝 client/core/protocols/vpnProtocol.h (+1 -0)
➕ client/core/splitTunneling/appleSplitTunnelingUpdateBackend.cpp (+27 -0)
➕ client/core/splitTunneling/appleSplitTunnelingUpdateBackend.h (+14 -0)
➕ client/core/splitTunneling/desktopSplitTunnelingUpdateBackend.cpp (+55 -0)
➕ client/core/splitTunneling/desktopSplitTunnelingUpdateBackend.h (+13 -0)
➕ client/core/splitTunneling/splitTunnelingUpdateBackend.cpp (+37 -0)
➕ client/core/splitTunneling/splitTunnelingUpdateBackend.h (+23 -0)
➕ client/core/splitTunneling/splitTunnelingUpdateBackendFactory.cpp (+19 -0)
➕ client/core/splitTunneling/splitTunnelingUpdateResult.h (+23 -0)

...and 55 more files

📄 Description

Problem and current scope

Adding a split tunneling address currently requires disconnecting and reconnecting the VPN. This draft introduces live IPv4 address/subnet additions for eligible WG/AWG connections, without an automatic reconnect fallback.

Both routing modes are covered: add destinations via VPN, or add destinations directly outside the tunnel. Split tunneling must already be enabled. Removal, clearing/replacing the list, changing its mode and enabling/disabling split tunneling remain unavailable while connected. Existing empty-list semantics are preserved.

Architecture and safety changes

A coordinator receives a platform backend through constructor injection. It serializes/coalesces requests, binds them to the active session and tracks pending/applied configurations separately. Results are explicit: Applied, NotApplied after confirmed compensation, or StateUnknown. Unknown outcomes block further live editing; unsupported connections keep the existing restrictions.

The desktop service updates the current interface and compensates failed operations:

  • Linux replaces the split firewall chains in one checked iptables-restore transaction. macOS replaces PF anchors in a protection-preserving order. The hot path is separate from startup configuration, and no firewall commands are issued when KillSwitch is disabled.
  • Route creation returns an ownership receipt. Conflicts are rejected without overwriting pre-existing routes; rollback removes only resources created by that request, including partial default-route creation. Linux waits for kernel netlink ACKs and remembers the gateway used for an exclusion.
  • Windows propagates route failures and retains failed cleanup records for retry. WFP rules use transactions. An unknown-state latch is cleared only after verified cleanup commits, rather than merely on a reconnect request. Queued network notifications cannot recreate routes after cleanup starts.

These changes are in ff9054d8; passing tests does not establish leak-free behavior on every OS.

Apple dependency and integration

Depends on the library Draft PR: https://github.com/amnezia-vpn/amneziawg-apple/pull/53.

Client integration: github.com/amnezia-vpn/amnezia-client@ee9875fad5.

The previous unverified Apple bridge was removed. The new bridge uses the library's routing-only contract, preserving the running peer instead of calling its general peer-replacing update. It checks request/session IDs, public key, mode and IPv4 additions; stale/duplicate responses cannot update another session. Profile settings are persisted after the tunnel confirms application; failed persistence is treated as unknown.

Apple live routing remains disabled by default behind AMNEZIA_ENABLE_APPLE_LIVE_ROUTING. Its build requires matching Swift sources and a target-SDK Go archive; the vendor submodule is unchanged while the library PR is reviewed. The source lists also preserve the build path with the old dependency when this capability is off.

For this Apple draft, only an existing inclusion/exclusion session is eligible. The effective mode-0/full-tunnel transition used by an empty list remains excluded until its includeAllNetworks policy is validated. That is separate from desktop coverage and is not a change to empty-list semantics.

Platform coverage and evidence

Backend Current state Available verification
Windows desktop Eligible WG/AWG additions implemented Transaction tests and actual route-monitor tests with simulated SDK/WinAPI; native Windows/WFP traffic validation pending
Linux desktop Eligible WG/AWG additions implemented Real kernel route/permission probes and nft/legacy firewall updates in isolated network namespaces; complete application/device matrix pending
macOS desktop service Eligible WG/AWG additions implemented Universal service build, focused tests and PF syntax checks; prior macOS/AWG build had user-confirmed live addition, but revised native PF/traffic validation remains pending
iOS / macOS Network Extension New integration prepared, capability off by default Swift/Go/C component compilation/linking and session tests; complete signed apps and real-device NE traffic tests pending
Android / unsupported protocols and configurations Existing behavior retained Live editing remains disabled

The desktop path is limited to eligible single-hop WG/AWG configurations with the standard initial full-tunnel AllowedIPs. Live rule additions are IPv4 only.

Validation

  • Fresh production configuration, arm64+x86_64 macOS service build and 5/5 focused desktop CTest suites passed.
  • Actual WindowsRouteMonitor with simulated SDK/WinAPI: 13 QtTest passes, including setup/cleanup. This is not native WinAPI execution.
  • 11 new Swift client-session tests passed, including their permanent CMake/CTest runner. Five CMake capability/input scenarios also passed.
  • Library dependency: 24 new Swift tests and two Go tests with -race passed. The Go backend test uses an in-memory TUN and preserves peer identity through update/compensation.
  • Swift/Go/C components and the new RPC method typechecked/linked for arm64 macOS, iOS Simulator and iPhone SDKs. The provider shell is minimal; full OpenVPN/Xray providers and signed applications were not built/run. Direct component builds do not validate the release Conan/Makefile pipeline.
  • New C++/Objective-C++ bridge syntax checks used real headers. Swift parses with and without the feature flag; Xcode project lint and whitespace checks passed.
  • The full dependency Swift suite has one unchanged handshake-cutoff failure out of 29 tests; its implementation and test match the pinned base. The complete library suite is not presented as green.

Native KillSwitch packet capture, transport failure with working internet, TCP/UDP/DNS continuity, device sleep/network changes, missing/late OS completion and Intel/macOS NE runtime validation remain outstanding. Keep both PRs as drafts.

Follow-up plan

  1. Review the library API in #53 and complete native failure/traffic/KillSwitch validation for the desktop and Apple paths.
  2. Build signed iOS/macOS NE applications with matching Swift/Go dependencies; validate the empty-list/full-tunnel transition separately. Only then pin the library revision and consider enabling Apple capability by default.
  3. Resolve the library's pre-existing handshake-cutoff test separately.
  4. Add live removal, including queued changes, shared addresses and explicit empty-list behavior.
  5. Add domain rules with DNS refresh and CDN address lifecycle management through the existing IP update pipeline.
  6. Extend protocols/platforms only where active-tunnel updates can be supported without an automatic restart.

🔄 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/3365 **Author:** [@ariran5](https://github.com/ariran5) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feat/live-split-tunneling-additions` --- ### 📝 Commits (3) - [`c484032`](https://github.com/amnezia-vpn/amnezia-client/commit/c484032459eafb8a2ef5a373ea9ccbeaed0ed06b) feat(split-tunneling): support live IPv4 rule additions for WG/AWG - [`ff9054d`](https://github.com/amnezia-vpn/amnezia-client/commit/ff9054d802cad4644ddaddc6f4169cbbc5b18e05) fix(split-tunneling): preserve firewall protection and recover route state - [`ee9875f`](https://github.com/amnezia-vpn/amnezia-client/commit/ee9875fad586337e29d6b1be7892d16c1c9524be) feat(apple): wire confirmed live routing updates through Network Extension ### 📊 Changes **75 files changed** (+4501 additions, -876 deletions) <details> <summary>View changed files</summary> 📝 `client/CMakeLists.txt` (+1 -0) ➕ `client/cmake/appleLiveRouting.cmake` (+23 -0) 📝 `client/cmake/ios.cmake` (+1 -1) 📝 `client/cmake/macos_ne.cmake` (+1 -1) 📝 `client/cmake/sources.cmake` (+13 -0) 📝 `client/core/controllers/connectionController.cpp` (+9 -0) 📝 `client/core/controllers/connectionController.h` (+3 -0) 📝 `client/core/controllers/coreSignalHandlers.cpp` (+8 -0) ➕ `client/core/controllers/splitTunnelingUpdateController.cpp` (+124 -0) ➕ `client/core/controllers/splitTunnelingUpdateController.h` (+42 -0) 📝 `client/core/protocols/vpnProtocol.cpp` (+8 -0) 📝 `client/core/protocols/vpnProtocol.h` (+1 -0) ➕ `client/core/splitTunneling/appleSplitTunnelingUpdateBackend.cpp` (+27 -0) ➕ `client/core/splitTunneling/appleSplitTunnelingUpdateBackend.h` (+14 -0) ➕ `client/core/splitTunneling/desktopSplitTunnelingUpdateBackend.cpp` (+55 -0) ➕ `client/core/splitTunneling/desktopSplitTunnelingUpdateBackend.h` (+13 -0) ➕ `client/core/splitTunneling/splitTunnelingUpdateBackend.cpp` (+37 -0) ➕ `client/core/splitTunneling/splitTunnelingUpdateBackend.h` (+23 -0) ➕ `client/core/splitTunneling/splitTunnelingUpdateBackendFactory.cpp` (+19 -0) ➕ `client/core/splitTunneling/splitTunnelingUpdateResult.h` (+23 -0) _...and 55 more files_ </details> ### 📄 Description ### Problem and current scope Adding a split tunneling address currently requires disconnecting and reconnecting the VPN. This draft introduces live IPv4 address/subnet additions for eligible WG/AWG connections, without an automatic reconnect fallback. Both routing modes are covered: add destinations **via VPN**, or add destinations **directly** outside the tunnel. Split tunneling must already be enabled. Removal, clearing/replacing the list, changing its mode and enabling/disabling split tunneling remain unavailable while connected. Existing empty-list semantics are preserved. ### Architecture and safety changes A coordinator receives a platform backend through constructor injection. It serializes/coalesces requests, binds them to the active session and tracks pending/applied configurations separately. Results are explicit: `Applied`, `NotApplied` after confirmed compensation, or `StateUnknown`. Unknown outcomes block further live editing; unsupported connections keep the existing restrictions. The desktop service updates the current interface and compensates failed operations: - Linux replaces the split firewall chains in one checked `iptables-restore` transaction. macOS replaces PF anchors in a protection-preserving order. The hot path is separate from startup configuration, and no firewall commands are issued when KillSwitch is disabled. - Route creation returns an ownership receipt. Conflicts are rejected without overwriting pre-existing routes; rollback removes only resources created by that request, including partial default-route creation. Linux waits for kernel netlink ACKs and remembers the gateway used for an exclusion. - Windows propagates route failures and retains failed cleanup records for retry. WFP rules use transactions. An unknown-state latch is cleared only after verified cleanup commits, rather than merely on a reconnect request. Queued network notifications cannot recreate routes after cleanup starts. These changes are in `ff9054d8`; passing tests does not establish leak-free behavior on every OS. ### Apple dependency and integration **Depends on the library Draft PR: https://github.com/amnezia-vpn/amneziawg-apple/pull/53.** Client integration: https://github.com/amnezia-vpn/amnezia-client/commit/ee9875fad586337e29d6b1be7892d16c1c9524be. The previous unverified Apple bridge was removed. The new bridge uses the library's routing-only contract, preserving the running peer instead of calling its general peer-replacing update. It checks request/session IDs, public key, mode and IPv4 additions; stale/duplicate responses cannot update another session. Profile settings are persisted after the tunnel confirms application; failed persistence is treated as unknown. **Apple live routing remains disabled by default** behind `AMNEZIA_ENABLE_APPLE_LIVE_ROUTING`. Its build requires matching Swift sources and a target-SDK Go archive; the vendor submodule is unchanged while the library PR is reviewed. The source lists also preserve the build path with the old dependency when this capability is off. For this Apple draft, only an existing inclusion/exclusion session is eligible. The effective mode-0/full-tunnel transition used by an empty list remains excluded until its `includeAllNetworks` policy is validated. That is separate from desktop coverage and is not a change to empty-list semantics. ### Platform coverage and evidence | Backend | Current state | Available verification | |---|---|---| | Windows desktop | Eligible WG/AWG additions implemented | Transaction tests and actual route-monitor tests with simulated SDK/WinAPI; native Windows/WFP traffic validation pending | | Linux desktop | Eligible WG/AWG additions implemented | Real kernel route/permission probes and nft/legacy firewall updates in isolated network namespaces; complete application/device matrix pending | | macOS desktop service | Eligible WG/AWG additions implemented | Universal service build, focused tests and PF syntax checks; prior macOS/AWG build had user-confirmed live addition, but revised native PF/traffic validation remains pending | | iOS / macOS Network Extension | New integration prepared, capability off by default | Swift/Go/C component compilation/linking and session tests; complete signed apps and real-device NE traffic tests pending | | Android / unsupported protocols and configurations | Existing behavior retained | Live editing remains disabled | The desktop path is limited to eligible single-hop WG/AWG configurations with the standard initial full-tunnel AllowedIPs. Live rule additions are IPv4 only. ### Validation - Fresh production configuration, arm64+x86_64 macOS service build and **5/5 focused desktop CTest suites** passed. - Actual WindowsRouteMonitor with simulated SDK/WinAPI: 13 QtTest passes, including setup/cleanup. This is not native WinAPI execution. - **11 new Swift client-session tests** passed, including their permanent CMake/CTest runner. Five CMake capability/input scenarios also passed. - Library dependency: **24 new Swift tests and two Go tests with `-race`** passed. The Go backend test uses an in-memory TUN and preserves peer identity through update/compensation. - Swift/Go/C components and the new RPC method typechecked/linked for arm64 macOS, iOS Simulator and iPhone SDKs. The provider shell is minimal; full OpenVPN/Xray providers and signed applications were not built/run. Direct component builds do not validate the release Conan/Makefile pipeline. - New C++/Objective-C++ bridge syntax checks used real headers. Swift parses with and without the feature flag; Xcode project lint and whitespace checks passed. - The full dependency Swift suite has **one unchanged handshake-cutoff failure out of 29 tests**; its implementation and test match the pinned base. The complete library suite is not presented as green. Native KillSwitch packet capture, transport failure with working internet, TCP/UDP/DNS continuity, device sleep/network changes, missing/late OS completion and Intel/macOS NE runtime validation remain outstanding. Keep both PRs as drafts. ### Follow-up plan 1. Review the library API in #53 and complete native failure/traffic/KillSwitch validation for the desktop and Apple paths. 2. Build signed iOS/macOS NE applications with matching Swift/Go dependencies; validate the empty-list/full-tunnel transition separately. Only then pin the library revision and consider enabling Apple capability by default. 3. Resolve the library's pre-existing handshake-cutoff test separately. 4. Add live removal, including queued changes, shared addresses and explicit empty-list behavior. 5. Add domain rules with DNS refresh and CDN address lifecycle management through the existing IP update pipeline. 6. Extend protocols/platforms only where active-tunnel updates can be supported without an automatic restart. --- <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#3266
No description provided.