diff --git a/ios/NebulaNetworkExtension/PacketTunnelProvider.swift b/ios/NebulaNetworkExtension/PacketTunnelProvider.swift index 07c1cb1..dffb054 100644 --- a/ios/NebulaNetworkExtension/PacketTunnelProvider.swift +++ b/ios/NebulaNetworkExtension/PacketTunnelProvider.swift @@ -52,14 +52,20 @@ class PacketTunnelProvider: NEPacketTunnelProvider { var config: Data var key: String - manager = try await self.findManager() - - guard let foundManager = manager else { - throw VPNStartError.couldNotFindManager - } - do { - self.site = try Site(manager: foundManager) + // Cannot use NETunnelProviderManager.loadAllFromPreferences() in earlier versions of iOS + // TODO: Remove else once we drop support for iOS 16 + if ProcessInfo().isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 17, minorVersion: 0, patchVersion: 0)) { + manager = try await self.findManager() + guard let foundManager = manager else { + throw VPNStartError.couldNotFindManager + } + self.site = try Site(manager: foundManager) + } else { + // This does not save the manager with the site, which means we cannot update the + // vpn profile name when updates happen (rare). + self.site = try Site(proto: self.protocolConfiguration as! NETunnelProviderProtocol) + } config = try self.site!.getConfig() } catch { //TODO: need a way to notify the app diff --git a/ios/Runner/DNUpdate.swift b/ios/Runner/DNUpdate.swift index 5b59e27..fd566ea 100644 --- a/ios/Runner/DNUpdate.swift +++ b/ios/Runner/DNUpdate.swift @@ -63,7 +63,10 @@ class DNUpdater { return } - newSite?.save(manager: site.manager) { error in + let siteManager = site.manager + let shouldSaveToManager = siteManager != nil || ProcessInfo().isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 17, minorVersion: 0, patchVersion: 0)) + + newSite?.save(manager: site.manager, saveToManager: shouldSaveToManager) { error in if (error != nil) { self.log.error("failed to save update: \(error!.localizedDescription, privacy: .public)") }