aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-22 05:12:53 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-22 05:13:04 +0100
commitb0b6866c518735ddb96b7f54a1ad2aec6972116f (patch)
treece739a103226e50d46b9e20641ecf8b23cb3dfaf /WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
parentRemoving a tunnel from iOS's settings is now immediately reflected in app (diff)
downloadwireguard-apple-b0b6866c518735ddb96b7f54a1ad2aec6972116f.tar.xz
wireguard-apple-b0b6866c518735ddb96b7f54a1ad2aec6972116f.zip
Do not crash if we can't get socket.fileDescriptor
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift2
1 files changed, 1 insertions, 1 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index fd6bb9b9..e44d2985 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -38,7 +38,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
packetTunnelSettingsGenerator = PacketTunnelSettingsGenerator(tunnelConfiguration: tunnelConfiguration, resolvedEndpoints: resolvedEndpoints)
- let fileDescriptor = packetFlow.value(forKeyPath: "socket.fileDescriptor") as! Int32 //swiftlint:disable:this force_cast
+ let fileDescriptor = (packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32) ?? -1
if fileDescriptor < 0 {
wg_log(.error, staticMessage: "Starting tunnel failed: Could not determine file descriptor")
errorNotifier.notify(PacketTunnelProviderError.couldNotDetermineFileDescriptor)