aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-06 23:38:02 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-06 23:59:48 +0530
commit33edfd35876ff439e95385e247590ed2a27ebac6 (patch)
treee35a2f51310f328048ce56b6b53a3a901cb4cc6d
parentModel: Endpoint.hasHostAsIPAddress() (diff)
downloadwireguard-apple-33edfd35876ff439e95385e247590ed2a27ebac6.tar.xz
wireguard-apple-33edfd35876ff439e95385e247590ed2a27ebac6.zip
DNSResolver: No need to resolve if the endpoint is already an IP address
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/VPN/DNSResolver.swift8
1 files changed, 6 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/VPN/DNSResolver.swift b/WireGuard/WireGuard/VPN/DNSResolver.swift
index e750454..6b7b73b 100644
--- a/WireGuard/WireGuard/VPN/DNSResolver.swift
+++ b/WireGuard/WireGuard/VPN/DNSResolver.swift
@@ -20,7 +20,9 @@ class DNSResolver {
var resolvedEndpoints: [Endpoint?] = Array<Endpoint?>(repeating: nil, count: endpoints.count)
for (i, endpoint) in self.endpoints.enumerated() {
guard let endpoint = endpoint else { continue }
- if let resolvedEndpointStringInCache = DNSResolver.cache.object(forKey: endpoint.stringRepresentation() as NSString),
+ if (endpoint.hasHostAsIPAddress()) {
+ resolvedEndpoints[i] = endpoint
+ } else if let resolvedEndpointStringInCache = DNSResolver.cache.object(forKey: endpoint.stringRepresentation() as NSString),
let resolvedEndpointInCache = Endpoint(from: resolvedEndpointStringInCache as String) {
resolvedEndpoints[i] = resolvedEndpointInCache
} else {
@@ -38,7 +40,9 @@ class DNSResolver {
var isResolvedByDNSRequest: [Bool] = Array<Bool>(repeating: false, count: endpoints.count)
for (i, endpoint) in self.endpoints.enumerated() {
guard let endpoint = endpoint else { continue }
- if let resolvedEndpointStringInCache = DNSResolver.cache.object(forKey: endpoint.stringRepresentation() as NSString),
+ if (endpoint.hasHostAsIPAddress()) {
+ resolvedEndpoints[i] = endpoint
+ } else if let resolvedEndpointStringInCache = DNSResolver.cache.object(forKey: endpoint.stringRepresentation() as NSString),
let resolvedEndpointInCache = Endpoint(from: resolvedEndpointStringInCache as String) {
resolvedEndpoints[i] = resolvedEndpointInCache
} else {