Merge branch 'discern-unsupported-option-alert'

This commit is contained in:
Davide De Rosa 2018-10-16 18:03:45 +02:00
commit e7eab45fdc
5 changed files with 14 additions and 8 deletions

View File

@ -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)

View File

@ -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.";

View File

@ -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)
}

View File

@ -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 {

View File

@ -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 {