Override hostname with profile value

Now that TunnelKit uses sessionConfiguration.hostname to set
.serverAddress, it must be set no matter what.

If hostname is nil, serverAddress is set to
resolvedAddresses.first, which for host profiles is always nil.

Also reorder provider code.
This commit is contained in:
Davide De Rosa 2019-04-10 00:33:27 +02:00
parent c8b9ad0cae
commit 12597d34b3
2 changed files with 7 additions and 3 deletions

View File

@ -66,6 +66,9 @@ public class HostConnectionProfile: ConnectionProfile, Codable, Equatable {
builder.debugLogFormat = configuration.debugLogFormat
builder.masksPrivateData = configuration.masksPrivateData
// forcibly override hostname with profile hostname (never nil)
builder.sessionConfiguration.hostname = hostname
return builder.build()
}

View File

@ -121,11 +121,12 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
builder.debugLogFormat = configuration.debugLogFormat
builder.masksPrivateData = configuration.masksPrivateData
if builder.sessionConfiguration.hostname == nil {
builder.resolvedAddresses = pool.addresses()
} else if let address = manualAddress {
if let address = manualAddress {
builder.prefersResolvedAddresses = true
builder.resolvedAddresses = [address]
} else if builder.sessionConfiguration.hostname == nil {
builder.prefersResolvedAddresses = true
builder.resolvedAddresses = pool.addresses()
} else {
builder.prefersResolvedAddresses = !preferences.resolvesHostname
builder.resolvedAddresses = pool.addresses()