aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension
diff options
context:
space:
mode:
authorEric Kuck <eric@bluelinelabs.com>2018-12-20 22:52:45 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-21 16:42:16 +0100
commit8553723e04c4d63b99e669df2e43fc4a914b7f9d (patch)
treee3b7b25777e47455a787fa590cf00d1c25cbdc5d /WireGuard/WireGuardNetworkExtension
parentNE: simplify logic (diff)
downloadwireguard-apple-8553723e04c4d63b99e669df2e43fc4a914b7f9d.tar.xz
wireguard-apple-8553723e04c4d63b99e669df2e43fc4a914b7f9d.zip
Updated NETunnelProvider save format
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift3
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift9
2 files changed, 5 insertions, 7 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 3a9066d..f32a004 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -26,12 +26,11 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
//swiftlint:disable:next function_body_length
override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
-
let activationAttemptId = options?["activationAttemptId"] as? String
let errorNotifier = ErrorNotifier(activationAttemptId: activationAttemptId, tunnelProvider: self)
guard let tunnelProviderProtocol = protocolConfiguration as? NETunnelProviderProtocol,
- let tunnelConfiguration = tunnelProviderProtocol.tunnelConfiguration() else {
+ let tunnelConfiguration = tunnelProviderProtocol.tunnelConfiguration else {
errorNotifier.notify(PacketTunnelProviderError.savedProtocolConfigurationIsInvalid)
startTunnelCompletionHandler(PacketTunnelProviderError.savedProtocolConfigurationIsInvalid)
return
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
index fd706d9..462d110 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift
@@ -6,7 +6,6 @@ import Network
import NetworkExtension
class PacketTunnelSettingsGenerator {
-
let tunnelConfiguration: TunnelConfiguration
let resolvedEndpoints: [Endpoint?]
@@ -26,7 +25,7 @@ class PacketTunnelSettingsGenerator {
wgSettings.append("public_key=\(peer.publicKey.hexEncodedString())\n")
if let endpoint = resolvedEndpoints[index] {
if case .name(_, _) = endpoint.host { assert(false, "Endpoint is not resolved") }
- wgSettings.append("endpoint=\(endpoint.stringRepresentation())\n")
+ wgSettings.append("endpoint=\(endpoint.stringRepresentation)\n")
}
}
@@ -51,13 +50,13 @@ class PacketTunnelSettingsGenerator {
}
if let endpoint = resolvedEndpoints[index] {
if case .name(_, _) = endpoint.host { assert(false, "Endpoint is not resolved") }
- wgSettings.append("endpoint=\(endpoint.stringRepresentation())\n")
+ wgSettings.append("endpoint=\(endpoint.stringRepresentation)\n")
}
let persistentKeepAlive = peer.persistentKeepAlive ?? 0
wgSettings.append("persistent_keepalive_interval=\(persistentKeepAlive)\n")
if !peer.allowedIPs.isEmpty {
wgSettings.append("replace_allowed_ips=true\n")
- peer.allowedIPs.forEach { wgSettings.append("allowed_ip=\($0.stringRepresentation())\n") }
+ peer.allowedIPs.forEach { wgSettings.append("allowed_ip=\($0.stringRepresentation)\n") }
}
}
return wgSettings
@@ -85,7 +84,7 @@ class PacketTunnelSettingsGenerator {
let networkSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: remoteAddress)
- let dnsServerStrings = tunnelConfiguration.interface.dns.map { $0.stringRepresentation() }
+ let dnsServerStrings = tunnelConfiguration.interface.dns.map { $0.stringRepresentation }
let dnsSettings = NEDNSSettings(servers: dnsServerStrings)
dnsSettings.matchDomains = [""] // All DNS queries must first go through the tunnel's DNS
networkSettings.dnsSettings = dnsSettings