From 78e332d48b2a6e96700ae37af15d02bf4ff1d590 Mon Sep 17 00:00:00 2001 From: Johan Kool Date: Wed, 18 Dec 2019 12:42:56 +0100 Subject: [PATCH] Force IPv4 on Mojave otherwise it breaks --- .../AppExtension/Transport/NETunnelInterface.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TunnelKit/Sources/AppExtension/Transport/NETunnelInterface.swift b/TunnelKit/Sources/AppExtension/Transport/NETunnelInterface.swift index 91186c7..429881b 100644 --- a/TunnelKit/Sources/AppExtension/Transport/NETunnelInterface.swift +++ b/TunnelKit/Sources/AppExtension/Transport/NETunnelInterface.swift @@ -46,7 +46,16 @@ public class NETunnelInterface: TunnelInterface { /// :nodoc: public init(impl: NEPacketTunnelFlow, isIPv6: Bool) { self.impl = impl + #if os(macOS) + if #available(OSX 10.15, *) { + protocolNumber = (isIPv6 ? AF_INET6 : AF_INET) as NSNumber + } else { + // Force IPv4 on Mojave otherwise it breaks + protocolNumber = AF_INET as NSNumber + } + #else protocolNumber = (isIPv6 ? AF_INET6 : AF_INET) as NSNumber + #endif } // MARK: TunnelInterface