TunnelsManager: If only Activate On Demand has changed, don't restart tunnel

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-12-19 18:35:53 +05:30
parent fa51e3f1d1
commit bba6d2f919
2 changed files with 17 additions and 6 deletions
@@ -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
}
}