DNSResolver: No need to resolve if the endpoint is already an IP address

This commit is contained in:
Roopesh Chander 2018-11-06 23:38:02 +05:30
parent 1410b89f23
commit c9b27d1617
1 changed files with 6 additions and 2 deletions

View File

@ -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 {