Skip to content

Commit

Permalink
Only consider managers stale on Catalyst, not on iOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed Jan 19, 2024
1 parent 4241c9b commit 8e790d3
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ public enum TunnelProviderKeys {
public extension NETunnelProviderManager {
// Checks if the configuration has gone stale, which means clients should discard it.
var isStale: Bool {
// When moving from macOS to Mac Catalyst, we need to delete the existing profile and create a new
// one. We track such "stale" profiles by a version on the provider configuration.
if let protocolConfiguration = protocolConfiguration as? NETunnelProviderProtocol {
var providerConfig: [String: Any] = protocolConfiguration.providerConfiguration ?? [:]
let version = providerConfig[TunnelProviderKeys.keyVersion, default: 0] as! Int
return version != 1
}
return true
#if targetEnvironment(macCatalyst)
// When migrating from macOS to Mac Catalyst, we can't use managers created by the macOS app.
// Instead, we need to create a new one. We track such "stale" managers by a version on the
// provider configuration.
if let protocolConfiguration = protocolConfiguration as? NETunnelProviderProtocol {
var providerConfig: [String: Any] = protocolConfiguration.providerConfiguration ?? [:]
let version = providerConfig[TunnelProviderKeys.keyVersion, default: 0] as! Int
return version != 1
}
return true
#else
return false
#endif
}

Check warning on line 38 in src/cordova/apple/OutlineAppleLib/Sources/OutlineTunnel/NETunnelProviderManager+Outline.swift

View check run for this annotation

Codecov / codecov/patch

src/cordova/apple/OutlineAppleLib/Sources/OutlineTunnel/NETunnelProviderManager+Outline.swift#L24-L38

Added lines #L24 - L38 were not covered by tests

var autoConnect: Bool {
Expand Down

0 comments on commit 8e790d3

Please sign in to comment.