aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-12 17:37:14 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-12 17:37:27 +0530
commit078780a3bafa91cdf903a8d9d0ab4120ff317cab (patch)
treec65b5cfeaa30812d420fd6c1d9412ec8061e686e /WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
parentInfo.plist: Localize with InfoPlist.strings (diff)
downloadwireguard-apple-078780a3bafa91cdf903a8d9d0ab4120ff317cab.tar.xz
wireguard-apple-078780a3bafa91cdf903a8d9d0ab4120ff317cab.zip
Don't migrate in asTunnelConfiguration()
It causes problems when installing a tunnel through a Configuration Profile on macOS and activating it first through Network Preferences.
Diffstat (limited to 'WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift')
-rw-r--r--WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift19
1 files changed, 8 insertions, 11 deletions
diff --git a/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
index 7345794..a57d5ff 100644
--- a/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
+++ b/WireGuard/Shared/Model/NETunnelProviderProtocol+Extension.swift
@@ -34,17 +34,14 @@ extension NETunnelProviderProtocol {
}
func asTunnelConfiguration(called name: String? = nil) -> TunnelConfiguration? {
- migrateConfigurationIfNeeded(called: name ?? "unknown")
- //TODO: in the case where migrateConfigurationIfNeeded is called by the network extension,
- // before the app has started, and when there is, in fact, configuration that needs to be
- // put into the keychain, this will generate one new keychain item every time it is started,
- // until finally the app is open. Would it be possible to call saveToPreferences here? Or is
- // that generally not available to network extensions? In which case, what should our
- // behavior be?
-
- guard let passwordReference = passwordReference else { return nil }
- guard let config = Keychain.openReference(called: passwordReference) else { return nil }
- return try? TunnelConfiguration(fromWgQuickConfig: config, called: name)
+ if let passwordReference = passwordReference,
+ let config = Keychain.openReference(called: passwordReference) {
+ return try? TunnelConfiguration(fromWgQuickConfig: config, called: name)
+ }
+ if let oldConfig = providerConfiguration?["WgQuickConfig"] as? String {
+ return try? TunnelConfiguration(fromWgQuickConfig: oldConfig, called: name)
+ }
+ return nil
}
func destroyConfigurationReference() {