DNSResolver: No need to resolve if the endpoint is already an IP address
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
aa0b6e0c60
commit
33edfd3587
|
@ -20,7 +20,9 @@ class DNSResolver {
|
||||||
var resolvedEndpoints: [Endpoint?] = Array<Endpoint?>(repeating: nil, count: endpoints.count)
|
var resolvedEndpoints: [Endpoint?] = Array<Endpoint?>(repeating: nil, count: endpoints.count)
|
||||||
for (i, endpoint) in self.endpoints.enumerated() {
|
for (i, endpoint) in self.endpoints.enumerated() {
|
||||||
guard let endpoint = endpoint else { continue }
|
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) {
|
let resolvedEndpointInCache = Endpoint(from: resolvedEndpointStringInCache as String) {
|
||||||
resolvedEndpoints[i] = resolvedEndpointInCache
|
resolvedEndpoints[i] = resolvedEndpointInCache
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +40,9 @@ class DNSResolver {
|
||||||
var isResolvedByDNSRequest: [Bool] = Array<Bool>(repeating: false, count: endpoints.count)
|
var isResolvedByDNSRequest: [Bool] = Array<Bool>(repeating: false, count: endpoints.count)
|
||||||
for (i, endpoint) in self.endpoints.enumerated() {
|
for (i, endpoint) in self.endpoints.enumerated() {
|
||||||
guard let endpoint = endpoint else { continue }
|
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) {
|
let resolvedEndpointInCache = Endpoint(from: resolvedEndpointStringInCache as String) {
|
||||||
resolvedEndpoints[i] = resolvedEndpointInCache
|
resolvedEndpoints[i] = resolvedEndpointInCache
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue