Maint: common GetPort for OpenVPN+Wireguard providers
This commit is contained in:
@@ -2,7 +2,6 @@ package mullvad
|
||||
|
||||
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"
|
||||
)
|
||||
@@ -39,23 +38,11 @@ func (m *Mullvad) GetConnection(selection configuration.ServerSelection) (
|
||||
}
|
||||
|
||||
func getPort(selection configuration.ServerSelection) (port uint16) {
|
||||
switch selection.VPN {
|
||||
case constants.Wireguard:
|
||||
customPort := selection.Wireguard.CustomPort
|
||||
if customPort > 0 {
|
||||
return customPort
|
||||
}
|
||||
const defaultPort = 51820
|
||||
return defaultPort
|
||||
default: // OpenVPN
|
||||
customPort := selection.OpenVPN.CustomPort
|
||||
if customPort > 0 {
|
||||
return customPort
|
||||
}
|
||||
port = 1194
|
||||
if selection.OpenVPN.TCP {
|
||||
port = 443
|
||||
}
|
||||
return port
|
||||
}
|
||||
const (
|
||||
defaultOpenVPNTCP = 443
|
||||
defaultOpenVPNUDP = 1194
|
||||
defaultWireguard = 51820
|
||||
)
|
||||
return utils.GetPort(selection, defaultOpenVPNTCP,
|
||||
defaultOpenVPNUDP, defaultWireguard)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user