aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-21 19:23:16 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-21 19:24:22 +0530
commita21c569e9f84c7b831395ba5a9f738742a748062 (patch)
treea36b7df30d0ad14f62ea3c1f7b6d914855e2df3a /WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
parentLocalize all the things (diff)
downloadwireguard-apple-a21c569e9f84c7b831395ba5a9f738742a748062.tar.xz
wireguard-apple-a21c569e9f84c7b831395ba5a9f738742a748062.zip
NE: Simplify DNS resolution
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift20
1 files changed, 3 insertions, 17 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 8d71f0be..c418ebc9 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -58,11 +58,9 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
errorNotifier.tunnelName = tunnelName
let endpoints = tunnelConfiguration.peers.map { $0.endpoint }
- guard let resolvedEndpoints = resolveDomainNames(endpoints: endpoints) else {
- wg_log(.error, staticMessage: "Starting tunnel failed: DNS resolution failure")
- let dnsError = PacketTunnelProviderError.dnsResolutionFailure
- errorNotifier.notify(dnsError)
- startTunnelCompletionHandler(dnsError)
+ guard let resolvedEndpoints = DNSResolver.resolveSync(endpoints: endpoints) else {
+ errorNotifier.notify(PacketTunnelProviderError.dnsResolutionFailure)
+ startTunnelCompletionHandler(PacketTunnelProviderError.dnsResolutionFailure)
return
}
assert(endpoints.count == resolvedEndpoints.count)
@@ -167,18 +165,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
}
- private func resolveDomainNames(endpoints: [Endpoint?]) -> [Endpoint?]? {
- do {
- return try DNSResolver.resolveSync(endpoints: endpoints)
- } catch DNSResolverError.dnsResolutionFailed(let hostnames) {
- wg_log(.error, message: "DNS resolution failed for the following hostnames: \(hostnames.joined(separator: ", "))")
- } catch {
- // There can be no other errors from DNSResolver.resolveSync()
- fatalError()
- }
- return nil
- }
-
private func connect(interfaceName: String, settings: String, fileDescriptor: Int32) -> Int32 {
return withStringsAsGoStrings(interfaceName, settings) { return wgTurnOn($0.0, $0.1, fileDescriptor) }
}