Feat: WeVPN support (#591)

This commit is contained in:
Quentin McGaw
2021-09-23 07:58:13 -07:00
committed by GitHub
parent 3cd26a9f61
commit d8e008606f
36 changed files with 1533 additions and 8 deletions

View File

@@ -0,0 +1,43 @@
package wevpn
import (
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils"
)
func (w *Wevpn) GetConnection(selection configuration.ServerSelection) (
connection models.Connection, err error) {
port := getPort(selection)
protocol := utils.GetProtocol(selection)
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,
}
connections = append(connections, connection)
}
}
return utils.PickConnection(connections, selection, w.randSource)
}
func getPort(selection configuration.ServerSelection) (port uint16) {
const (
defaultOpenVPNTCP = 1195
defaultOpenVPNUDP = 1194
defaultWireguard = 0 // Wireguard not supported
)
return utils.GetPort(selection, defaultOpenVPNTCP,
defaultOpenVPNUDP, defaultWireguard)
}