Feature: multiple IP addresses per PIA server

This commit is contained in:
Quentin McGaw
2021-05-10 15:44:46 +00:00
parent 52ff03ae41
commit baf506ae27
7 changed files with 422 additions and 394 deletions

View File

@@ -131,17 +131,30 @@ func (p *pia) GetOpenVPNConnection(selection configuration.ServerSelection) (
var connections []models.OpenVPNConnection
for _, server := range servers {
connection := models.OpenVPNConnection{IP: server.IP, Port: port, Protocol: selection.Protocol}
connections = append(connections, connection)
for _, ip := range server.IPs {
connection := models.OpenVPNConnection{
IP: ip,
Port: port,
Protocol: selection.Protocol,
}
connections = append(connections, connection)
}
}
connection = pickRandomConnection(connections, p.randSource)
}
// Reverse lookup server from picked connection
found := false
for _, server := range servers {
if connection.IP.Equal(server.IP) {
p.activeServer = server
for _, ip := range server.IPs {
if connection.IP.Equal(ip) {
p.activeServer = server
found = true
break
}
}
if found {
break
}
}