Commit 41af8ad1 authored by Davide De Rosa's avatar Davide De Rosa
Browse files

Hardcode automatic protocols to common endpoints

UDP:8080 -> TCP:443
parent 8a3c6f08
......@@ -64,6 +64,12 @@ struct AppConfiguration {
return builder
}()
static let piaAutomaticProtocols: [PIATunnelProvider.EndpointProtocol] = [
// let vpnPorts = Client.providers.serverProvider.currentServersConfiguration.vpnPorts
PIATunnelProvider.EndpointProtocol(.udp, 8080, .pia),
PIATunnelProvider.EndpointProtocol(.tcp, 443, .pia)
]
private static let piaCustomRenegotiation: Renegotiation = .qa
private static var piaRenegotiationInterval: Int {
......
......@@ -113,15 +113,7 @@ class Bootstrapper {
AppPreferences.shared.piaSocketType = nil
var tunnelConfigurationBuilder = tunnelConfiguration?.builder()
let vpnPorts = Client.providers.serverProvider.currentServersConfiguration.vpnPorts
var protos: [PIATunnelProvider.EndpointProtocol] = []
for port in vpnPorts.udp {
protos.append(PIATunnelProvider.EndpointProtocol(.udp, port, .pia))
}
for port in vpnPorts.tcp {
protos.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
}
tunnelConfigurationBuilder?.endpointProtocols = protos
tunnelConfigurationBuilder?.endpointProtocols = AppConfiguration.VPN.piaAutomaticProtocols
if let newConfiguration = tunnelConfigurationBuilder?.build() {
pref.setVPNCustomConfiguration(newConfiguration, for: PIATunnelProfile.vpnType)
}
......
......@@ -972,12 +972,13 @@ extension SettingsViewController: OptionsViewControllerDelegate {
}
}
} else {
for port in serversCfg.vpnPorts.udp {
newProtocols.append(PIATunnelProvider.EndpointProtocol(.udp, port, .pia))
}
for port in serversCfg.vpnPorts.tcp {
newProtocols.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
}
// for port in serversCfg.vpnPorts.udp {
// newProtocols.append(PIATunnelProvider.EndpointProtocol(.udp, port, .pia))
// }
// for port in serversCfg.vpnPorts.tcp {
// newProtocols.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
// }
newProtocols = AppConfiguration.VPN.piaAutomaticProtocols
}
pendingOpenVPNSocketType = optSocketType
pendingOpenVPNConfiguration.endpointProtocols = newProtocols
......@@ -987,18 +988,20 @@ extension SettingsViewController: OptionsViewControllerDelegate {
var newProtocols: [PIATunnelProvider.EndpointProtocol] = []
if (port != SettingsViewController.AUTOMATIC_PORT) {
// FIXME: prevent UI
guard let socketType = pendingOpenVPNSocketType else {
fatalError("Port cannot be set manually when socket type is automatic")
}
newProtocols.append(PIATunnelProvider.EndpointProtocol(socketType, port, .pia))
} else {
if (pendingOpenVPNSocketType == nil) || (pendingOpenVPNSocketType == .udp) {
if (pendingOpenVPNSocketType == nil) {
newProtocols = AppConfiguration.VPN.piaAutomaticProtocols
}
else if (pendingOpenVPNSocketType == .udp) {
for port in serversCfg.vpnPorts.udp {
newProtocols.append(PIATunnelProvider.EndpointProtocol(.udp, port, .pia))
}
}
if (pendingOpenVPNSocketType == nil) || (pendingOpenVPNSocketType == .tcp) {
else if (pendingOpenVPNSocketType == .tcp) {
for port in serversCfg.vpnPorts.tcp {
newProtocols.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment