diff options
Diffstat (limited to '')
4 files changed, 28 insertions, 36 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift b/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift index e7733b3..b9db8e9 100644 --- a/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift +++ b/WireGuard/WireGuard/UI/iOS/ErrorPresenter.swift @@ -10,21 +10,21 @@ class ErrorPresenter { // TunnelManagementError case TunnelManagementError.tunnelAlreadyExistsWithThatName: - return ("Name already in use", "A tunnel with that name already exists. Please pick a different name.") + return ("Name already exists", "A tunnel with that name already exists. Please choose a different name.") case TunnelManagementError.vpnSystemErrorOnAddTunnel: - return ("Could not create tunnel", "Internal error") + return ("Unable to create tunnel", "Internal error") case TunnelManagementError.vpnSystemErrorOnModifyTunnel: - return ("Could not modify tunnel", "Internal error") + return ("Unable to modify tunnel", "Internal error") case TunnelManagementError.vpnSystemErrorOnRemoveTunnel: - return ("Could not remove tunnel", "Internal error") + return ("Unable to remove tunnel", "Internal error") // TunnelActivationError case TunnelActivationError.noEndpoint: return ("Endpoint missing", "There must be at least one peer with an endpoint") case TunnelActivationError.dnsResolutionFailed: - return ("DNS Failure", "One or more endpoint domains could not be resolved") + return ("DNS resolution failure", "One or more endpoint domains could not be resolved") case TunnelActivationError.tunnelActivationFailed: - return ("Activation failed", "The tunnel could not be activated because of an internal error") + return ("Activation failure", "The tunnel could not be activated due to an internal error") case TunnelActivationError.attemptingActivationWhenAnotherTunnelIsBusy(let otherTunnelStatus): let statusString: String = { switch (otherTunnelStatus) { @@ -41,7 +41,7 @@ class ErrorPresenter { fatalError() } }() - return ("Activation failed", "Another tunnel is currently \(statusString). Only one tunnel can be in operation at a time.") + return ("Activation failure", "Another tunnel is currently \(statusString). Only one tunnel may be in operation at a time.") default: os_log("ErrorPresenter: Error not presented: %{public}@", log: OSLog.default, type: .error, "\(error)") diff --git a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift index 99af984..a65c712 100644 --- a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift @@ -40,7 +40,7 @@ class QRScanViewController: UIViewController { let captureSession = captureSession, captureSession.canAddInput(videoInput), captureSession.canAddOutput(metadataOutput) else { - scanDidEncounterError(title: "Scanning Not Supported", message: "This device does not have the ability to scan QR codes.") + scanDidEncounterError(title: "Camera Unsupported", message: "This device is not able to scan QR codes.") return } @@ -108,11 +108,11 @@ class QRScanViewController: UIViewController { func scanDidComplete(withCode code: String) { let scannedTunnelConfiguration = try? WgQuickConfigFileParser.parse(code, name: "Scanned") guard let tunnelConfiguration = scannedTunnelConfiguration else { - scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.") + scanDidEncounterError(title: "Invalid QR Code", message: "The scanned QR code is not a valid WireGuard configuration.") return } - let alert = UIAlertController(title: NSLocalizedString("Enter a title for new tunnel", comment: ""), message: nil, preferredStyle: .alert) + let alert = UIAlertController(title: NSLocalizedString("Please name the scanned tunnel", comment: ""), message: nil, preferredStyle: .alert) alert.addTextField(configurationHandler: nil) alert.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)) alert.addAction(UIAlertAction(title: NSLocalizedString("Save", comment: ""), style: .default, handler: { [weak self] _ in diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift index edb3a60..fa5f6d0 100644 --- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift @@ -46,7 +46,7 @@ class SettingsTableViewController: UITableViewController { func exportConfigurationsAsZipFile(sourceView: UIView) { guard let tunnelsManager = tunnelsManager, tunnelsManager.numberOfTunnels() > 0 else { - showErrorAlert(title: "Nothing to export", message: "There are no tunnel configurations to export") + showErrorAlert(title: "Nothing to export", message: "There are no tunnels to export") return } var inputsToArchiver: [(fileName: String, contents: Data)] = [] @@ -76,21 +76,15 @@ class SettingsTableViewController: UITableViewController { os_log("Failed to delete file: %{public}@ : %{public}@", log: OSLog.default, type: .error, destinationURL.absoluteString, error.localizedDescription) } - var ok = false do { try ZipArchive.archive(inputs: inputsToArchiver, to: destinationURL) - ok = true - } catch { - os_log("Failed to create archive: %{public}@ : %{public}@", log: OSLog.default, type: .error, destinationURL.absoluteString) - } - - if (ok) { let activityVC = UIActivityViewController(activityItems: [destinationURL], applicationActivities: nil) // popoverPresentationController shall be non-nil on the iPad activityVC.popoverPresentationController?.sourceView = sourceView present(activityVC, animated: true) - } else { - showErrorAlert(title: "Could not export", message: "There was an error creating the tunnel configuration archive") + + } catch (let error) { + showErrorAlert(title: "Unable to export", message: "There was an error exporting the tunnel configuration archive: \(String(describing: error))") } } diff --git a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift index 66b404c..d142ea4 100644 --- a/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/TunnelsListTableViewController.swift @@ -42,15 +42,13 @@ class TunnelsListTableViewController: UITableViewController { } @objc func addButtonTapped(sender: UIBarButtonItem!) { - let alert = UIAlertController(title: "", - message: "Add a tunnel", - preferredStyle: .actionSheet) - let importFileAction = UIAlertAction(title: "Import file or archive", style: .default) { [weak self] (action) in + let alert = UIAlertController(title: "", message: "Add a new WireGuard tunnel", preferredStyle: .actionSheet) + let importFileAction = UIAlertAction(title: "Create from file or archive", style: .default) { [weak self] (action) in self?.presentViewControllerForFileImport() } alert.addAction(importFileAction) - let scanQRCodeAction = UIAlertAction(title: "Scan QR code", style: .default) { [weak self] (action) in + let scanQRCodeAction = UIAlertAction(title: "Create from QR code", style: .default) { [weak self] (action) in self?.presentViewControllerForScanningQRCode() } alert.addAction(scanQRCodeAction) @@ -83,8 +81,8 @@ class TunnelsListTableViewController: UITableViewController { do { let fileContents = try String(contentsOf: configFileURL) try tunnelConfiguration = WgQuickConfigFileParser.parse(fileContents, name: name) - } catch { - showErrorAlert(title: "Could not import config", message: "There was an error importing the config file") + } catch (let error) { + showErrorAlert(title: "Unable to import tunnel", message: "An error occured when importing the tunnel configuration: \(String(describing: error))") return } tunnelConfiguration?.interface.name = name @@ -140,18 +138,18 @@ class TunnelsListTableViewController: UITableViewController { } } } else { - showErrorAlert(title: "Could not import", message: "The config file contained errors") + showErrorAlert(title: "Unable to import tunnel", message: "An error occured when importing the tunnel configuration.") } } else if (url.pathExtension == "zip") { var unarchivedFiles: [(fileName: String, contents: Data)] = [] do { unarchivedFiles = try ZipArchive.unarchive(url: url, requiredFileExtensions: ["conf"]) } catch ZipArchiveError.cantOpenInputZipFile { - showErrorAlert(title: "Cannot read zip archive", message: "The zip file couldn't be read") + showErrorAlert(title: "Unable to read zip archive", message: "The zip archive could not be read") } catch ZipArchiveError.badArchive { - showErrorAlert(title: "Cannot read zip archive", message: "Bad archive") + showErrorAlert(title: "Unable to read zip archive", message: "Bad or corrupt zip archive") } catch (let error) { - print("Error opening zip archive: \(error)") + showErrorAlert(title: "Unable to read zip archive", message: "Unexpected error: \(String(describing: error))") } var numberOfConfigFilesWithErrors = 0 var tunnelConfigurationsToAdd: [TunnelConfiguration] = [] @@ -167,7 +165,7 @@ class TunnelsListTableViewController: UITableViewController { } } guard (tunnelConfigurationsToAdd.count > 0) else { - showErrorAlert(title: "No configurations found", message: "Zip archive doesn't contain any valid .conf files") + showErrorAlert(title: "No configurations found", message: "Zip archive does not contain any valid .conf files") return } var numberOfTunnelsRemainingAfterError = 0 @@ -179,8 +177,8 @@ class TunnelsListTableViewController: UITableViewController { } } if (numberOfConfigFilesWithErrors > 0) { - showErrorAlert(title: "Could not import \(numberOfConfigFilesWithErrors + numberOfTunnelsRemainingAfterError) files", - message: "\(numberOfConfigFilesWithErrors) of \(unarchivedFiles.count) files contained errors or duplicate names and were not imported") + showErrorAlert(title: "Created \(unarchivedFiles.count) tunnels", + message: "Created \(numberOfTunnelsRemainingAfterError) of \(unarchivedFiles.count) tunnels from files in zip archive") } } } @@ -254,8 +252,8 @@ extension TunnelsListTableViewController { } } } else { - tunnelsManager.startDeactivation(of: tunnel) { error in - print("Error while deactivating: \(String(describing: error))") + tunnelsManager.startDeactivation(of: tunnel) { [weak s] error in + s?.showErrorAlert(title: "Deactivation error", message: "Error while bringing down tunnel: \(String(describing: error))") } } } |