Commit 9ab0f8a4 authored by Jose Blaya's avatar Jose Blaya
Browse files

Force migration to GEN4

parent 7d6a0aa1
......@@ -117,6 +117,14 @@ public protocol VPNProvider: class {
- Parameter callback: Returns the `Usage` information on success.
*/
func dataUsage(_ callback: LibraryCallback<Usage>?)
/**
Check if the VPN profile needs to be migrated to GEN4.
- Precondition: isVPNConnected == true
- Returns: `Bool`
*/
func needsMigrationToGEN4() -> Bool
}
public extension VPNProvider {
......
......@@ -22,6 +22,7 @@
import Foundation
import __PIALibraryNative
import NetworkExtension
class DefaultVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess, PreferencesAccess, ProvidersAccess, WebServicesAccess {
......@@ -364,4 +365,17 @@ class DefaultVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess, Pref
var webServices: WebServices {
return customWebServices ?? accessedWebServices
}
// MARK: Migration
func needsMigrationToGEN4() -> Bool {
if isVPNConnected {
let manager = NEVPNManager.shared()
if let protocolConfiguration = manager.protocolConfiguration,
let address = protocolConfiguration.serverAddress,
address.contains("privateinternetaccess.com") {
return true
}
}
return false
}
}
......@@ -141,4 +141,8 @@ public class MockVPNProvider: VPNProvider, ConfigurationAccess, DatabaseAccess {
public func dataUsage(_ callback: LibraryCallback<Usage>?) {
callback?(nil, ClientError.unsupported)
}
public func needsMigrationToGEN4() -> Bool {
return false
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment