Do not sort endpoint addresses

Defeats purpose of best-first ordering in DNS reply.
This commit is contained in:
Davide De Rosa 2019-01-05 21:55:59 +01:00
parent f585130355
commit d0de93c60a
2 changed files with 4 additions and 6 deletions

View File

@ -125,7 +125,7 @@ class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
builder.resolvedAddresses = [address] builder.resolvedAddresses = [address]
} else { } else {
builder.prefersResolvedAddresses = !preferences.resolvesHostname builder.prefersResolvedAddresses = !preferences.resolvesHostname
builder.resolvedAddresses = pool.addresses(sorted: false) builder.resolvedAddresses = pool.addresses()
} }
if let proto = manualProtocol { if let proto = manualProtocol {
@ -158,7 +158,7 @@ extension ProviderConnectionProfile {
} }
var addresses: [String] { var addresses: [String] {
return pool?.addresses(sorted: true) ?? [] return pool?.addresses() ?? []
} }
var protocols: [EndpointProtocol] { var protocols: [EndpointProtocol] {

View File

@ -61,10 +61,8 @@ struct Pool: Codable, Comparable, CustomStringConvertible {
} }
// XXX: inefficient, can't easily use lazy on struct // XXX: inefficient, can't easily use lazy on struct
func addresses(sorted: Bool) -> [String] { func addresses() -> [String] {
var addrs = (sorted ? numericAddresses.sorted() : numericAddresses).map { var addrs = numericAddresses.map { DNSResolver.string(fromIPv4: $0) }
return DNSResolver.string(fromIPv4: $0)
}
addrs.insert(hostname, at: 0) addrs.insert(hostname, at: 0)
return addrs return addrs
} }