Default "Any" protocol to UDP endpoints

Mitigates a potential issue with randomizeEndpoint where TCP
endpoints might be picked with equal probability, resulting in
poor performance out of the box.

Let the user pick TCP endpoints manually.
This commit is contained in:
Davide De Rosa 2019-04-07 15:13:50 +02:00
parent b4c3b57d38
commit f53ad65bcd

View File

@ -132,7 +132,15 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
if let proto = manualProtocol { if let proto = manualProtocol {
builder.sessionConfiguration.endpointProtocols = [proto] builder.sessionConfiguration.endpointProtocols = [proto]
} else { } else {
builder.sessionConfiguration.endpointProtocols = preset.configuration.sessionConfiguration.endpointProtocols
// restrict "Any" protocol to UDP, unless there are no UDP endpoints
let allEndpoints = preset.configuration.sessionConfiguration.endpointProtocols
var endpoints = allEndpoints?.filter { $0.socketType == .udp }
if endpoints?.isEmpty ?? true {
endpoints = allEndpoints
}
builder.sessionConfiguration.endpointProtocols = endpoints
// builder.sessionConfiguration.endpointProtocols = [ // builder.sessionConfiguration.endpointProtocols = [
// EndpointProtocol(.udp, 8080), // EndpointProtocol(.udp, 8080),
// EndpointProtocol(.tcp, 443) // EndpointProtocol(.tcp, 443)