aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorEric Kuck <eric@bluelinelabs.com>2018-12-21 12:51:14 -0600
committerEric Kuck <eric@bluelinelabs.com>2018-12-21 12:51:14 -0600
commitf6af9d9ffbc3dae8c387a0eacf811d58ee6e4605 (patch)
treeae6563a1e5a37fb3c8856b627062e81443d0eb97 /WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
parentSimplify versioning of stored data (diff)
downloadwireguard-apple-f6af9d9ffbc3dae8c387a0eacf811d58ee6e4605.tar.xz
wireguard-apple-f6af9d9ffbc3dae8c387a0eacf811d58ee6e4605.zip
All migration stuff moved to one gross file
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/Shared/NETunnelProviderProtocol+Extension.swift20
1 files changed, 0 insertions, 20 deletions
diff --git a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
index 7d6e412d..6f4e3eb0 100644
--- a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
+++ b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
@@ -52,24 +52,4 @@ extension NETunnelProviderProtocol {
return serializedThisTunnelConfiguration == serializedOtherTunnelConfiguration
}
- @discardableResult
- func migrateConfigurationIfNeeded() -> Bool {
- guard let configurationVersion = providerConfiguration?["tunnelConfigurationVersion"] as? Int else { return false }
- if configurationVersion == 1 {
- migrateFromConfigurationV1()
- } else {
- fatalError("No migration from configuration version \(configurationVersion) exists.")
- }
- return true
- }
-
- 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 tunnelConfigData = try? JSONEncoder().encode(configuration.migrated) else { return }
- guard let tunnelConfigDictionary = try? JSONSerialization.jsonObject(with: tunnelConfigData, options: .allowFragments) else { return }
-
- providerConfiguration = [ Keys.wgQuickConfig.rawValue: tunnelConfigDictionary ]
- }
-
}