[PR #53] feat(routing): add confirmed live rule updates for existing tunnels #53

Open
opened 2026-11-07 18:00:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: master ← Head: feat/live-split-routing


📝 Commits (1)

  • d63ac73 feat(routing): add confirmed live rule updates for existing tunnels

📊 Changes

10 files changed (+516 additions, -36 deletions)

View changed files

📝 Package.swift (+1 -0)
➕ Sources/WireGuardKit/RoutingUpdatePlan.swift (+57 -0)
➕ Sources/WireGuardKit/RoutingUpdateTransaction.swift (+69 -0)
📝 Sources/WireGuardKit/WireGuardAdapter.swift (+82 -33)
📝 Sources/WireGuardKitGo/api-apple.go (+7 -3)
➕ Sources/WireGuardKitGo/api-apple_test.go (+81 -0)
📝 Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift (+4 -0)
➕ Tests/WireGuardKitTests/RoutingUpdatePlanTests.swift (+103 -0)
➕ Tests/WireGuardKitTests/RoutingUpdateTransactionTests.swift (+100 -0)
📝 WireGuard.xcodeproj/project.pbxproj (+12 -0)

📄 Description

The current adapter ignores wgSetConfig failures and continues after a missing network-settings completion. Its general update also emits replace_peers=true, so it cannot provide a confirmed, routing-only operation that preserves an existing peer.

Add WireGuardAdapter.updateRouting() for additive changes to one existing peer. It leaves keys, endpoints and the backend handle unchanged, validates the requested change and checks the runtime peer/AllowedIPs before acknowledging it. Inclusion updates prepare expanded AllowedIPs before changing routes; exclusion-only updates leave peer configuration untouched.

The update reports Applied, NotApplied or StateUnknown. A confirmed OS rejection triggers checked restoration of settings and peer state. Missing completion leaves the outcome unknown: no competing network-settings update is submitted after timeout, and subsequent mutations/path updates are blocked in that adapter instance. The shared completion wait is synchronized; the general update checks its backend error, and the Go bridge returns EBADF for an absent handle.

Client integration and discussion: https://github.com/amnezia-vpn/amnezia-client/pull/3365. The client uses an injected platform backend and keeps Apple live routing disabled by default pending device validation. Its vendor revision is intentionally unchanged; the integration accepts matching external Swift sources and a Go archive while this library change is reviewed.

The implementation and component validation use the client-pinned base bdaf0b337b85c815e1dc462505455155b6cdfe79. The target is master; its subsequent Xray/version updates are not reverted by this PR and still require validation in the merged dependency build.

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

Validation

  • 24 new Swift tests passed: additive plans, unchanged peer parameters, runtime verification, compensation and immediate/missing/late/duplicate completion.
  • Two Go tests passed with -race, including an actual backend with an in-memory fake TUN. They verify absent-handle failure and retention of the same peer object during AllowedIPs updates and compensation.
  • Swift/Go/C components typechecked and linked for arm64 macOS 12, iOS Simulator 15 and iPhone 15 using SDK 26. These use a minimal provider shell; they are not complete signed applications. Go archives were built directly for component checks; the release Conan/Makefile pipeline was not exercised.
  • Xcode project lint and whitespace checks passed.
  • The complete Swift suite is not green: 29 tests, one existing failure in testLatestHandshakeOlderThanCutoffIsNotFresh. Both the cutoff implementation and its test are unchanged from bdaf0b337b85c815e1dc462505455155b6cdfe79.

Draft scope and follow-up

This is a draft API/dependency change, not a claim of leak-free operation or uninterrupted traffic on devices. Real Network Extension completion behavior, transport failure with live internet, KillSwitch packet capture, TCP/UDP/DNS continuity, sleep/network changes and Intel runtime tests remain required. Full signed iOS/macOS NE applications have not been built or run.

The associated client currently allows additions only in an existing inclusion/exclusion session. Its empty-list/full-tunnel transition, removal, mode switching, automatic reconnect and dynamic domain/CDN rules are outside this draft. After native validation, the client can pin the matching Swift/Go revision and enable the capability. The pre-existing handshake-cutoff failure needs separate resolution.


🔄 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/amneziawg-apple/pull/53 **Author:** [@ariran5](https://github.com/ariran5) **Created:** 11/1/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feat/live-split-routing` --- ### 📝 Commits (1) - [`d63ac73`](https://github.com/amnezia-vpn/amneziawg-apple/commit/d63ac7365f701e557fce80d2f1a54153ec2afc8a) feat(routing): add confirmed live rule updates for existing tunnels ### 📊 Changes **10 files changed** (+516 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `Package.swift` (+1 -0) ➕ `Sources/WireGuardKit/RoutingUpdatePlan.swift` (+57 -0) ➕ `Sources/WireGuardKit/RoutingUpdateTransaction.swift` (+69 -0) 📝 `Sources/WireGuardKit/WireGuardAdapter.swift` (+82 -33) 📝 `Sources/WireGuardKitGo/api-apple.go` (+7 -3) ➕ `Sources/WireGuardKitGo/api-apple_test.go` (+81 -0) 📝 `Sources/WireGuardNetworkExtension/PacketTunnelProvider.swift` (+4 -0) ➕ `Tests/WireGuardKitTests/RoutingUpdatePlanTests.swift` (+103 -0) ➕ `Tests/WireGuardKitTests/RoutingUpdateTransactionTests.swift` (+100 -0) 📝 `WireGuard.xcodeproj/project.pbxproj` (+12 -0) </details> ### 📄 Description The current adapter ignores `wgSetConfig` failures and continues after a missing network-settings completion. Its general update also emits `replace_peers=true`, so it cannot provide a confirmed, routing-only operation that preserves an existing peer. Add `WireGuardAdapter.updateRouting()` for additive changes to one existing peer. It leaves keys, endpoints and the backend handle unchanged, validates the requested change and checks the runtime peer/AllowedIPs before acknowledging it. Inclusion updates prepare expanded AllowedIPs before changing routes; exclusion-only updates leave peer configuration untouched. The update reports `Applied`, `NotApplied` or `StateUnknown`. A confirmed OS rejection triggers checked restoration of settings and peer state. Missing completion leaves the outcome unknown: no competing network-settings update is submitted after timeout, and subsequent mutations/path updates are blocked in that adapter instance. The shared completion wait is synchronized; the general update checks its backend error, and the Go bridge returns `EBADF` for an absent handle. Client integration and discussion: https://github.com/amnezia-vpn/amnezia-client/pull/3365. The client uses an injected platform backend and keeps Apple live routing **disabled by default** pending device validation. Its vendor revision is intentionally unchanged; the integration accepts matching external Swift sources and a Go archive while this library change is reviewed. The implementation and component validation use the client-pinned base `bdaf0b337b85c815e1dc462505455155b6cdfe79`. The target is `master`; its subsequent Xray/version updates are not reverted by this PR and still require validation in the merged dependency build. Client integration commit: https://github.com/amnezia-vpn/amnezia-client/commit/ee9875fad586337e29d6b1be7892d16c1c9524be. ### Validation - 24 new Swift tests passed: additive plans, unchanged peer parameters, runtime verification, compensation and immediate/missing/late/duplicate completion. - Two Go tests passed with `-race`, including an actual backend with an in-memory fake TUN. They verify absent-handle failure and retention of the same peer object during AllowedIPs updates and compensation. - Swift/Go/C components typechecked and linked for arm64 macOS 12, iOS Simulator 15 and iPhone 15 using SDK 26. These use a minimal provider shell; they are not complete signed applications. Go archives were built directly for component checks; the release Conan/Makefile pipeline was not exercised. - Xcode project lint and whitespace checks passed. - The complete Swift suite is **not green**: 29 tests, one existing failure in `testLatestHandshakeOlderThanCutoffIsNotFresh`. Both the cutoff implementation and its test are unchanged from `bdaf0b337b85c815e1dc462505455155b6cdfe79`. ### Draft scope and follow-up This is a draft API/dependency change, not a claim of leak-free operation or uninterrupted traffic on devices. Real Network Extension completion behavior, transport failure with live internet, KillSwitch packet capture, TCP/UDP/DNS continuity, sleep/network changes and Intel runtime tests remain required. Full signed iOS/macOS NE applications have not been built or run. The associated client currently allows additions only in an existing inclusion/exclusion session. Its empty-list/full-tunnel transition, removal, mode switching, automatic reconnect and dynamic domain/CDN rules are outside this draft. After native validation, the client can pin the matching Swift/Go revision and enable the capability. The pre-existing handshake-cutoff failure needs separate resolution. --- <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/amneziawg-apple#53
No description provided.