chore(models): streamline all server models IPs (#942)
- Use `IPs []net.IP` for all server models - Use `ips` JSON field for all server models - Merge IPv4 and IPv6 addresses together for Mullvad
This commit is contained in:
@@ -16,9 +16,13 @@ func (m *Mullvad) GetConnection(selection settings.ServerSelection) (
|
||||
return connection, err
|
||||
}
|
||||
|
||||
var connections []models.Connection
|
||||
connections := make([]models.Connection, 0, len(servers))
|
||||
for _, server := range servers {
|
||||
for _, IP := range server.IPs {
|
||||
if IP.To4() == nil {
|
||||
// do not use IPv6 connections for now
|
||||
continue
|
||||
}
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: IP,
|
||||
|
||||
@@ -21,15 +21,17 @@ func (n *Nordvpn) GetConnection(selection settings.ServerSelection) (
|
||||
return connection, err
|
||||
}
|
||||
|
||||
connections := make([]models.Connection, len(servers))
|
||||
for i := range servers {
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: servers[i].IP,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
connections := make([]models.Connection, 0, len(servers))
|
||||
for _, server := range servers {
|
||||
for _, ip := range server.IPs {
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: ip,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
connections = append(connections, connection)
|
||||
}
|
||||
connections[i] = connection
|
||||
}
|
||||
|
||||
return utils.PickConnection(connections, selection, n.randSource)
|
||||
|
||||
@@ -17,16 +17,18 @@ func (p *Privado) GetConnection(selection settings.ServerSelection) (
|
||||
return connection, err
|
||||
}
|
||||
|
||||
connections := make([]models.Connection, len(servers))
|
||||
for i := range servers {
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: servers[i].IP,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
Hostname: servers[i].Hostname,
|
||||
connections := make([]models.Connection, 0, len(servers))
|
||||
for _, server := range servers {
|
||||
for _, ip := range server.IPs {
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: ip,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
Hostname: server.Hostname,
|
||||
}
|
||||
connections = append(connections, connection)
|
||||
}
|
||||
connections[i] = connection
|
||||
}
|
||||
|
||||
return utils.PickConnection(connections, selection, p.randSource)
|
||||
|
||||
@@ -24,13 +24,16 @@ func (p *Protonvpn) GetConnection(selection settings.ServerSelection) (
|
||||
return connection, err
|
||||
}
|
||||
|
||||
connections := make([]models.Connection, len(servers))
|
||||
for i := range servers {
|
||||
connections[i] = models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: servers[i].EntryIP,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
connections := make([]models.Connection, 0, len(servers))
|
||||
for _, server := range servers {
|
||||
for _, ip := range server.IPs {
|
||||
connection := models.Connection{
|
||||
Type: selection.VPN,
|
||||
IP: ip,
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
connections = append(connections, connection)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user