aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-19 16:02:48 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-19 18:35:53 +0530
commitbba6d2f9195214d79621159fc1e323206a611845 (patch)
treeebafa19507c91f7b4a7aed97ab89000bd253bb7c /WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
parentNE: Handle bad domain names and Activate On Demand (diff)
downloadwireguard-apple-bba6d2f9195214d79621159fc1e323206a611845.tar.xz
wireguard-apple-bba6d2f9195214d79621159fc1e323206a611845.zip
TunnelsManager: If only Activate On Demand has changed, don't restart tunnel
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/Shared/NETunnelProviderProtocol+Extension.swift6
1 files changed, 6 insertions, 0 deletions
diff --git a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
index 9f4af774..776e03b2 100644
--- a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
+++ b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
@@ -37,4 +37,10 @@ extension NETunnelProviderProtocol {
var isActivateOnDemandEnabled: Bool {
return (providerConfiguration?["isActivateOnDemandEnabled"] as? Bool) ?? false
}
+
+ func hasTunnelConfiguration(tunnelConfiguration otherTunnelConfiguration: TunnelConfiguration) -> Bool {
+ guard let serializedThisTunnelConfiguration = providerConfiguration?["tunnelConfiguration"] as? Data else { return false }
+ guard let serializedOtherTunnelConfiguration = try? JSONEncoder().encode(otherTunnelConfiguration) else { return false }
+ return serializedThisTunnelConfiguration == serializedOtherTunnelConfiguration
+ }
}