Skip to content

Commit

Permalink
Merge branch 'bugfix/network-protection-ios17' into staging-2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Oct 19, 2023
2 parents 1766d10 + 5e1a6ba commit 0f70852
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions IVPNClient/Managers/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,35 @@ extension StorageManager {
return nil
}

private static func probeURL() -> URL? {
let isNetworkProtection = UserDefaults.shared.networkProtectionEnabled
let probeURL = URL(string: "https://\(Config.ApiHostName)\(Config.apiServersFile)")
return isNetworkProtection ? probeURL : nil
}

private static func getDefaultOnDemandRule(status: NEVPNStatus) -> NEOnDemandRule? {
let defaultTrust = getDefaultTrust()

if defaultTrust == NetworkTrust.Untrusted.rawValue {
return NEOnDemandRuleConnect()
let onDemandRule = NEOnDemandRuleConnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
}
if defaultTrust == NetworkTrust.Trusted.rawValue {
return NEOnDemandRuleDisconnect()
let onDemandRule = NEOnDemandRuleDisconnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
}

switch status {
case .connected:
return NEOnDemandRuleConnect()
let onDemandRule = NEOnDemandRuleConnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
case .disconnected, .invalid:
return NEOnDemandRuleDisconnect()
let onDemandRule = NEOnDemandRuleDisconnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
default:
return nil
}
Expand Down

0 comments on commit 0f70852

Please sign in to comment.