chore(constants): internal/constants/providers
- New package to avoid package import cycles
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/openvpn/parse"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
@@ -84,14 +85,14 @@ func (o OpenVPN) validate(vpnProvider string) (err error) {
|
||||
ErrOpenVPNVersionIsNotValid, o.Version, strings.Join(validVersions, ", "))
|
||||
}
|
||||
|
||||
isCustom := vpnProvider == constants.Custom
|
||||
isCustom := vpnProvider == providers.Custom
|
||||
|
||||
if !isCustom && o.User == "" {
|
||||
return ErrOpenVPNUserIsEmpty
|
||||
}
|
||||
|
||||
passwordRequired := !isCustom &&
|
||||
(vpnProvider != constants.Ivpn || !ivpnAccountID.MatchString(o.User))
|
||||
(vpnProvider != providers.Ivpn || !ivpnAccountID.MatchString(o.User))
|
||||
|
||||
if passwordRequired && o.Password == "" {
|
||||
return ErrOpenVPNPasswordIsEmpty
|
||||
@@ -153,8 +154,8 @@ func validateOpenVPNClientCertificate(vpnProvider,
|
||||
clientCert string) (err error) {
|
||||
switch vpnProvider {
|
||||
case
|
||||
constants.Cyberghost,
|
||||
constants.VPNUnlimited:
|
||||
providers.Cyberghost,
|
||||
providers.VPNUnlimited:
|
||||
if clientCert == "" {
|
||||
return ErrMissingValue
|
||||
}
|
||||
@@ -174,9 +175,9 @@ func validateOpenVPNClientCertificate(vpnProvider,
|
||||
func validateOpenVPNClientKey(vpnProvider, clientKey string) (err error) {
|
||||
switch vpnProvider {
|
||||
case
|
||||
constants.Cyberghost,
|
||||
constants.VPNUnlimited,
|
||||
constants.Wevpn:
|
||||
providers.Cyberghost,
|
||||
providers.VPNUnlimited,
|
||||
providers.Wevpn:
|
||||
if clientKey == "" {
|
||||
return ErrMissingValue
|
||||
}
|
||||
@@ -256,7 +257,7 @@ func (o *OpenVPN) overrideWith(other OpenVPN) {
|
||||
|
||||
func (o *OpenVPN) setDefaults(vpnProvider string) {
|
||||
o.Version = helpers.DefaultString(o.Version, constants.Openvpn25)
|
||||
if vpnProvider == constants.Mullvad {
|
||||
if vpnProvider == providers.Mullvad {
|
||||
o.Password = "m"
|
||||
}
|
||||
|
||||
@@ -266,7 +267,7 @@ func (o *OpenVPN) setDefaults(vpnProvider string) {
|
||||
o.ClientKey = helpers.DefaultStringPtr(o.ClientKey, "")
|
||||
|
||||
var defaultEncPreset string
|
||||
if vpnProvider == constants.PrivateInternetAccess {
|
||||
if vpnProvider == providers.PrivateInternetAccess {
|
||||
defaultEncPreset = constants.PIAEncryptionPresetStrong
|
||||
}
|
||||
o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
|
||||
@@ -39,11 +40,11 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
|
||||
|
||||
// Validate TCP
|
||||
if *o.TCP && helpers.IsOneOf(vpnProvider,
|
||||
constants.Ipvanish,
|
||||
constants.Perfectprivacy,
|
||||
constants.Privado,
|
||||
constants.VPNUnlimited,
|
||||
constants.Vyprvpn,
|
||||
providers.Ipvanish,
|
||||
providers.Perfectprivacy,
|
||||
providers.Privado,
|
||||
providers.VPNUnlimited,
|
||||
providers.Vyprvpn,
|
||||
) {
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrOpenVPNTCPNotSupported, vpnProvider)
|
||||
@@ -53,33 +54,33 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
|
||||
if *o.CustomPort != 0 {
|
||||
switch vpnProvider {
|
||||
// no restriction on port
|
||||
case constants.Cyberghost, constants.HideMyAss,
|
||||
constants.PrivateInternetAccess, constants.Privatevpn,
|
||||
constants.Protonvpn, constants.Torguard:
|
||||
case providers.Cyberghost, providers.HideMyAss,
|
||||
providers.PrivateInternetAccess, providers.Privatevpn,
|
||||
providers.Protonvpn, providers.Torguard:
|
||||
// no custom port allowed
|
||||
case constants.Expressvpn, constants.Fastestvpn,
|
||||
constants.Ipvanish, constants.Nordvpn,
|
||||
constants.Privado, constants.Purevpn,
|
||||
constants.Surfshark, constants.VPNUnlimited,
|
||||
constants.Vyprvpn:
|
||||
case providers.Expressvpn, providers.Fastestvpn,
|
||||
providers.Ipvanish, providers.Nordvpn,
|
||||
providers.Privado, providers.Purevpn,
|
||||
providers.Surfshark, providers.VPNUnlimited,
|
||||
providers.Vyprvpn:
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrOpenVPNCustomPortNotAllowed, vpnProvider)
|
||||
default:
|
||||
var allowedTCP, allowedUDP []uint16
|
||||
switch vpnProvider {
|
||||
case constants.Ivpn:
|
||||
case providers.Ivpn:
|
||||
allowedTCP = []uint16{80, 443, 1143}
|
||||
allowedUDP = []uint16{53, 1194, 2049, 2050}
|
||||
case constants.Mullvad:
|
||||
case providers.Mullvad:
|
||||
allowedTCP = []uint16{80, 443, 1401}
|
||||
allowedUDP = []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400}
|
||||
case constants.Perfectprivacy:
|
||||
case providers.Perfectprivacy:
|
||||
allowedTCP = []uint16{44, 443, 4433}
|
||||
allowedUDP = []uint16{44, 443, 4433}
|
||||
case constants.Wevpn:
|
||||
case providers.Wevpn:
|
||||
allowedTCP = []uint16{53, 1195, 1199, 2018}
|
||||
allowedUDP = []uint16{80, 1194, 1198}
|
||||
case constants.Windscribe:
|
||||
case providers.Windscribe:
|
||||
allowedTCP = []uint16{21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783}
|
||||
allowedUDP = []uint16{53, 80, 123, 443, 1194, 54783}
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
|
||||
}
|
||||
|
||||
// Validate EncPreset
|
||||
if vpnProvider == constants.PrivateInternetAccess {
|
||||
if vpnProvider == providers.PrivateInternetAccess {
|
||||
validEncryptionPresets := []string{
|
||||
constants.PIAEncryptionPresetNone,
|
||||
constants.PIAEncryptionPresetNormal,
|
||||
@@ -142,7 +143,7 @@ func (o *OpenVPNSelection) setDefaults(vpnProvider string) {
|
||||
o.CustomPort = helpers.DefaultUint16(o.CustomPort, 0)
|
||||
|
||||
var defaultEncPreset string
|
||||
if vpnProvider == constants.PrivateInternetAccess {
|
||||
if vpnProvider == providers.PrivateInternetAccess {
|
||||
defaultEncPreset = constants.PIAEncryptionPresetStrong
|
||||
}
|
||||
o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ func (p PortForwarding) validate(vpnProvider string) (err error) {
|
||||
}
|
||||
|
||||
// Validate Enabled
|
||||
validProviders := []string{constants.PrivateInternetAccess}
|
||||
validProviders := []string{providers.PrivateInternetAccess}
|
||||
if !helpers.IsOneOf(vpnProvider, validProviders...) {
|
||||
return fmt.Errorf("%w: for provider %s, it is only available for %s",
|
||||
ErrPortForwardingEnabled, vpnProvider, strings.Join(validProviders, ", "))
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
@@ -26,14 +27,14 @@ func (p *Provider) validate(vpnType string, allServers models.AllServers) (err e
|
||||
// Validate Name
|
||||
var validNames []string
|
||||
if vpnType == constants.OpenVPN {
|
||||
validNames = constants.AllProviders()
|
||||
validNames = providers.All()
|
||||
validNames = append(validNames, "pia") // Retro-compatibility
|
||||
} else { // Wireguard
|
||||
validNames = []string{
|
||||
constants.Custom,
|
||||
constants.Ivpn,
|
||||
constants.Mullvad,
|
||||
constants.Windscribe,
|
||||
providers.Custom,
|
||||
providers.Ivpn,
|
||||
providers.Mullvad,
|
||||
providers.Windscribe,
|
||||
}
|
||||
}
|
||||
if !helpers.IsOneOf(*p.Name, validNames...) {
|
||||
@@ -75,7 +76,7 @@ func (p *Provider) overrideWith(other Provider) {
|
||||
}
|
||||
|
||||
func (p *Provider) setDefaults() {
|
||||
p.Name = helpers.DefaultStringPtr(p.Name, constants.PrivateInternetAccess)
|
||||
p.Name = helpers.DefaultStringPtr(p.Name, providers.PrivateInternetAccess)
|
||||
p.ServerSelection.setDefaults(*p.Name)
|
||||
p.PortForwarding.setDefaults()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/validation"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
@@ -90,15 +91,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
|
||||
}
|
||||
|
||||
if *ss.OwnedOnly &&
|
||||
vpnServiceProvider != constants.Mullvad {
|
||||
vpnServiceProvider != providers.Mullvad {
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrOwnedOnlyNotSupported, vpnServiceProvider)
|
||||
}
|
||||
|
||||
if *ss.FreeOnly &&
|
||||
!helpers.IsOneOf(vpnServiceProvider,
|
||||
constants.Protonvpn,
|
||||
constants.VPNUnlimited,
|
||||
providers.Protonvpn,
|
||||
providers.VPNUnlimited,
|
||||
) {
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrFreeOnlyNotSupported, vpnServiceProvider)
|
||||
@@ -106,15 +107,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
|
||||
|
||||
if *ss.StreamOnly &&
|
||||
!helpers.IsOneOf(vpnServiceProvider,
|
||||
constants.Protonvpn,
|
||||
constants.VPNUnlimited,
|
||||
providers.Protonvpn,
|
||||
providers.VPNUnlimited,
|
||||
) {
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrStreamOnlyNotSupported, vpnServiceProvider)
|
||||
}
|
||||
|
||||
if *ss.MultiHopOnly &&
|
||||
vpnServiceProvider != constants.Surfshark {
|
||||
vpnServiceProvider != providers.Surfshark {
|
||||
return fmt.Errorf("%w: for VPN service provider %s",
|
||||
ErrMultiHopOnlyNotSupported, vpnServiceProvider)
|
||||
}
|
||||
@@ -140,80 +141,80 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection,
|
||||
ispChoices, nameChoices, hostnameChoices []string,
|
||||
err error) {
|
||||
switch vpnServiceProvider {
|
||||
case constants.Custom:
|
||||
case constants.Cyberghost:
|
||||
case providers.Custom:
|
||||
case providers.Cyberghost:
|
||||
servers := allServers.GetCyberghost()
|
||||
countryChoices = validation.CyberghostCountryChoices(servers)
|
||||
hostnameChoices = validation.CyberghostHostnameChoices(servers)
|
||||
case constants.Expressvpn:
|
||||
case providers.Expressvpn:
|
||||
servers := allServers.GetExpressvpn()
|
||||
countryChoices = validation.ExpressvpnCountriesChoices(servers)
|
||||
cityChoices = validation.ExpressvpnCityChoices(servers)
|
||||
hostnameChoices = validation.ExpressvpnHostnameChoices(servers)
|
||||
case constants.Fastestvpn:
|
||||
case providers.Fastestvpn:
|
||||
servers := allServers.GetFastestvpn()
|
||||
countryChoices = validation.FastestvpnCountriesChoices(servers)
|
||||
hostnameChoices = validation.FastestvpnHostnameChoices(servers)
|
||||
case constants.HideMyAss:
|
||||
case providers.HideMyAss:
|
||||
servers := allServers.GetHideMyAss()
|
||||
countryChoices = validation.HideMyAssCountryChoices(servers)
|
||||
regionChoices = validation.HideMyAssRegionChoices(servers)
|
||||
cityChoices = validation.HideMyAssCityChoices(servers)
|
||||
hostnameChoices = validation.HideMyAssHostnameChoices(servers)
|
||||
case constants.Ipvanish:
|
||||
case providers.Ipvanish:
|
||||
servers := allServers.GetIpvanish()
|
||||
countryChoices = validation.IpvanishCountryChoices(servers)
|
||||
cityChoices = validation.IpvanishCityChoices(servers)
|
||||
hostnameChoices = validation.IpvanishHostnameChoices(servers)
|
||||
case constants.Ivpn:
|
||||
case providers.Ivpn:
|
||||
servers := allServers.GetIvpn()
|
||||
countryChoices = validation.IvpnCountryChoices(servers)
|
||||
cityChoices = validation.IvpnCityChoices(servers)
|
||||
ispChoices = validation.IvpnISPChoices(servers)
|
||||
hostnameChoices = validation.IvpnHostnameChoices(servers)
|
||||
case constants.Mullvad:
|
||||
case providers.Mullvad:
|
||||
servers := allServers.GetMullvad()
|
||||
countryChoices = validation.MullvadCountryChoices(servers)
|
||||
cityChoices = validation.MullvadCityChoices(servers)
|
||||
ispChoices = validation.MullvadISPChoices(servers)
|
||||
hostnameChoices = validation.MullvadHostnameChoices(servers)
|
||||
case constants.Nordvpn:
|
||||
case providers.Nordvpn:
|
||||
servers := allServers.GetNordvpn()
|
||||
regionChoices = validation.NordvpnRegionChoices(servers)
|
||||
hostnameChoices = validation.NordvpnHostnameChoices(servers)
|
||||
case constants.Perfectprivacy:
|
||||
case providers.Perfectprivacy:
|
||||
servers := allServers.GetPerfectprivacy()
|
||||
cityChoices = validation.PerfectprivacyCityChoices(servers)
|
||||
case constants.Privado:
|
||||
case providers.Privado:
|
||||
servers := allServers.GetPrivado()
|
||||
countryChoices = validation.PrivadoCountryChoices(servers)
|
||||
regionChoices = validation.PrivadoRegionChoices(servers)
|
||||
cityChoices = validation.PrivadoCityChoices(servers)
|
||||
hostnameChoices = validation.PrivadoHostnameChoices(servers)
|
||||
case constants.PrivateInternetAccess:
|
||||
case providers.PrivateInternetAccess:
|
||||
servers := allServers.GetPia()
|
||||
regionChoices = validation.PIAGeoChoices(servers)
|
||||
hostnameChoices = validation.PIAHostnameChoices(servers)
|
||||
nameChoices = validation.PIANameChoices(servers)
|
||||
case constants.Privatevpn:
|
||||
case providers.Privatevpn:
|
||||
servers := allServers.GetPrivatevpn()
|
||||
countryChoices = validation.PrivatevpnCountryChoices(servers)
|
||||
cityChoices = validation.PrivatevpnCityChoices(servers)
|
||||
hostnameChoices = validation.PrivatevpnHostnameChoices(servers)
|
||||
case constants.Protonvpn:
|
||||
case providers.Protonvpn:
|
||||
servers := allServers.GetProtonvpn()
|
||||
countryChoices = validation.ProtonvpnCountryChoices(servers)
|
||||
regionChoices = validation.ProtonvpnRegionChoices(servers)
|
||||
cityChoices = validation.ProtonvpnCityChoices(servers)
|
||||
nameChoices = validation.ProtonvpnNameChoices(servers)
|
||||
hostnameChoices = validation.ProtonvpnHostnameChoices(servers)
|
||||
case constants.Purevpn:
|
||||
case providers.Purevpn:
|
||||
servers := allServers.GetPurevpn()
|
||||
countryChoices = validation.PurevpnCountryChoices(servers)
|
||||
regionChoices = validation.PurevpnRegionChoices(servers)
|
||||
cityChoices = validation.PurevpnCityChoices(servers)
|
||||
hostnameChoices = validation.PurevpnHostnameChoices(servers)
|
||||
case constants.Surfshark:
|
||||
case providers.Surfshark:
|
||||
servers := allServers.GetSurfshark()
|
||||
countryChoices = validation.SurfsharkCountryChoices(servers)
|
||||
cityChoices = validation.SurfsharkCityChoices(servers)
|
||||
@@ -227,24 +228,24 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection,
|
||||
// Retro compatibility
|
||||
// TODO remove in v4
|
||||
*ss = surfsharkRetroRegion(*ss)
|
||||
case constants.Torguard:
|
||||
case providers.Torguard:
|
||||
servers := allServers.GetTorguard()
|
||||
countryChoices = validation.TorguardCountryChoices(servers)
|
||||
cityChoices = validation.TorguardCityChoices(servers)
|
||||
hostnameChoices = validation.TorguardHostnameChoices(servers)
|
||||
case constants.VPNUnlimited:
|
||||
case providers.VPNUnlimited:
|
||||
servers := allServers.GetVPNUnlimited()
|
||||
countryChoices = validation.VPNUnlimitedCountryChoices(servers)
|
||||
cityChoices = validation.VPNUnlimitedCityChoices(servers)
|
||||
hostnameChoices = validation.VPNUnlimitedHostnameChoices(servers)
|
||||
case constants.Vyprvpn:
|
||||
case providers.Vyprvpn:
|
||||
servers := allServers.GetVyprvpn()
|
||||
regionChoices = validation.VyprvpnRegionChoices(servers)
|
||||
case constants.Wevpn:
|
||||
case providers.Wevpn:
|
||||
servers := allServers.GetWevpn()
|
||||
cityChoices = validation.WevpnCityChoices(servers)
|
||||
hostnameChoices = validation.WevpnHostnameChoices(servers)
|
||||
case constants.Windscribe:
|
||||
case providers.Windscribe:
|
||||
servers := allServers.GetWindscribe()
|
||||
regionChoices = validation.WindscribeRegionChoices(servers)
|
||||
cityChoices = validation.WindscribeCityChoices(servers)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gotree"
|
||||
)
|
||||
|
||||
@@ -42,8 +42,8 @@ func (u Updater) Validate() (err error) {
|
||||
|
||||
for i, provider := range u.Providers {
|
||||
valid := false
|
||||
for _, validProvider := range constants.AllProviders() {
|
||||
if validProvider == constants.Custom {
|
||||
for _, validProvider := range providers.All() {
|
||||
if validProvider == providers.Custom {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func (u *Updater) SetDefaults(vpnProvider string) {
|
||||
u.Period = helpers.DefaultDuration(u.Period, 0)
|
||||
u.DNSAddress = helpers.DefaultIP(u.DNSAddress, net.IPv4(1, 1, 1, 1))
|
||||
u.CLI = helpers.DefaultBool(u.CLI, false)
|
||||
if len(u.Providers) == 0 && vpnProvider != constants.Custom {
|
||||
if len(u.Providers) == 0 && vpnProvider != providers.Custom {
|
||||
u.Providers = []string{vpnProvider}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"regexp"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gotree"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
@@ -35,10 +35,10 @@ var regexpInterfaceName = regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
|
||||
// It should only be ran if the VPN type chosen is Wireguard.
|
||||
func (w Wireguard) validate(vpnProvider string) (err error) {
|
||||
if !helpers.IsOneOf(vpnProvider,
|
||||
constants.Custom,
|
||||
constants.Ivpn,
|
||||
constants.Mullvad,
|
||||
constants.Windscribe,
|
||||
providers.Custom,
|
||||
providers.Ivpn,
|
||||
providers.Mullvad,
|
||||
providers.Windscribe,
|
||||
) {
|
||||
// do not validate for VPN provider not supporting Wireguard
|
||||
return nil
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/qdm12/gotree"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
@@ -36,8 +36,8 @@ type WireguardSelection struct {
|
||||
func (w WireguardSelection) validate(vpnProvider string) (err error) {
|
||||
// Validate EndpointIP
|
||||
switch vpnProvider {
|
||||
case constants.Ivpn, constants.Mullvad, constants.Windscribe: // endpoint IP addresses are baked in
|
||||
case constants.Custom:
|
||||
case providers.Ivpn, providers.Mullvad, providers.Windscribe: // endpoint IP addresses are baked in
|
||||
case providers.Custom:
|
||||
if len(w.EndpointIP) == 0 {
|
||||
return ErrWireguardEndpointIPNotSet
|
||||
}
|
||||
@@ -47,23 +47,23 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) {
|
||||
// Validate EndpointPort
|
||||
switch vpnProvider {
|
||||
// EndpointPort is required
|
||||
case constants.Custom:
|
||||
case providers.Custom:
|
||||
if *w.EndpointPort == 0 {
|
||||
return ErrWireguardEndpointPortNotSet
|
||||
}
|
||||
case constants.Ivpn, constants.Mullvad, constants.Windscribe:
|
||||
case providers.Ivpn, providers.Mullvad, providers.Windscribe:
|
||||
// EndpointPort is optional and can be 0
|
||||
if *w.EndpointPort == 0 {
|
||||
break // no custom endpoint port set
|
||||
}
|
||||
if vpnProvider == constants.Mullvad {
|
||||
if vpnProvider == providers.Mullvad {
|
||||
break // no restriction on custom endpoint port value
|
||||
}
|
||||
var allowed []uint16
|
||||
switch vpnProvider {
|
||||
case constants.Ivpn:
|
||||
case providers.Ivpn:
|
||||
allowed = []uint16{2049, 2050, 53, 30587, 41893, 48574, 58237}
|
||||
case constants.Windscribe:
|
||||
case providers.Windscribe:
|
||||
allowed = []uint16{53, 80, 123, 443, 1194, 65142}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) {
|
||||
|
||||
// Validate PublicKey
|
||||
switch vpnProvider {
|
||||
case constants.Ivpn, constants.Mullvad, constants.Windscribe: // public keys are baked in
|
||||
case constants.Custom:
|
||||
case providers.Ivpn, providers.Mullvad, providers.Windscribe: // public keys are baked in
|
||||
case providers.Custom:
|
||||
if w.PublicKey == "" {
|
||||
return ErrWireguardPublicKeyNotSet
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
)
|
||||
|
||||
func (r *Reader) readProvider(vpnType string) (provider settings.Provider, err error) {
|
||||
@@ -35,11 +36,11 @@ func (r *Reader) readVPNServiceProvider(vpnType string) (vpnProviderPtr *string)
|
||||
switch {
|
||||
case vpnType != constants.Wireguard &&
|
||||
os.Getenv("OPENVPN_CUSTOM_CONFIG") != "": // retro compatibility
|
||||
return stringPtr(constants.Custom)
|
||||
return stringPtr(providers.Custom)
|
||||
case s == "":
|
||||
return nil
|
||||
case s == "pia": // retro compatibility
|
||||
return stringPtr(constants.PrivateInternetAccess)
|
||||
return stringPtr(providers.PrivateInternetAccess)
|
||||
}
|
||||
return stringPtr(s)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -27,7 +27,7 @@ func (r *Reader) readServerSelection(vpnProvider, vpnType string) (
|
||||
|
||||
countriesKey, _ := r.getEnvWithRetro("SERVER_COUNTRIES", "COUNTRY")
|
||||
ss.Countries = envToCSV(countriesKey)
|
||||
if vpnProvider == constants.Cyberghost && len(ss.Countries) == 0 {
|
||||
if vpnProvider == providers.Cyberghost && len(ss.Countries) == 0 {
|
||||
// Retro-compatibility for Cyberghost using the REGION variable
|
||||
ss.Countries = envToCSV("REGION")
|
||||
if len(ss.Countries) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user