- Add VPN field to ServerSelection struct - Set VPN type to server selection at start using VPN_TYPE - Change OpenVPNConnection to Connection with Type field - Rename Provider GetOpenVPNConnection to GetConnection - Rename GetTargetIPOpenVPNConnection to GetTargetIPConnection - Rename PickRandomOpenVPNConnection to PickRandomConnection - Add 'OpenVPN' prefix to OpenVPN specific methods on connection
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package windscribe
|
|
|
|
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 (w *Windscribe) GetConnection(selection configuration.ServerSelection) (
|
|
connection models.Connection, err error) {
|
|
protocol := constants.UDP
|
|
var port uint16 = 443
|
|
if selection.OpenVPN.TCP {
|
|
protocol = constants.TCP
|
|
port = 1194
|
|
}
|
|
|
|
if selection.OpenVPN.CustomPort > 0 {
|
|
port = selection.OpenVPN.CustomPort
|
|
}
|
|
|
|
servers, err := w.filterServers(selection)
|
|
if err != nil {
|
|
return connection, err
|
|
}
|
|
|
|
var connections []models.Connection
|
|
for _, server := range servers {
|
|
for _, IP := range server.IPs {
|
|
connection := models.Connection{
|
|
Type: selection.VPN,
|
|
IP: IP,
|
|
Port: port,
|
|
Protocol: protocol,
|
|
Hostname: server.OvpnX509,
|
|
}
|
|
connections = append(connections, connection)
|
|
}
|
|
}
|
|
|
|
if selection.TargetIP != nil {
|
|
return utils.GetTargetIPConnection(connections, selection.TargetIP)
|
|
}
|
|
|
|
return utils.PickRandomConnection(connections, w.randSource), nil
|
|
}
|