From ce20a17e51f217deebe7414379938c73bc9a0a49 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Tue, 30 Oct 2018 16:54:16 +0530 Subject: [PATCH] NE: Print error when unable to start the tunnel Signed-off-by: Roopesh Chander --- .../WireGuardNetworkExtension/PacketTunnelProvider.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift index 6cacf6c..a961f76 100644 --- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift +++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift @@ -27,6 +27,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { os_log("Starting tunnel", log: OSLog.default, type: .info) guard let options = options else { + os_log("Starting tunnel failed: No options passed", log: OSLog.default, type: .error) startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions) return } @@ -54,6 +55,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { let ipv6ExcludedRouteNetworkPrefixLengths = options[.ipv6ExcludedRouteNetworkPrefixLengths] as? [NSNumber] else { + os_log("Starting tunnel failed: Invalid options passed", log: OSLog.default, type: .error) startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions) return } @@ -64,6 +66,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { let handle = connect(interfaceName: interfaceName, settings: wireguardSettings, mtu: mtu.uint16Value) if handle < 0 { + os_log("Starting tunnel failed: Could not start WireGuard", log: OSLog.default, type: .error) startTunnelCompletionHandler(PacketTunnelProviderError.couldNotStartWireGuard) return } @@ -111,7 +114,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { setTunnelNetworkSettings(networkSettings) { (error) in if let error = error { - os_log("Error setting network settings: %s", log: OSLog.default, type: .error, error.localizedDescription) + os_log("Starting tunnel failed: Error setting network settings: %s", log: OSLog.default, type: .error, error.localizedDescription) startTunnelCompletionHandler(PacketTunnelProviderError.coultNotSetNetworkSettings) } else { startTunnelCompletionHandler(nil /* No errors */)