Merge pull request #31 from passepartoutvpn/drop-ip-sorting

Do not sort endpoint addresses
This commit is contained in:
Davide De Rosa 2019-01-17 09:56:00 +01:00 committed by GitHub
commit 95a39d5376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Retain DNS reply order in resolved endpoint addresses. [#31](https://github.com/passepartoutvpn/passepartout-ios/pull/31)
## 1.0 (2019-01-16)
### Added

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
}