From ec031b1f19c7b85b52ef478b8dfe3f8e173cf046 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 21 Dec 2018 18:50:32 +0100 Subject: Get rid of superflous isActivateOnDemandEnabled key Signed-off-by: Jason A. Donenfeld --- WireGuard/Shared/NETunnelProviderProtocol+Extension.swift | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'WireGuard/Shared/NETunnelProviderProtocol+Extension.swift') diff --git a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift index e5cfac8..3a9bc38 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 ] } -- cgit v1.2.3-59-g8ed1b