- Check target IP matches a server for Wireguard since we need the public key - Streamline connection picking for all providers
37 lines
877 B
Go
37 lines
877 B
Go
package nordvpn
|
|
|
|
import (
|
|
"github.com/qdm12/gluetun/internal/configuration"
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
"github.com/qdm12/gluetun/internal/provider/utils"
|
|
)
|
|
|
|
func (n *Nordvpn) GetConnection(selection configuration.ServerSelection) (
|
|
connection models.Connection, err error) {
|
|
var port uint16 = 1194
|
|
protocol := constants.UDP
|
|
if selection.OpenVPN.TCP {
|
|
port = 443
|
|
protocol = constants.TCP
|
|
}
|
|
|
|
servers, err := n.filterServers(selection)
|
|
if err != nil {
|
|
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[i] = connection
|
|
}
|
|
|
|
return utils.PickConnection(connections, selection, n.randSource)
|
|
}
|