aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/Tunnel
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-22 16:05:35 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-22 16:05:43 +0530
commite6e1795d08e52fcf45f3cdc2ab0452560f216bc6 (patch)
tree4ee5af46dff0686b8a8d46be380d04ea39541383 /WireGuard/WireGuard/Tunnel
parentTunnelStatus: Absorb NEVPNStatus+CustomStringConvertible (diff)
downloadwireguard-apple-e6e1795d08e52fcf45f3cdc2ab0452560f216bc6.tar.xz
wireguard-apple-e6e1795d08e52fcf45f3cdc2ab0452560f216bc6.zip
TunnelErrors: Add alert text for PacketTunnelProviderError
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/Tunnel')
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelErrors.swift17
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift17
2 files changed, 21 insertions, 13 deletions
diff --git a/WireGuard/WireGuard/Tunnel/TunnelErrors.swift b/WireGuard/WireGuard/Tunnel/TunnelErrors.swift
index 77b04109..8e7f5245 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelErrors.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelErrors.swift
@@ -64,6 +64,23 @@ enum TunnelsManagerActivationError: WireGuardAppError {
}
}
+extension PacketTunnelProviderError: WireGuardAppError {
+ var alertText: AlertText {
+ switch self {
+ case .savedProtocolConfigurationIsInvalid:
+ return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSavedConfigFailureMessage"))
+ case .dnsResolutionFailure:
+ return (tr("alertTunnelDNSFailureTitle"), tr("alertTunnelDNSFailureMessage"))
+ case .couldNotStartBackend:
+ return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationBackendFailureMessage"))
+ case .couldNotDetermineFileDescriptor:
+ return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFileDescriptorFailureMessage"))
+ case .couldNotSetNetworkSettings:
+ return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSetNetworkSettingsMessage"))
+ }
+ }
+}
+
extension Error {
var localizedUIString: String {
if let systemError = self as? NEVPNError {
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index da1b217c..6b24a58e 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -323,20 +323,11 @@ private func lastErrorTextFromNetworkExtension(for tunnel: TunnelContainer) -> (
guard let lastErrorStrings = String(data: lastErrorData, encoding: .utf8)?.splitToArray(separator: "\n") else { return nil }
guard lastErrorStrings.count == 2 && tunnel.activationAttemptId == lastErrorStrings[0] else { return nil }
- switch PacketTunnelProviderError(rawValue: lastErrorStrings[1]) {
- case .some(.savedProtocolConfigurationIsInvalid):
- return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSavedConfigFailureMessage"))
- case .some(.dnsResolutionFailure):
- return (tr("alertTunnelDNSFailureTitle"), tr("alertTunnelDNSFailureMessage"))
- case .some(.couldNotStartBackend):
- return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationBackendFailureMessage"))
- case .some(.couldNotDetermineFileDescriptor):
- return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFileDescriptorFailureMessage"))
- case .some(.couldNotSetNetworkSettings):
- return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationSetNetworkSettingsMessage"))
- default:
- return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFailureMessage"))
+ if let extensionError = PacketTunnelProviderError(rawValue: lastErrorStrings[1]) {
+ return extensionError.alertText
}
+
+ return (tr("alertTunnelActivationFailureTitle"), tr("alertTunnelActivationFailureMessage"))
}
class TunnelContainer: NSObject {