Treat unsupported option errors specifically
Show a more informative alert if the provided .ovpn file contains an unsupported option.
This commit is contained in:
parent
7151ab8698
commit
d1b0b59748
|
@ -116,6 +116,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
|||
}
|
||||
nav.modalPresentationStyle = .formSheet
|
||||
root.present(nav, animated: true, completion: nil)
|
||||
} catch ApplicationError.unsupportedConfiguration(let option) {
|
||||
let alert = Macros.alert(L10n.Organizer.Sections.Hosts.header, L10n.Wizards.Host.Alerts.unsupported(option))
|
||||
alert.addCancelAction(L10n.Global.ok)
|
||||
root.present(alert, animated: true, completion: nil)
|
||||
} catch {
|
||||
let alert = Macros.alert(L10n.Organizer.Sections.Hosts.header, L10n.Wizards.Host.Alerts.parsing)
|
||||
alert.addCancelAction(L10n.Global.ok)
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
"wizards.host.cells.title_input.placeholder" = "My Profile";
|
||||
"wizards.host.sections.existing.header" = "Existing profiles";
|
||||
"wizards.host.alerts.existing" = "A host profile with the same title already exists. Replace it?";
|
||||
"wizards.host.alerts.unsupported" = "The configuration file contains an unsupported option (%@).";
|
||||
"wizards.host.alerts.parsing" = "Unable to parse the provided configuration file.";
|
||||
|
||||
"service.welcome.message" = "Welcome to Passepartout!\n\nUse the organizer to add a new profile.";
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
enum ApplicationError: String, Error {
|
||||
enum ApplicationError: Error {
|
||||
case missingProfile
|
||||
|
||||
case missingCredentials
|
||||
|
@ -40,5 +40,5 @@ enum ApplicationError: String, Error {
|
|||
|
||||
case emptyRemotes
|
||||
|
||||
case unsupportedConfiguration
|
||||
case unsupportedConfiguration(option: String)
|
||||
}
|
||||
|
|
|
@ -660,6 +660,10 @@ internal enum L10n {
|
|||
internal static let existing = L10n.tr("Localizable", "wizards.host.alerts.existing")
|
||||
/// Unable to parse the provided configuration file.
|
||||
internal static let parsing = L10n.tr("Localizable", "wizards.host.alerts.parsing")
|
||||
/// The configuration file contains an unsupported option (%@).
|
||||
internal static func unsupported(_ p1: String) -> String {
|
||||
return L10n.tr("Localizable", "wizards.host.alerts.unsupported", p1)
|
||||
}
|
||||
}
|
||||
|
||||
internal enum Cells {
|
||||
|
|
|
@ -113,11 +113,8 @@ extension TunnelKitProvider.Configuration {
|
|||
case "key":
|
||||
clientKey = CryptoContainer(pem: currentBlock.joined(separator: "\n"))
|
||||
|
||||
case "tls-auth":
|
||||
unsupportedError = ApplicationError.unsupportedConfiguration
|
||||
|
||||
case "tls-crypt":
|
||||
unsupportedError = ApplicationError.unsupportedConfiguration
|
||||
case "tls-auth", "tls-crypt":
|
||||
unsupportedError = ApplicationError.unsupportedConfiguration(option: blockName)
|
||||
|
||||
default:
|
||||
break
|
||||
|
@ -187,7 +184,7 @@ extension TunnelKitProvider.Configuration {
|
|||
renegotiateAfterSeconds = Int(arg)
|
||||
}
|
||||
Regex.fragment.enumerateArguments(in: line) { (_) in
|
||||
unsupportedError = ApplicationError.unsupportedConfiguration
|
||||
unsupportedError = ApplicationError.unsupportedConfiguration(option: "fragment")
|
||||
}
|
||||
|
||||
if let error = unsupportedError {
|
||||
|
|
Loading…
Reference in New Issue