From 990fde53254e249bbd1ad2006d070865e67bd4ee Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 11 Jan 2024 00:15:06 +0100 Subject: [PATCH] On-demand not applying to wired connections (#463) Condition is `#if os(macOS)`, but a Catalyst app is actually `os(iOS)`, so the code adding the Ethernet rule was being ignored. --- CHANGELOG.md | 1 + .../PassepartoutVPNImpl/Extensions/OnDemand+Rules.swift | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ceb4032..6725f141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - "Restore purchases" not working. [#459](https://github.com/passepartoutvpn/passepartout-apple/issues/459) - Purchase is not credited if any refund was issued in the past. [#461](https://github.com/passepartoutvpn/passepartout-apple/issues/461) +- On-demand not applying to wired connections. [#463](https://github.com/passepartoutvpn/passepartout-apple/pull/463) ## 2.3.2 (2024-01-10) diff --git a/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Extensions/OnDemand+Rules.swift b/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Extensions/OnDemand+Rules.swift index ab1dd00d..63c0eade 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Extensions/OnDemand+Rules.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPNImpl/Extensions/OnDemand+Rules.swift @@ -63,7 +63,7 @@ private extension Profile.OnDemand { rules.append(cellularRule()) } #endif - #if os(macOS) + #if targetEnvironment(macCatalyst) || os(macOS) if Utils.hasEthernet() && withEthernetNetwork { if let rule = ethernetRule() { rules.append(rule) @@ -81,6 +81,11 @@ private extension Profile.OnDemand { // IMPORTANT: append fallback rule last rules.append(globalRule()) + pp_log.debug("On-demand rules:") + rules.forEach { + pp_log.debug("\($0)") + } + return rules } } @@ -118,7 +123,7 @@ private extension Profile.OnDemand { } #endif - #if os(macOS) + #if targetEnvironment(macCatalyst) || os(macOS) func ethernetRule() -> NEOnDemandRule? { guard let compatibleEthernet = NEOnDemandRuleInterfaceType.compatibleEthernet else { return nil