Improve logging of ConnectionStrategy

This commit is contained in:
Davide De Rosa 2020-06-11 16:16:55 +02:00
parent bb40404a51
commit 1ff936895f
2 changed files with 8 additions and 1 deletions

View File

@ -5,6 +5,10 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 2.2.7 (2020-06-11)
- Code cleanup.
## 2.2.6 (2020-05-12) ## 2.2.6 (2020-05-12)
- Address concerns from Guido Vranken fuzzers. [#141](https://github.com/passepartoutvpn/tunnelkit/pull/141) - Address concerns from Guido Vranken fuzzers. [#141](https://github.com/passepartoutvpn/tunnelkit/pull/141)

View File

@ -84,17 +84,20 @@ class ConnectionStrategy {
currentEndpointIndex = 0 currentEndpointIndex = 0
if let resolvedAddresses = configuration.resolvedAddresses { if let resolvedAddresses = configuration.resolvedAddresses {
if configuration.prefersResolvedAddresses { if configuration.prefersResolvedAddresses {
log.debug("Will use pre-resolved addresses only")
endpoints = ConnectionStrategy.unrolledEndpoints( endpoints = ConnectionStrategy.unrolledEndpoints(
records: resolvedAddresses.map { DNSRecord(address: $0, isIPv6: false) }, records: resolvedAddresses.map { DNSRecord(address: $0, isIPv6: false) },
protos: endpointProtocols protos: endpointProtocols
) )
} else { } else {
log.debug("Will use DNS resolution with fallback to pre-resolved addresses")
endpoints = [] endpoints = []
} }
self.resolvedAddresses = resolvedAddresses self.resolvedAddresses = resolvedAddresses
} else { } else {
log.debug("Will use DNS resolution")
guard hostname != nil else { guard hostname != nil else {
fatalError("Either configuration.hostname or resolvedRecords required") fatalError("Either configuration.sessionConfiguration.hostname or configuration.resolvedAddresses required")
} }
endpoints = [] endpoints = []
resolvedAddresses = [] resolvedAddresses = []