NE: Print error when unable to start the tunnel

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-10-30 16:54:16 +05:30
parent 60943d88e0
commit ce20a17e51
1 changed files with 4 additions and 1 deletions

View File

@ -27,6 +27,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
os_log("Starting tunnel", log: OSLog.default, type: .info) os_log("Starting tunnel", log: OSLog.default, type: .info)
guard let options = options else { guard let options = options else {
os_log("Starting tunnel failed: No options passed", log: OSLog.default, type: .error)
startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions) startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions)
return return
} }
@ -54,6 +55,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
let ipv6ExcludedRouteNetworkPrefixLengths = options[.ipv6ExcludedRouteNetworkPrefixLengths] as? [NSNumber] let ipv6ExcludedRouteNetworkPrefixLengths = options[.ipv6ExcludedRouteNetworkPrefixLengths] as? [NSNumber]
else { else {
os_log("Starting tunnel failed: Invalid options passed", log: OSLog.default, type: .error)
startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions) startTunnelCompletionHandler(PacketTunnelProviderError.invalidOptions)
return return
} }
@ -64,6 +66,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
let handle = connect(interfaceName: interfaceName, settings: wireguardSettings, mtu: mtu.uint16Value) let handle = connect(interfaceName: interfaceName, settings: wireguardSettings, mtu: mtu.uint16Value)
if handle < 0 { if handle < 0 {
os_log("Starting tunnel failed: Could not start WireGuard", log: OSLog.default, type: .error)
startTunnelCompletionHandler(PacketTunnelProviderError.couldNotStartWireGuard) startTunnelCompletionHandler(PacketTunnelProviderError.couldNotStartWireGuard)
return return
} }
@ -111,7 +114,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
setTunnelNetworkSettings(networkSettings) { (error) in setTunnelNetworkSettings(networkSettings) { (error) in
if let error = error { 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) startTunnelCompletionHandler(PacketTunnelProviderError.coultNotSetNetworkSettings)
} else { } else {
startTunnelCompletionHandler(nil /* No errors */) startTunnelCompletionHandler(nil /* No errors */)