Stop to download additional provider resources
This commit is contained in:
parent
0507b8324a
commit
2f09a41d06
|
@ -247,7 +247,14 @@ class ServiceViewController: UIViewController, TableModelHost {
|
||||||
}
|
}
|
||||||
vpn.reconnect { (error) in
|
vpn.reconnect { (error) in
|
||||||
guard error == nil else {
|
guard error == nil else {
|
||||||
|
|
||||||
|
// XXX: delay to avoid weird toggle state
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {
|
||||||
cell.setOn(false, animated: true)
|
cell.setOn(false, animated: true)
|
||||||
|
if error as? ApplicationError == .externalResources {
|
||||||
|
self.requireDownload()
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.reloadModel()
|
self.reloadModel()
|
||||||
|
@ -439,6 +446,27 @@ class ServiceViewController: UIViewController, TableModelHost {
|
||||||
IssueReporter.shared.present(in: self, withAttachments: attach)
|
IssueReporter.shared.present(in: self, withAttachments: attach)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func requireDownload() {
|
||||||
|
guard let providerProfile = profile as? ProviderConnectionProfile else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard let downloadURL = AppConstants.URLs.externalResources[providerProfile.name] else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let alert = Macros.alert(
|
||||||
|
L10n.Service.Alerts.Download.title,
|
||||||
|
L10n.Service.Alerts.Download.message(providerProfile.name.rawValue)
|
||||||
|
)
|
||||||
|
alert.addCancelAction(L10n.Global.cancel)
|
||||||
|
alert.addDefaultAction(L10n.Global.ok) {
|
||||||
|
|
||||||
|
// FIXME: start external download
|
||||||
|
print(downloadURL)
|
||||||
|
}
|
||||||
|
present(alert, animated: true, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Notifications
|
// MARK: Notifications
|
||||||
|
|
||||||
@objc private func vpnDidUpdate() {
|
@objc private func vpnDidUpdate() {
|
||||||
|
|
|
@ -132,6 +132,8 @@
|
||||||
"service.alerts.data_count.messages.not_available" = "Information not available, are you connected?";
|
"service.alerts.data_count.messages.not_available" = "Information not available, are you connected?";
|
||||||
"service.alerts.masks_private_data.messages.must_reconnect" = "In order to safely reset the current debug log and apply the new masking preference, you must reconnect to the VPN now.";
|
"service.alerts.masks_private_data.messages.must_reconnect" = "In order to safely reset the current debug log and apply the new masking preference, you must reconnect to the VPN now.";
|
||||||
"service.alerts.buttons.reconnect" = "Reconnect";
|
"service.alerts.buttons.reconnect" = "Reconnect";
|
||||||
|
"service.alerts.download.title" = "Download required";
|
||||||
|
"service.alerts.download.message" = "%@ requires the download of additional configuration files.\n\nConfirm to start the download.";
|
||||||
|
|
||||||
"account.sections.credentials.header" = "Credentials";
|
"account.sections.credentials.header" = "Credentials";
|
||||||
"account.sections.guidance.footer.infrastructure.mullvad" = "Use your %@ website account number and password \"m\".";
|
"account.sections.guidance.footer.infrastructure.mullvad" = "Use your %@ website account number and password \"m\".";
|
||||||
|
|
|
@ -202,6 +202,8 @@ public class AppConstants {
|
||||||
.tunnelBear: "https://click.tunnelbear.com/aff_c?offer_id=2&aff_id=7464",
|
.tunnelBear: "https://click.tunnelbear.com/aff_c?offer_id=2&aff_id=7464",
|
||||||
.windscribe: "https://secure.link/kCsD0prd"
|
.windscribe: "https://secure.link/kCsD0prd"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
public static let externalResources: [Infrastructure.Name: String] = [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Repos {
|
public class Repos {
|
||||||
|
|
|
@ -33,4 +33,6 @@ public enum ApplicationError: String, Error {
|
||||||
case migration
|
case migration
|
||||||
|
|
||||||
case inactiveProfile
|
case inactiveProfile
|
||||||
|
|
||||||
|
case externalResources
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
|
||||||
do {
|
do {
|
||||||
try preset.injectExternalConfiguration(&builder, with: name, pool: pool)
|
try preset.injectExternalConfiguration(&builder, with: name, pool: pool)
|
||||||
} catch {
|
} catch {
|
||||||
fatalError("Could not find external preset resources")
|
throw ApplicationError.externalResources
|
||||||
}
|
}
|
||||||
|
|
||||||
if let address = manualAddress {
|
if let address = manualAddress {
|
||||||
|
|
|
@ -593,6 +593,14 @@ public enum L10n {
|
||||||
public static let notAvailable = L10n.tr("Localizable", "service.alerts.data_count.messages.not_available")
|
public static let notAvailable = L10n.tr("Localizable", "service.alerts.data_count.messages.not_available")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public enum Download {
|
||||||
|
/// %@ requires the download of additional configuration files.\n\nConfirm to start the download.
|
||||||
|
public static func message(_ p1: String) -> String {
|
||||||
|
return L10n.tr("Localizable", "service.alerts.download.message", p1)
|
||||||
|
}
|
||||||
|
/// Download required
|
||||||
|
public static let title = L10n.tr("Localizable", "service.alerts.download.title")
|
||||||
|
}
|
||||||
public enum MasksPrivateData {
|
public enum MasksPrivateData {
|
||||||
public enum Messages {
|
public enum Messages {
|
||||||
/// In order to safely reset the current debug log and apply the new masking preference, you must reconnect to the VPN now.
|
/// In order to safely reset the current debug log and apply the new masking preference, you must reconnect to the VPN now.
|
||||||
|
|
|
@ -75,6 +75,10 @@ public class GracefulVPN {
|
||||||
log.info("Reconnecting...")
|
log.info("Reconnecting...")
|
||||||
try vpn.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn.reconnect(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
} catch let e {
|
} catch let e {
|
||||||
|
guard e as? ApplicationError != .externalResources else {
|
||||||
|
completionHandler?(e)
|
||||||
|
return
|
||||||
|
}
|
||||||
log.error("Could not reconnect: \(e)")
|
log.error("Could not reconnect: \(e)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,6 +93,10 @@ public class GracefulVPN {
|
||||||
log.info("Reinstalling...")
|
log.info("Reinstalling...")
|
||||||
try vpn.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
try vpn.install(configuration: service.vpnConfiguration(), completionHandler: completionHandler)
|
||||||
} catch let e {
|
} catch let e {
|
||||||
|
guard e as? ApplicationError != .externalResources else {
|
||||||
|
completionHandler?(e)
|
||||||
|
return
|
||||||
|
}
|
||||||
log.error("Could not reinstall: \(e)")
|
log.error("Could not reinstall: \(e)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue