aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-21 18:50:32 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-21 18:50:32 +0100
commitec031b1f19c7b85b52ef478b8dfe3f8e173cf046 (patch)
treec8c6e394d51a8c977c0f3b73f4389755a4fa4842 /WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
parentUpdated NETunnelProvider save format (diff)
downloadwireguard-apple-ec031b1f19c7b85b52ef478b8dfe3f8e173cf046.tar.xz
wireguard-apple-ec031b1f19c7b85b52ef478b8dfe3f8e173cf046.zip
Get rid of superflous isActivateOnDemandEnabled key
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/Shared/NETunnelProviderProtocol+Extension.swift14
1 files changed, 3 insertions, 11 deletions
diff --git a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
index e5cfac88..3a9bc38b 100644
--- a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
+++ b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
@@ -10,7 +10,6 @@ extension NETunnelProviderProtocol {
enum Keys: String {
case tunnelConfiguration = "TunnelConfiguration"
case tunnelConfigurationVersion = "TunnelConfigurationVersion"
- case isActivateOnDemandEnabled = "IsActivateOnDemandEnabled"
}
var tunnelConfiguration: TunnelConfiguration? {
@@ -27,11 +26,7 @@ extension NETunnelProviderProtocol {
return try? JSONDecoder().decode(TunnelConfiguration.self, from: tunnelConfigurationData!)
}
- var isActivateOnDemandEnabled: Bool {
- return providerConfiguration?[Keys.isActivateOnDemandEnabled.rawValue] as? Bool ?? false
- }
-
- convenience init?(tunnelConfiguration: TunnelConfiguration, isActivateOnDemandEnabled: Bool) {
+ convenience init?(tunnelConfiguration: TunnelConfiguration) {
assert(!tunnelConfiguration.interface.name.isEmpty)
guard let tunnelConfigData = try? JSONEncoder().encode(tunnelConfiguration) else { return nil }
@@ -43,8 +38,7 @@ extension NETunnelProviderProtocol {
providerBundleIdentifier = "\(appId).network-extension"
providerConfiguration = [
Keys.tunnelConfiguration.rawValue: tunnelConfigDictionary,
- Keys.tunnelConfigurationVersion.rawValue: tunnelConfigurationVersion,
- Keys.isActivateOnDemandEnabled.rawValue: isActivateOnDemandEnabled
+ Keys.tunnelConfigurationVersion.rawValue: tunnelConfigurationVersion
]
let endpoints = tunnelConfiguration.peers.compactMap { $0.endpoint }
@@ -85,14 +79,12 @@ extension NETunnelProviderProtocol {
private func migrateFromConfigurationV1() {
guard let serializedTunnelConfiguration = providerConfiguration?["tunnelConfiguration"] as? Data else { return }
guard let configuration = try? JSONDecoder().decode(LegacyTunnelConfiguration.self, from: serializedTunnelConfiguration) else { return }
- guard let isActivateOnDemandEnabled = providerConfiguration?["isActivateOnDemandEnabled"] as? Bool else { return }
guard let tunnelConfigData = try? JSONEncoder().encode(configuration.migrated) else { return }
guard let tunnelConfigDictionary = try? JSONSerialization.jsonObject(with: tunnelConfigData, options: .allowFragments) else { return }
providerConfiguration = [
Keys.tunnelConfiguration.rawValue: tunnelConfigDictionary,
- Keys.tunnelConfigurationVersion.rawValue: tunnelConfigurationVersion,
- Keys.isActivateOnDemandEnabled.rawValue: isActivateOnDemandEnabled
+ Keys.tunnelConfigurationVersion.rawValue: tunnelConfigurationVersion
]
}