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]
} else {
builder.prefersResolvedAddresses = !preferences.resolvesHostname
builder.resolvedAddresses = pool.addresses(sorted: false)
builder.resolvedAddresses = pool.addresses()
}
if let proto = manualProtocol {
@ -158,7 +158,7 @@ extension ProviderConnectionProfile {
}
var addresses: [String] {
return pool?.addresses(sorted: true) ?? []
return pool?.addresses() ?? []
}
var protocols: [EndpointProtocol] {

View File

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