aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorEric Kuck <eric@bluelinelabs.com>2018-12-16 23:51:25 -0600
committerEric Kuck <eric@bluelinelabs.com>2018-12-16 23:51:25 -0600
commited9b4c85edd17b2b9361f8c7a1a83f91f98cdb8f (patch)
tree5ba59b66646fe7eae8041558cb160506f4cba642 /WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
parentPotential fix for insertRowAtIndexPath crash (diff)
downloadwireguard-apple-ed9b4c85edd17b2b9361f8c7a1a83f91f98cdb8f.tar.xz
wireguard-apple-ed9b4c85edd17b2b9361f8c7a1a83f91f98cdb8f.zip
Got TunnelsManager back under the max file length by splitting out NEVPNStatus+CustomStringConvertible
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift15
1 files changed, 2 insertions, 13 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 0bc79158..8fd5cad6 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -13,17 +13,12 @@ enum PacketTunnelProviderError: Error {
case coultNotSetNetworkSettings
}
-/// A packet tunnel provider object.
class PacketTunnelProvider: NEPacketTunnelProvider {
-
- // MARK: Properties
-
+
private var wgHandle: Int32?
private var networkMonitor: NWPathMonitor?
- // MARK: NEPacketTunnelProvider
-
deinit {
networkMonitor?.cancel()
}
@@ -45,7 +40,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
//swiftlint:disable:next function_body_length
func startTunnel(with tunnelConfiguration: TunnelConfiguration, errorNotifier: ErrorNotifier, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
-
configureLogger()
wg_log(.info, message: "Starting tunnel '\(tunnelConfiguration.interface.name)'")
@@ -66,8 +60,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
assert(endpoints.count == resolvedEndpoints.count)
- // Setup packetTunnelSettingsGenerator
-
let packetTunnelSettingsGenerator = PacketTunnelSettingsGenerator(tunnelConfiguration: tunnelConfiguration, resolvedEndpoints: resolvedEndpoints)
// Bring up wireguard-go backend
@@ -110,8 +102,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
wgHandle = handle
- // Apply network settings
-
let networkSettings: NEPacketTunnelNetworkSettings = packetTunnelSettingsGenerator.generateNetworkSettings()
setTunnelNetworkSettings(networkSettings) { error in
if let error = error {
@@ -120,12 +110,11 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
errorNotifier.notify(PacketTunnelProviderError.coultNotSetNetworkSettings)
startTunnelCompletionHandler(PacketTunnelProviderError.coultNotSetNetworkSettings)
} else {
- startTunnelCompletionHandler(nil /* No errors */)
+ startTunnelCompletionHandler(nil)
}
}
}
- /// Begin the process of stopping the tunnel.
override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) {
networkMonitor?.cancel()
networkMonitor = nil