macOS: support multiple simultaneous tunnels
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v1 Latest posting 2/210 patches 0 repliesNew
- v1 posting 1/27 patches 0 repliesSuperseded
Patches in v1 posting 2/2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/10 | WireGuardKitC: include sys/types.h for BSD type definitionsSources/ | +2 | 0 replies | |
| 2/10 | TunnelsManager: drop the restart intent when deactivation is requestedSources/ | +5 | 0 replies | |
| 3/10 | WireGuardKit: attach each adapter to its own utun deviceSources/ | +103 | 0 replies | |
| 4/10 | TunnelsManager: restrict single-tunnel activation policy to iOSSources/ | +21 | 0 replies | |
| 5/10 | PacketTunnelProvider: only exit on stop of last tunnel in the processSources/ | +49 | 0 replies | |
| 6/10 | macOS: support multiple simultaneous tunnels in the menu bar UISources/ Sources/ Sources/ +2 more | +68 | 0 replies | |
| 7/10 | Add opt-in split DNS supportSources/ Sources/ Sources/ +5 more | +125 | 0 replies | |
| 8/10 | macOS: activate the app before showing a modal alert without a windowSources/ | +5 | 0 replies | |
| 9/10 | macOS: don't crash opening the editor for an unreadable tunnelSources/ Sources/ | +8 | 0 replies | |
| 10/10 | macOS: reset peer endpoints after a network changeSources/ Sources/ | +99 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RESEND PATCH wireguard-apple 00/10] macOS: support multiple simultaneous tunnels
This is a resend. I first sent this series on July 10, and two follow-up fixes on July 25, but none of the messages made it out of the list's moderation queue, so they never reached the archive. The patches are unchanged; the same commits are also on a branch and as a pull request on the GitHub mirror, if either is easier to pull from:
https://github.com/cremenescu/wireguard-apple/tree/macos-multiple-tunnels
https://github.com/WireGuard/wireguard-apple/pull/63
macOS, unlike iOS, can run multiple packet tunnel provider sessions at the same time, but the app serializes activation on both platforms: activating one tunnel deactivates the tunnel already in operation. On iOS that mirrors an OS restriction. On macOS it is purely app policy, and macOS users routinely need several disjoint split tunnels up at once.
Lifting the policy alone is not enough. When two sessions run in one extension process, each WireGuardAdapter locates its tunnel device by taking the first utun control socket in the process, so the second tunnel attaches to the first tunnel's device and passes no traffic. This looks like the failure reported on this list in July 2021 ("Running multiple tunnels simultaneously on macOS"), where two tunnels both reached Connected but only one passed traffic. Patch 3 fixes the device attachment; patches 4-6 then lift the single-tunnel policy on macOS while keeping iOS behaviour exactly as it is today.
The first two patches are independent fixes that the series happens to need:
a build fix for the strict module verifier in current Xcode, and a fix for an explicit deactivation losing against a pending restart.
Patch 7 adds an opt-in per-tunnel split DNS toggle. With several tunnels up, tunnels that install their DNS servers as the system-wide resolver fight over it; the toggle lets a tunnel's DNS servers be used only for that tunnel's DNS search domains. Existing full-tunnel setups keep their match-everything DNS by default. A related DNSMatchDomains approach was posted here in April 2024; this variant keeps the wg-quick config text untouched and portable, and gates the behaviour on an explicit opt-in.
Patches 8-10 are robustness fixes found while running the result daily: an alert that came up invisibly behind everything on a menu bar app, a crash opening the editor for a tunnel whose saved configuration cannot be read, and endpoints that were never set again after a network change. That last one is worth a number: a peer that had roamed to an address only reachable on the previous network went from 2 completed handshakes out of 130 attempts to 83 out of 129.
Tested on macOS 26 with Xcode 26: multiple concurrent tunnels passing traffic simultaneously on disjoint AllowedIPs, deactivating one tunnel leaving the others up, and DNS resolution verified with and without DNS= entries as well as with split DNS enabled. Every patch builds for both macOS and iOS on its own, so the series stays bisectable.
I would also be glad to help maintain wireguard-apple if that is useful - the repositories page says you would welcome someone taking it over.
Razvan Cremenescu (10):
WireGuardKitC: include sys/types.h for BSD type definitions
TunnelsManager: drop the restart intent when deactivation is requested
WireGuardKit: attach each adapter to its own utun device
TunnelsManager: restrict single-tunnel activation policy to iOS
PacketTunnelProvider: only exit on stop of last tunnel in the process
macOS: support multiple simultaneous tunnels in the menu bar UI Add opt-in split DNS support
macOS: activate the app before showing a modal alert without a window
macOS: don't crash opening the editor for an unreadable tunnel
macOS: reset peer endpoints after a network change
.../NETunnelProviderProtocol+Extension.swift | 26 +++ .../Base.lproj/Localizable.strings | 12 ++ .../WireGuardApp/Tunnel/TunnelsManager.swift | 43 ++++- .../TunnelEditTableViewController.swift | 39 +++- .../WireGuardApp/UI/macOS/AppDelegate.swift | 31 ++- .../UI/macOS/ErrorPresenter.swift | 5 + .../UI/macOS/StatusItemController.swift | 14 +- .../WireGuardApp/UI/macOS/StatusMenu.swift | 25 ++- .../UI/macOS/TunnelsTracker.swift | 31 ++- .../TunnelDetailTableViewController.swift | 7 + .../TunnelEditViewController.swift | 21 ++- .../PacketTunnelSettingsGenerator.swift | 59 +++++- Sources/WireGuardKit/WireGuardAdapter.swift | 176 +++++++++++++++++- Sources/WireGuardKitC/WireGuardKitC.h | 2 + .../PacketTunnelProvider.swift | 52 +++++- 15 files changed, 485 insertions(+), 58 deletions(-)
Signature · 1 line
2.50.1 (Apple Git-155)