chore(constants): internal/constants/providers

- New package to avoid package import cycles
This commit is contained in:
Quentin McGaw
2022-04-16 19:30:26 +00:00
parent ad80e0c1ab
commit 54b7e23974
51 changed files with 335 additions and 339 deletions

View File

@@ -8,6 +8,7 @@ import (
"path/filepath" "path/filepath"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/storage" "github.com/qdm12/gluetun/internal/storage"
) )
@@ -28,26 +29,26 @@ func (c *CLI) FormatServers(args []string) error {
flagSet := flag.NewFlagSet("markdown", flag.ExitOnError) flagSet := flag.NewFlagSet("markdown", flag.ExitOnError)
flagSet.StringVar(&format, "format", "markdown", "Format to use which can be: 'markdown'") flagSet.StringVar(&format, "format", "markdown", "Format to use which can be: 'markdown'")
flagSet.StringVar(&output, "output", "/dev/stdout", "Output file to write the formatted data to") flagSet.StringVar(&output, "output", "/dev/stdout", "Output file to write the formatted data to")
flagSet.BoolVar(&cyberghost, "cyberghost", false, "Format Cyberghost servers") flagSet.BoolVar(&cyberghost, providers.Cyberghost, false, "Format Cyberghost servers")
flagSet.BoolVar(&expressvpn, "expressvpn", false, "Format ExpressVPN servers") flagSet.BoolVar(&expressvpn, providers.Expressvpn, false, "Format ExpressVPN servers")
flagSet.BoolVar(&fastestvpn, "fastestvpn", false, "Format FastestVPN servers") flagSet.BoolVar(&fastestvpn, providers.Fastestvpn, false, "Format FastestVPN servers")
flagSet.BoolVar(&hideMyAss, "hidemyass", false, "Format HideMyAss servers") flagSet.BoolVar(&hideMyAss, providers.HideMyAss, false, "Format HideMyAss servers")
flagSet.BoolVar(&ipvanish, "ipvanish", false, "Format IpVanish servers") flagSet.BoolVar(&ipvanish, providers.Ipvanish, false, "Format IpVanish servers")
flagSet.BoolVar(&ivpn, "ivpn", false, "Format IVPN servers") flagSet.BoolVar(&ivpn, providers.Ivpn, false, "Format IVPN servers")
flagSet.BoolVar(&mullvad, "mullvad", false, "Format Mullvad servers") flagSet.BoolVar(&mullvad, providers.Mullvad, false, "Format Mullvad servers")
flagSet.BoolVar(&nordvpn, "nordvpn", false, "Format Nordvpn servers") flagSet.BoolVar(&nordvpn, providers.Nordvpn, false, "Format Nordvpn servers")
flagSet.BoolVar(&perfectPrivacy, "perfectprivacy", false, "Format Perfect Privacy servers") flagSet.BoolVar(&perfectPrivacy, providers.Perfectprivacy, false, "Format Perfect Privacy servers")
flagSet.BoolVar(&pia, "pia", false, "Format Private Internet Access servers") flagSet.BoolVar(&pia, providers.PrivateInternetAccess, false, "Format Private Internet Access servers")
flagSet.BoolVar(&privado, "privado", false, "Format Privado servers") flagSet.BoolVar(&privado, providers.Privado, false, "Format Privado servers")
flagSet.BoolVar(&privatevpn, "privatevpn", false, "Format Private VPN servers") flagSet.BoolVar(&privatevpn, providers.Privatevpn, false, "Format Private VPN servers")
flagSet.BoolVar(&protonvpn, "protonvpn", false, "Format Protonvpn servers") flagSet.BoolVar(&protonvpn, providers.Protonvpn, false, "Format Protonvpn servers")
flagSet.BoolVar(&purevpn, "purevpn", false, "Format Purevpn servers") flagSet.BoolVar(&purevpn, providers.Purevpn, false, "Format Purevpn servers")
flagSet.BoolVar(&surfshark, "surfshark", false, "Format Surfshark servers") flagSet.BoolVar(&surfshark, providers.Surfshark, false, "Format Surfshark servers")
flagSet.BoolVar(&torguard, "torguard", false, "Format Torguard servers") flagSet.BoolVar(&torguard, providers.Torguard, false, "Format Torguard servers")
flagSet.BoolVar(&vpnUnlimited, "vpnunlimited", false, "Format VPN Unlimited servers") flagSet.BoolVar(&vpnUnlimited, providers.VPNUnlimited, false, "Format VPN Unlimited servers")
flagSet.BoolVar(&vyprvpn, "vyprvpn", false, "Format Vyprvpn servers") flagSet.BoolVar(&vyprvpn, providers.Vyprvpn, false, "Format Vyprvpn servers")
flagSet.BoolVar(&wevpn, "wevpn", false, "Format WeVPN servers") flagSet.BoolVar(&wevpn, providers.Wevpn, false, "Format WeVPN servers")
flagSet.BoolVar(&windscribe, "windscribe", false, "Format Windscribe servers") flagSet.BoolVar(&windscribe, providers.Windscribe, false, "Format Windscribe servers")
if err := flagSet.Parse(args); err != nil { if err := flagSet.Parse(args); err != nil {
return err return err
} }

View File

@@ -14,6 +14,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/storage" "github.com/qdm12/gluetun/internal/storage"
"github.com/qdm12/gluetun/internal/updater" "github.com/qdm12/gluetun/internal/updater"
@@ -62,8 +63,8 @@ func (c *CLI) Update(ctx context.Context, args []string, logger UpdaterLogger) e
} }
if updateAll { if updateAll {
for _, provider := range constants.AllProviders() { for _, provider := range providers.All() {
if provider == constants.Custom { if provider == providers.Custom {
continue continue
} }
options.Providers = append(options.Providers, provider) options.Providers = append(options.Providers, provider)

View File

@@ -7,6 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/openvpn/parse" "github.com/qdm12/gluetun/internal/openvpn/parse"
"github.com/qdm12/gotree" "github.com/qdm12/gotree"
) )
@@ -84,14 +85,14 @@ func (o OpenVPN) validate(vpnProvider string) (err error) {
ErrOpenVPNVersionIsNotValid, o.Version, strings.Join(validVersions, ", ")) ErrOpenVPNVersionIsNotValid, o.Version, strings.Join(validVersions, ", "))
} }
isCustom := vpnProvider == constants.Custom isCustom := vpnProvider == providers.Custom
if !isCustom && o.User == "" { if !isCustom && o.User == "" {
return ErrOpenVPNUserIsEmpty return ErrOpenVPNUserIsEmpty
} }
passwordRequired := !isCustom && passwordRequired := !isCustom &&
(vpnProvider != constants.Ivpn || !ivpnAccountID.MatchString(o.User)) (vpnProvider != providers.Ivpn || !ivpnAccountID.MatchString(o.User))
if passwordRequired && o.Password == "" { if passwordRequired && o.Password == "" {
return ErrOpenVPNPasswordIsEmpty return ErrOpenVPNPasswordIsEmpty
@@ -153,8 +154,8 @@ func validateOpenVPNClientCertificate(vpnProvider,
clientCert string) (err error) { clientCert string) (err error) {
switch vpnProvider { switch vpnProvider {
case case
constants.Cyberghost, providers.Cyberghost,
constants.VPNUnlimited: providers.VPNUnlimited:
if clientCert == "" { if clientCert == "" {
return ErrMissingValue return ErrMissingValue
} }
@@ -174,9 +175,9 @@ func validateOpenVPNClientCertificate(vpnProvider,
func validateOpenVPNClientKey(vpnProvider, clientKey string) (err error) { func validateOpenVPNClientKey(vpnProvider, clientKey string) (err error) {
switch vpnProvider { switch vpnProvider {
case case
constants.Cyberghost, providers.Cyberghost,
constants.VPNUnlimited, providers.VPNUnlimited,
constants.Wevpn: providers.Wevpn:
if clientKey == "" { if clientKey == "" {
return ErrMissingValue return ErrMissingValue
} }
@@ -256,7 +257,7 @@ func (o *OpenVPN) overrideWith(other OpenVPN) {
func (o *OpenVPN) setDefaults(vpnProvider string) { func (o *OpenVPN) setDefaults(vpnProvider string) {
o.Version = helpers.DefaultString(o.Version, constants.Openvpn25) o.Version = helpers.DefaultString(o.Version, constants.Openvpn25)
if vpnProvider == constants.Mullvad { if vpnProvider == providers.Mullvad {
o.Password = "m" o.Password = "m"
} }
@@ -266,7 +267,7 @@ func (o *OpenVPN) setDefaults(vpnProvider string) {
o.ClientKey = helpers.DefaultStringPtr(o.ClientKey, "") o.ClientKey = helpers.DefaultStringPtr(o.ClientKey, "")
var defaultEncPreset string var defaultEncPreset string
if vpnProvider == constants.PrivateInternetAccess { if vpnProvider == providers.PrivateInternetAccess {
defaultEncPreset = constants.PIAEncryptionPresetStrong defaultEncPreset = constants.PIAEncryptionPresetStrong
} }
o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset) o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset)

View File

@@ -5,6 +5,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gotree" "github.com/qdm12/gotree"
) )
@@ -39,11 +40,11 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
// Validate TCP // Validate TCP
if *o.TCP && helpers.IsOneOf(vpnProvider, if *o.TCP && helpers.IsOneOf(vpnProvider,
constants.Ipvanish, providers.Ipvanish,
constants.Perfectprivacy, providers.Perfectprivacy,
constants.Privado, providers.Privado,
constants.VPNUnlimited, providers.VPNUnlimited,
constants.Vyprvpn, providers.Vyprvpn,
) { ) {
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrOpenVPNTCPNotSupported, vpnProvider) ErrOpenVPNTCPNotSupported, vpnProvider)
@@ -53,33 +54,33 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
if *o.CustomPort != 0 { if *o.CustomPort != 0 {
switch vpnProvider { switch vpnProvider {
// no restriction on port // no restriction on port
case constants.Cyberghost, constants.HideMyAss, case providers.Cyberghost, providers.HideMyAss,
constants.PrivateInternetAccess, constants.Privatevpn, providers.PrivateInternetAccess, providers.Privatevpn,
constants.Protonvpn, constants.Torguard: providers.Protonvpn, providers.Torguard:
// no custom port allowed // no custom port allowed
case constants.Expressvpn, constants.Fastestvpn, case providers.Expressvpn, providers.Fastestvpn,
constants.Ipvanish, constants.Nordvpn, providers.Ipvanish, providers.Nordvpn,
constants.Privado, constants.Purevpn, providers.Privado, providers.Purevpn,
constants.Surfshark, constants.VPNUnlimited, providers.Surfshark, providers.VPNUnlimited,
constants.Vyprvpn: providers.Vyprvpn:
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrOpenVPNCustomPortNotAllowed, vpnProvider) ErrOpenVPNCustomPortNotAllowed, vpnProvider)
default: default:
var allowedTCP, allowedUDP []uint16 var allowedTCP, allowedUDP []uint16
switch vpnProvider { switch vpnProvider {
case constants.Ivpn: case providers.Ivpn:
allowedTCP = []uint16{80, 443, 1143} allowedTCP = []uint16{80, 443, 1143}
allowedUDP = []uint16{53, 1194, 2049, 2050} allowedUDP = []uint16{53, 1194, 2049, 2050}
case constants.Mullvad: case providers.Mullvad:
allowedTCP = []uint16{80, 443, 1401} allowedTCP = []uint16{80, 443, 1401}
allowedUDP = []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400} allowedUDP = []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400}
case constants.Perfectprivacy: case providers.Perfectprivacy:
allowedTCP = []uint16{44, 443, 4433} allowedTCP = []uint16{44, 443, 4433}
allowedUDP = []uint16{44, 443, 4433} allowedUDP = []uint16{44, 443, 4433}
case constants.Wevpn: case providers.Wevpn:
allowedTCP = []uint16{53, 1195, 1199, 2018} allowedTCP = []uint16{53, 1195, 1199, 2018}
allowedUDP = []uint16{80, 1194, 1198} allowedUDP = []uint16{80, 1194, 1198}
case constants.Windscribe: case providers.Windscribe:
allowedTCP = []uint16{21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783} allowedTCP = []uint16{21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783}
allowedUDP = []uint16{53, 80, 123, 443, 1194, 54783} allowedUDP = []uint16{53, 80, 123, 443, 1194, 54783}
} }
@@ -97,7 +98,7 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
} }
// Validate EncPreset // Validate EncPreset
if vpnProvider == constants.PrivateInternetAccess { if vpnProvider == providers.PrivateInternetAccess {
validEncryptionPresets := []string{ validEncryptionPresets := []string{
constants.PIAEncryptionPresetNone, constants.PIAEncryptionPresetNone,
constants.PIAEncryptionPresetNormal, constants.PIAEncryptionPresetNormal,
@@ -142,7 +143,7 @@ func (o *OpenVPNSelection) setDefaults(vpnProvider string) {
o.CustomPort = helpers.DefaultUint16(o.CustomPort, 0) o.CustomPort = helpers.DefaultUint16(o.CustomPort, 0)
var defaultEncPreset string var defaultEncPreset string
if vpnProvider == constants.PrivateInternetAccess { if vpnProvider == providers.PrivateInternetAccess {
defaultEncPreset = constants.PIAEncryptionPresetStrong defaultEncPreset = constants.PIAEncryptionPresetStrong
} }
o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset) o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset)

View File

@@ -6,7 +6,7 @@ import (
"strings" "strings"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "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" "github.com/qdm12/gotree"
) )
@@ -28,7 +28,7 @@ func (p PortForwarding) validate(vpnProvider string) (err error) {
} }
// Validate Enabled // Validate Enabled
validProviders := []string{constants.PrivateInternetAccess} validProviders := []string{providers.PrivateInternetAccess}
if !helpers.IsOneOf(vpnProvider, validProviders...) { if !helpers.IsOneOf(vpnProvider, validProviders...) {
return fmt.Errorf("%w: for provider %s, it is only available for %s", return fmt.Errorf("%w: for provider %s, it is only available for %s",
ErrPortForwardingEnabled, vpnProvider, strings.Join(validProviders, ", ")) ErrPortForwardingEnabled, vpnProvider, strings.Join(validProviders, ", "))

View File

@@ -5,6 +5,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gotree" "github.com/qdm12/gotree"
) )
@@ -26,14 +27,14 @@ func (p *Provider) validate(vpnType string, allServers models.AllServers) (err e
// Validate Name // Validate Name
var validNames []string var validNames []string
if vpnType == constants.OpenVPN { if vpnType == constants.OpenVPN {
validNames = constants.AllProviders() validNames = providers.All()
validNames = append(validNames, "pia") // Retro-compatibility validNames = append(validNames, "pia") // Retro-compatibility
} else { // Wireguard } else { // Wireguard
validNames = []string{ validNames = []string{
constants.Custom, providers.Custom,
constants.Ivpn, providers.Ivpn,
constants.Mullvad, providers.Mullvad,
constants.Windscribe, providers.Windscribe,
} }
} }
if !helpers.IsOneOf(*p.Name, validNames...) { if !helpers.IsOneOf(*p.Name, validNames...) {
@@ -75,7 +76,7 @@ func (p *Provider) overrideWith(other Provider) {
} }
func (p *Provider) setDefaults() { 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.ServerSelection.setDefaults(*p.Name)
p.PortForwarding.setDefaults() p.PortForwarding.setDefaults()
} }

View File

@@ -9,6 +9,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/configuration/settings/validation" "github.com/qdm12/gluetun/internal/configuration/settings/validation"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gotree" "github.com/qdm12/gotree"
) )
@@ -90,15 +91,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
} }
if *ss.OwnedOnly && if *ss.OwnedOnly &&
vpnServiceProvider != constants.Mullvad { vpnServiceProvider != providers.Mullvad {
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrOwnedOnlyNotSupported, vpnServiceProvider) ErrOwnedOnlyNotSupported, vpnServiceProvider)
} }
if *ss.FreeOnly && if *ss.FreeOnly &&
!helpers.IsOneOf(vpnServiceProvider, !helpers.IsOneOf(vpnServiceProvider,
constants.Protonvpn, providers.Protonvpn,
constants.VPNUnlimited, providers.VPNUnlimited,
) { ) {
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrFreeOnlyNotSupported, vpnServiceProvider) ErrFreeOnlyNotSupported, vpnServiceProvider)
@@ -106,15 +107,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string,
if *ss.StreamOnly && if *ss.StreamOnly &&
!helpers.IsOneOf(vpnServiceProvider, !helpers.IsOneOf(vpnServiceProvider,
constants.Protonvpn, providers.Protonvpn,
constants.VPNUnlimited, providers.VPNUnlimited,
) { ) {
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrStreamOnlyNotSupported, vpnServiceProvider) ErrStreamOnlyNotSupported, vpnServiceProvider)
} }
if *ss.MultiHopOnly && if *ss.MultiHopOnly &&
vpnServiceProvider != constants.Surfshark { vpnServiceProvider != providers.Surfshark {
return fmt.Errorf("%w: for VPN service provider %s", return fmt.Errorf("%w: for VPN service provider %s",
ErrMultiHopOnlyNotSupported, vpnServiceProvider) ErrMultiHopOnlyNotSupported, vpnServiceProvider)
} }
@@ -140,80 +141,80 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection,
ispChoices, nameChoices, hostnameChoices []string, ispChoices, nameChoices, hostnameChoices []string,
err error) { err error) {
switch vpnServiceProvider { switch vpnServiceProvider {
case constants.Custom: case providers.Custom:
case constants.Cyberghost: case providers.Cyberghost:
servers := allServers.GetCyberghost() servers := allServers.GetCyberghost()
countryChoices = validation.CyberghostCountryChoices(servers) countryChoices = validation.CyberghostCountryChoices(servers)
hostnameChoices = validation.CyberghostHostnameChoices(servers) hostnameChoices = validation.CyberghostHostnameChoices(servers)
case constants.Expressvpn: case providers.Expressvpn:
servers := allServers.GetExpressvpn() servers := allServers.GetExpressvpn()
countryChoices = validation.ExpressvpnCountriesChoices(servers) countryChoices = validation.ExpressvpnCountriesChoices(servers)
cityChoices = validation.ExpressvpnCityChoices(servers) cityChoices = validation.ExpressvpnCityChoices(servers)
hostnameChoices = validation.ExpressvpnHostnameChoices(servers) hostnameChoices = validation.ExpressvpnHostnameChoices(servers)
case constants.Fastestvpn: case providers.Fastestvpn:
servers := allServers.GetFastestvpn() servers := allServers.GetFastestvpn()
countryChoices = validation.FastestvpnCountriesChoices(servers) countryChoices = validation.FastestvpnCountriesChoices(servers)
hostnameChoices = validation.FastestvpnHostnameChoices(servers) hostnameChoices = validation.FastestvpnHostnameChoices(servers)
case constants.HideMyAss: case providers.HideMyAss:
servers := allServers.GetHideMyAss() servers := allServers.GetHideMyAss()
countryChoices = validation.HideMyAssCountryChoices(servers) countryChoices = validation.HideMyAssCountryChoices(servers)
regionChoices = validation.HideMyAssRegionChoices(servers) regionChoices = validation.HideMyAssRegionChoices(servers)
cityChoices = validation.HideMyAssCityChoices(servers) cityChoices = validation.HideMyAssCityChoices(servers)
hostnameChoices = validation.HideMyAssHostnameChoices(servers) hostnameChoices = validation.HideMyAssHostnameChoices(servers)
case constants.Ipvanish: case providers.Ipvanish:
servers := allServers.GetIpvanish() servers := allServers.GetIpvanish()
countryChoices = validation.IpvanishCountryChoices(servers) countryChoices = validation.IpvanishCountryChoices(servers)
cityChoices = validation.IpvanishCityChoices(servers) cityChoices = validation.IpvanishCityChoices(servers)
hostnameChoices = validation.IpvanishHostnameChoices(servers) hostnameChoices = validation.IpvanishHostnameChoices(servers)
case constants.Ivpn: case providers.Ivpn:
servers := allServers.GetIvpn() servers := allServers.GetIvpn()
countryChoices = validation.IvpnCountryChoices(servers) countryChoices = validation.IvpnCountryChoices(servers)
cityChoices = validation.IvpnCityChoices(servers) cityChoices = validation.IvpnCityChoices(servers)
ispChoices = validation.IvpnISPChoices(servers) ispChoices = validation.IvpnISPChoices(servers)
hostnameChoices = validation.IvpnHostnameChoices(servers) hostnameChoices = validation.IvpnHostnameChoices(servers)
case constants.Mullvad: case providers.Mullvad:
servers := allServers.GetMullvad() servers := allServers.GetMullvad()
countryChoices = validation.MullvadCountryChoices(servers) countryChoices = validation.MullvadCountryChoices(servers)
cityChoices = validation.MullvadCityChoices(servers) cityChoices = validation.MullvadCityChoices(servers)
ispChoices = validation.MullvadISPChoices(servers) ispChoices = validation.MullvadISPChoices(servers)
hostnameChoices = validation.MullvadHostnameChoices(servers) hostnameChoices = validation.MullvadHostnameChoices(servers)
case constants.Nordvpn: case providers.Nordvpn:
servers := allServers.GetNordvpn() servers := allServers.GetNordvpn()
regionChoices = validation.NordvpnRegionChoices(servers) regionChoices = validation.NordvpnRegionChoices(servers)
hostnameChoices = validation.NordvpnHostnameChoices(servers) hostnameChoices = validation.NordvpnHostnameChoices(servers)
case constants.Perfectprivacy: case providers.Perfectprivacy:
servers := allServers.GetPerfectprivacy() servers := allServers.GetPerfectprivacy()
cityChoices = validation.PerfectprivacyCityChoices(servers) cityChoices = validation.PerfectprivacyCityChoices(servers)
case constants.Privado: case providers.Privado:
servers := allServers.GetPrivado() servers := allServers.GetPrivado()
countryChoices = validation.PrivadoCountryChoices(servers) countryChoices = validation.PrivadoCountryChoices(servers)
regionChoices = validation.PrivadoRegionChoices(servers) regionChoices = validation.PrivadoRegionChoices(servers)
cityChoices = validation.PrivadoCityChoices(servers) cityChoices = validation.PrivadoCityChoices(servers)
hostnameChoices = validation.PrivadoHostnameChoices(servers) hostnameChoices = validation.PrivadoHostnameChoices(servers)
case constants.PrivateInternetAccess: case providers.PrivateInternetAccess:
servers := allServers.GetPia() servers := allServers.GetPia()
regionChoices = validation.PIAGeoChoices(servers) regionChoices = validation.PIAGeoChoices(servers)
hostnameChoices = validation.PIAHostnameChoices(servers) hostnameChoices = validation.PIAHostnameChoices(servers)
nameChoices = validation.PIANameChoices(servers) nameChoices = validation.PIANameChoices(servers)
case constants.Privatevpn: case providers.Privatevpn:
servers := allServers.GetPrivatevpn() servers := allServers.GetPrivatevpn()
countryChoices = validation.PrivatevpnCountryChoices(servers) countryChoices = validation.PrivatevpnCountryChoices(servers)
cityChoices = validation.PrivatevpnCityChoices(servers) cityChoices = validation.PrivatevpnCityChoices(servers)
hostnameChoices = validation.PrivatevpnHostnameChoices(servers) hostnameChoices = validation.PrivatevpnHostnameChoices(servers)
case constants.Protonvpn: case providers.Protonvpn:
servers := allServers.GetProtonvpn() servers := allServers.GetProtonvpn()
countryChoices = validation.ProtonvpnCountryChoices(servers) countryChoices = validation.ProtonvpnCountryChoices(servers)
regionChoices = validation.ProtonvpnRegionChoices(servers) regionChoices = validation.ProtonvpnRegionChoices(servers)
cityChoices = validation.ProtonvpnCityChoices(servers) cityChoices = validation.ProtonvpnCityChoices(servers)
nameChoices = validation.ProtonvpnNameChoices(servers) nameChoices = validation.ProtonvpnNameChoices(servers)
hostnameChoices = validation.ProtonvpnHostnameChoices(servers) hostnameChoices = validation.ProtonvpnHostnameChoices(servers)
case constants.Purevpn: case providers.Purevpn:
servers := allServers.GetPurevpn() servers := allServers.GetPurevpn()
countryChoices = validation.PurevpnCountryChoices(servers) countryChoices = validation.PurevpnCountryChoices(servers)
regionChoices = validation.PurevpnRegionChoices(servers) regionChoices = validation.PurevpnRegionChoices(servers)
cityChoices = validation.PurevpnCityChoices(servers) cityChoices = validation.PurevpnCityChoices(servers)
hostnameChoices = validation.PurevpnHostnameChoices(servers) hostnameChoices = validation.PurevpnHostnameChoices(servers)
case constants.Surfshark: case providers.Surfshark:
servers := allServers.GetSurfshark() servers := allServers.GetSurfshark()
countryChoices = validation.SurfsharkCountryChoices(servers) countryChoices = validation.SurfsharkCountryChoices(servers)
cityChoices = validation.SurfsharkCityChoices(servers) cityChoices = validation.SurfsharkCityChoices(servers)
@@ -227,24 +228,24 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection,
// Retro compatibility // Retro compatibility
// TODO remove in v4 // TODO remove in v4
*ss = surfsharkRetroRegion(*ss) *ss = surfsharkRetroRegion(*ss)
case constants.Torguard: case providers.Torguard:
servers := allServers.GetTorguard() servers := allServers.GetTorguard()
countryChoices = validation.TorguardCountryChoices(servers) countryChoices = validation.TorguardCountryChoices(servers)
cityChoices = validation.TorguardCityChoices(servers) cityChoices = validation.TorguardCityChoices(servers)
hostnameChoices = validation.TorguardHostnameChoices(servers) hostnameChoices = validation.TorguardHostnameChoices(servers)
case constants.VPNUnlimited: case providers.VPNUnlimited:
servers := allServers.GetVPNUnlimited() servers := allServers.GetVPNUnlimited()
countryChoices = validation.VPNUnlimitedCountryChoices(servers) countryChoices = validation.VPNUnlimitedCountryChoices(servers)
cityChoices = validation.VPNUnlimitedCityChoices(servers) cityChoices = validation.VPNUnlimitedCityChoices(servers)
hostnameChoices = validation.VPNUnlimitedHostnameChoices(servers) hostnameChoices = validation.VPNUnlimitedHostnameChoices(servers)
case constants.Vyprvpn: case providers.Vyprvpn:
servers := allServers.GetVyprvpn() servers := allServers.GetVyprvpn()
regionChoices = validation.VyprvpnRegionChoices(servers) regionChoices = validation.VyprvpnRegionChoices(servers)
case constants.Wevpn: case providers.Wevpn:
servers := allServers.GetWevpn() servers := allServers.GetWevpn()
cityChoices = validation.WevpnCityChoices(servers) cityChoices = validation.WevpnCityChoices(servers)
hostnameChoices = validation.WevpnHostnameChoices(servers) hostnameChoices = validation.WevpnHostnameChoices(servers)
case constants.Windscribe: case providers.Windscribe:
servers := allServers.GetWindscribe() servers := allServers.GetWindscribe()
regionChoices = validation.WindscribeRegionChoices(servers) regionChoices = validation.WindscribeRegionChoices(servers)
cityChoices = validation.WindscribeCityChoices(servers) cityChoices = validation.WindscribeCityChoices(servers)

View File

@@ -7,7 +7,7 @@ import (
"time" "time"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "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" "github.com/qdm12/gotree"
) )
@@ -42,8 +42,8 @@ func (u Updater) Validate() (err error) {
for i, provider := range u.Providers { for i, provider := range u.Providers {
valid := false valid := false
for _, validProvider := range constants.AllProviders() { for _, validProvider := range providers.All() {
if validProvider == constants.Custom { if validProvider == providers.Custom {
continue continue
} }
@@ -93,7 +93,7 @@ func (u *Updater) SetDefaults(vpnProvider string) {
u.Period = helpers.DefaultDuration(u.Period, 0) u.Period = helpers.DefaultDuration(u.Period, 0)
u.DNSAddress = helpers.DefaultIP(u.DNSAddress, net.IPv4(1, 1, 1, 1)) u.DNSAddress = helpers.DefaultIP(u.DNSAddress, net.IPv4(1, 1, 1, 1))
u.CLI = helpers.DefaultBool(u.CLI, false) 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} u.Providers = []string{vpnProvider}
} }
} }

View File

@@ -6,7 +6,7 @@ import (
"regexp" "regexp"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "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" "github.com/qdm12/gotree"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" "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. // It should only be ran if the VPN type chosen is Wireguard.
func (w Wireguard) validate(vpnProvider string) (err error) { func (w Wireguard) validate(vpnProvider string) (err error) {
if !helpers.IsOneOf(vpnProvider, if !helpers.IsOneOf(vpnProvider,
constants.Custom, providers.Custom,
constants.Ivpn, providers.Ivpn,
constants.Mullvad, providers.Mullvad,
constants.Windscribe, providers.Windscribe,
) { ) {
// do not validate for VPN provider not supporting Wireguard // do not validate for VPN provider not supporting Wireguard
return nil return nil

View File

@@ -5,7 +5,7 @@ import (
"net" "net"
"github.com/qdm12/gluetun/internal/configuration/settings/helpers" "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" "github.com/qdm12/gotree"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes" "golang.zx2c4.com/wireguard/wgctrl/wgtypes"
) )
@@ -36,8 +36,8 @@ type WireguardSelection struct {
func (w WireguardSelection) validate(vpnProvider string) (err error) { func (w WireguardSelection) validate(vpnProvider string) (err error) {
// Validate EndpointIP // Validate EndpointIP
switch vpnProvider { switch vpnProvider {
case constants.Ivpn, constants.Mullvad, constants.Windscribe: // endpoint IP addresses are baked in case providers.Ivpn, providers.Mullvad, providers.Windscribe: // endpoint IP addresses are baked in
case constants.Custom: case providers.Custom:
if len(w.EndpointIP) == 0 { if len(w.EndpointIP) == 0 {
return ErrWireguardEndpointIPNotSet return ErrWireguardEndpointIPNotSet
} }
@@ -47,23 +47,23 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) {
// Validate EndpointPort // Validate EndpointPort
switch vpnProvider { switch vpnProvider {
// EndpointPort is required // EndpointPort is required
case constants.Custom: case providers.Custom:
if *w.EndpointPort == 0 { if *w.EndpointPort == 0 {
return ErrWireguardEndpointPortNotSet return ErrWireguardEndpointPortNotSet
} }
case constants.Ivpn, constants.Mullvad, constants.Windscribe: case providers.Ivpn, providers.Mullvad, providers.Windscribe:
// EndpointPort is optional and can be 0 // EndpointPort is optional and can be 0
if *w.EndpointPort == 0 { if *w.EndpointPort == 0 {
break // no custom endpoint port set break // no custom endpoint port set
} }
if vpnProvider == constants.Mullvad { if vpnProvider == providers.Mullvad {
break // no restriction on custom endpoint port value break // no restriction on custom endpoint port value
} }
var allowed []uint16 var allowed []uint16
switch vpnProvider { switch vpnProvider {
case constants.Ivpn: case providers.Ivpn:
allowed = []uint16{2049, 2050, 53, 30587, 41893, 48574, 58237} allowed = []uint16{2049, 2050, 53, 30587, 41893, 48574, 58237}
case constants.Windscribe: case providers.Windscribe:
allowed = []uint16{53, 80, 123, 443, 1194, 65142} allowed = []uint16{53, 80, 123, 443, 1194, 65142}
} }
@@ -78,8 +78,8 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) {
// Validate PublicKey // Validate PublicKey
switch vpnProvider { switch vpnProvider {
case constants.Ivpn, constants.Mullvad, constants.Windscribe: // public keys are baked in case providers.Ivpn, providers.Mullvad, providers.Windscribe: // public keys are baked in
case constants.Custom: case providers.Custom:
if w.PublicKey == "" { if w.PublicKey == "" {
return ErrWireguardPublicKeyNotSet return ErrWireguardPublicKeyNotSet
} }

View File

@@ -7,6 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
) )
func (r *Reader) readProvider(vpnType string) (provider settings.Provider, err error) { func (r *Reader) readProvider(vpnType string) (provider settings.Provider, err error) {
@@ -35,11 +36,11 @@ func (r *Reader) readVPNServiceProvider(vpnType string) (vpnProviderPtr *string)
switch { switch {
case vpnType != constants.Wireguard && case vpnType != constants.Wireguard &&
os.Getenv("OPENVPN_CUSTOM_CONFIG") != "": // retro compatibility os.Getenv("OPENVPN_CUSTOM_CONFIG") != "": // retro compatibility
return stringPtr(constants.Custom) return stringPtr(providers.Custom)
case s == "": case s == "":
return nil return nil
case s == "pia": // retro compatibility case s == "pia": // retro compatibility
return stringPtr(constants.PrivateInternetAccess) return stringPtr(providers.PrivateInternetAccess)
} }
return stringPtr(s) return stringPtr(s)
} }

View File

@@ -9,7 +9,7 @@ import (
"strings" "strings"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
) )
var ( var (
@@ -27,7 +27,7 @@ func (r *Reader) readServerSelection(vpnProvider, vpnType string) (
countriesKey, _ := r.getEnvWithRetro("SERVER_COUNTRIES", "COUNTRY") countriesKey, _ := r.getEnvWithRetro("SERVER_COUNTRIES", "COUNTRY")
ss.Countries = envToCSV(countriesKey) 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 // Retro-compatibility for Cyberghost using the REGION variable
ss.Countries = envToCSV("REGION") ss.Countries = envToCSV("REGION")
if len(ss.Countries) > 0 { if len(ss.Countries) > 0 {

View File

@@ -1,27 +0,0 @@
package constants
func AllProviders() []string {
return []string{
Custom,
Cyberghost,
Expressvpn,
Fastestvpn,
HideMyAss,
Ipvanish,
Ivpn,
Mullvad,
Nordvpn,
Perfectprivacy,
Privado,
PrivateInternetAccess,
Privatevpn,
Protonvpn,
Purevpn,
Surfshark,
Torguard,
VPNUnlimited,
Vyprvpn,
Wevpn,
Windscribe,
}
}

View File

@@ -0,0 +1,53 @@
package providers
const (
// Custom is the VPN provider name for custom
// VPN configurations.
Custom = "custom"
Cyberghost = "cyberghost"
Expressvpn = "expressvpn"
Fastestvpn = "fastestvpn"
HideMyAss = "hidemyass"
Ipvanish = "ipvanish"
Ivpn = "ivpn"
Mullvad = "mullvad"
Nordvpn = "nordvpn"
Perfectprivacy = "perfect privacy"
Privado = "privado"
PrivateInternetAccess = "private internet access"
Privatevpn = "privatevpn"
Protonvpn = "protonvpn"
Purevpn = "purevpn"
Surfshark = "surfshark"
Torguard = "torguard"
VPNUnlimited = "vpn unlimited"
Vyprvpn = "vyprvpn"
Wevpn = "wevpn"
Windscribe = "windscribe"
)
func All() []string {
return []string{
Custom,
Cyberghost,
Expressvpn,
Fastestvpn,
HideMyAss,
Ipvanish,
Ivpn,
Mullvad,
Nordvpn,
Perfectprivacy,
Privado,
PrivateInternetAccess,
Privatevpn,
Protonvpn,
Purevpn,
Surfshark,
Torguard,
VPNUnlimited,
Vyprvpn,
Wevpn,
Windscribe,
}
}

View File

@@ -5,52 +5,6 @@ const (
Wireguard = "wireguard" Wireguard = "wireguard"
) )
const (
// Custom is the VPN provider name for custom
// VPN configurations.
Custom = "custom"
// Cyberghost is a VPN provider.
Cyberghost = "cyberghost"
// Expressvpn is a VPN provider.
Expressvpn = "expressvpn"
// Fastestvpn is a VPN provider.
Fastestvpn = "fastestvpn"
// HideMyAss is a VPN provider.
HideMyAss = "hidemyass"
// Ipvanish is a VPN provider.
Ipvanish = "ipvanish"
// Ivpn is a VPN provider.
Ivpn = "ivpn"
// Mullvad is a VPN provider.
Mullvad = "mullvad"
// Nordvpn is a VPN provider.
Nordvpn = "nordvpn"
// Perfectprivacy is a VPN provider.
Perfectprivacy = "perfect privacy"
// Privado is a VPN provider.
Privado = "privado"
// PrivateInternetAccess is a VPN provider.
PrivateInternetAccess = "private internet access"
// Privatevpn is a VPN provider.
Privatevpn = "privatevpn"
// Protonvpn is a VPN provider.
Protonvpn = "protonvpn"
// Purevpn is a VPN provider.
Purevpn = "purevpn"
// Surfshark is a VPN provider.
Surfshark = "surfshark"
// Torguard is a VPN provider.
Torguard = "torguard"
// VPNUnlimited is a VPN provider.
VPNUnlimited = "vpn unlimited"
// Vyprvpn is a VPN provider.
Vyprvpn = "vyprvpn"
// WeVPN is a VPN provider.
Wevpn = "wevpn"
// Windscribe is a VPN provider.
Windscribe = "windscribe"
)
const ( const (
// TCP is a network protocol (reliable and slower than UDP). // TCP is a network protocol (reliable and slower than UDP).
TCP string = "tcp" TCP string = "tcp"

View File

@@ -6,6 +6,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@@ -42,7 +43,7 @@ func Test_modifyConfig(t *testing.T) {
ProcessUser: "procuser", ProcessUser: "procuser",
Interface: "tun3", Interface: "tun3",
Verbosity: intPtr(0), Verbosity: intPtr(0),
}.WithDefaults(constants.Custom), }.WithDefaults(providers.Custom),
connection: models.Connection{ connection: models.Connection{
IP: net.IPv4(1, 2, 3, 4), IP: net.IPv4(1, 2, 3, 4),
Port: 1194, Port: 1194,

View File

@@ -1,7 +1,7 @@
package custom package custom
import ( import (
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/openvpn/extract" "github.com/qdm12/gluetun/internal/openvpn/extract"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -14,6 +14,6 @@ type Provider struct {
func New() *Provider { func New() *Provider {
return &Provider{ return &Provider{
extractor: extract.New(), extractor: extract.New(),
NoPortForwarder: utils.NewNoPortForwarding(constants.Custom), NoPortForwarder: utils.NewNoPortForwarding(providers.Custom),
} }
} }

View File

@@ -5,7 +5,7 @@ import (
"testing" "testing"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -22,7 +22,7 @@ func Test_Cyberghost_filterServers(t *testing.T) {
err error err error
}{ }{
"no server": { "no server": {
selection: settings.ServerSelection{}.WithDefaults(constants.Cyberghost), selection: settings.ServerSelection{}.WithDefaults(providers.Cyberghost),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"servers without filter defaults to UDP": { "servers without filter defaults to UDP": {
@@ -32,7 +32,7 @@ func Test_Cyberghost_filterServers(t *testing.T) {
{Country: "c", UDP: true}, {Country: "c", UDP: true},
{Country: "d", UDP: true}, {Country: "d", UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Cyberghost), selection: settings.ServerSelection{}.WithDefaults(providers.Cyberghost),
filteredServers: []models.CyberghostServer{ filteredServers: []models.CyberghostServer{
{Country: "c", UDP: true}, {Country: "c", UDP: true},
{Country: "d", UDP: true}, {Country: "d", UDP: true},
@@ -49,7 +49,7 @@ func Test_Cyberghost_filterServers(t *testing.T) {
OpenVPN: settings.OpenVPNSelection{ OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true), TCP: boolPtr(true),
}, },
}.WithDefaults(constants.Cyberghost), }.WithDefaults(providers.Cyberghost),
filteredServers: []models.CyberghostServer{ filteredServers: []models.CyberghostServer{
{Country: "a", TCP: true}, {Country: "a", TCP: true},
{Country: "b", TCP: true}, {Country: "b", TCP: true},
@@ -64,7 +64,7 @@ func Test_Cyberghost_filterServers(t *testing.T) {
}, },
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Countries: []string{"a", "c"}, Countries: []string{"a", "c"},
}.WithDefaults(constants.Cyberghost), }.WithDefaults(providers.Cyberghost),
filteredServers: []models.CyberghostServer{ filteredServers: []models.CyberghostServer{
{Country: "a", UDP: true}, {Country: "a", UDP: true},
{Country: "c", UDP: true}, {Country: "c", UDP: true},
@@ -78,7 +78,7 @@ func Test_Cyberghost_filterServers(t *testing.T) {
}, },
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"a", "c"}, Hostnames: []string{"a", "c"},
}.WithDefaults(constants.Cyberghost), }.WithDefaults(providers.Cyberghost),
filteredServers: []models.CyberghostServer{ filteredServers: []models.CyberghostServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "c", UDP: true}, {Hostname: "c", UDP: true},

View File

@@ -3,7 +3,7 @@ package cyberghost
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.CyberghostServer, randSource rand.Source) *Cyberghost
return &Cyberghost{ return &Cyberghost{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Cyberghost), NoPortForwarder: utils.NewNoPortForwarding(providers.Cyberghost),
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -23,7 +24,7 @@ func Test_Provider_GetConnection(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -32,7 +33,7 @@ func Test_Provider_GetConnection(t *testing.T) {
{IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
{IPs: []net.IP{net.IPv4(3, 3, 3, 3)}, UDP: true}, {IPs: []net.IP{net.IPv4(3, 3, 3, 3)}, UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
connection: models.Connection{ connection: models.Connection{
Type: constants.OpenVPN, Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1), IP: net.IPv4(1, 1, 1, 1),
@@ -43,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) {
"target IP": { "target IP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2), TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true}, {IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
@@ -59,7 +60,7 @@ func Test_Provider_GetConnection(t *testing.T) {
"with filter": { "with filter": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true}, {Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},

View File

@@ -6,7 +6,7 @@ import (
"testing" "testing"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -24,7 +24,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -33,7 +33,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
{Hostname: "c", UDP: true}, {Hostname: "c", UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn),
filtered: []models.ExpressvpnServer{ filtered: []models.ExpressvpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
@@ -43,7 +43,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
"filter by country": { "filter by country": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Countries: []string{"b"}, Countries: []string{"b"},
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{Country: "a", UDP: true}, {Country: "a", UDP: true},
{Country: "b", UDP: true}, {Country: "b", UDP: true},
@@ -56,7 +56,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{City: "a", UDP: true}, {City: "a", UDP: true},
{City: "b", UDP: true}, {City: "b", UDP: true},
@@ -69,7 +69,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
@@ -84,7 +84,7 @@ func Test_Expressvpn_filterServers(t *testing.T) {
OpenVPN: settings.OpenVPNSelection{ OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true), TCP: boolPtr(true),
}, },
}.WithDefaults(constants.Expressvpn), }.WithDefaults(providers.Expressvpn),
servers: []models.ExpressvpnServer{ servers: []models.ExpressvpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true, TCP: true}, {Hostname: "b", UDP: true, TCP: true},

View File

@@ -3,7 +3,7 @@ package expressvpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.ExpressvpnServer, randSource rand.Source) *Provider {
return &Provider{ return &Provider{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Expressvpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Expressvpn),
} }
} }

View File

@@ -3,7 +3,7 @@ package fastestvpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.FastestvpnServer, randSource rand.Source) *Fastestvpn
return &Fastestvpn{ return &Fastestvpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Fastestvpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Fastestvpn),
} }
} }

View File

@@ -3,7 +3,7 @@ package hidemyass
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.HideMyAssServer, randSource rand.Source) *HideMyAss {
return &HideMyAss{ return &HideMyAss{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.HideMyAss), NoPortForwarder: utils.NewNoPortForwarding(providers.HideMyAss),
} }
} }

View File

@@ -3,7 +3,7 @@ package ipvanish
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.IpvanishServer, randSource rand.Source) *Ipvanish {
return &Ipvanish{ return &Ipvanish{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Ipvanish), NoPortForwarder: utils.NewNoPortForwarding(providers.Ipvanish),
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -23,7 +24,7 @@ func Test_Ivpn_GetConnection(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -32,7 +33,7 @@ func Test_Ivpn_GetConnection(t *testing.T) {
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}, UDP: true}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}, UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn),
connection: models.Connection{ connection: models.Connection{
Type: constants.OpenVPN, Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1), IP: net.IPv4(1, 1, 1, 1),
@@ -43,7 +44,7 @@ func Test_Ivpn_GetConnection(t *testing.T) {
"target IP": { "target IP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2), TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},
@@ -59,7 +60,7 @@ func Test_Ivpn_GetConnection(t *testing.T) {
"with filter": { "with filter": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true}, {VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, UDP: true},
{VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}, UDP: true},

View File

@@ -7,6 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -24,7 +25,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -33,7 +34,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
{VPN: constants.OpenVPN, Hostname: "b", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true},
{VPN: constants.OpenVPN, Hostname: "c", UDP: true}, {VPN: constants.OpenVPN, Hostname: "c", UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn),
filtered: []models.IvpnServer{ filtered: []models.IvpnServer{
{VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "a", UDP: true},
{VPN: constants.OpenVPN, Hostname: "b", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true},
@@ -43,7 +44,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
"filter by country": { "filter by country": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Countries: []string{"b"}, Countries: []string{"b"},
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, Country: "a", UDP: true}, {VPN: constants.OpenVPN, Country: "a", UDP: true},
{VPN: constants.OpenVPN, Country: "b", UDP: true}, {VPN: constants.OpenVPN, Country: "b", UDP: true},
@@ -56,7 +57,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, City: "a", UDP: true}, {VPN: constants.OpenVPN, City: "a", UDP: true},
{VPN: constants.OpenVPN, City: "b", UDP: true}, {VPN: constants.OpenVPN, City: "b", UDP: true},
@@ -69,7 +70,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
"filter by ISP": { "filter by ISP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
ISPs: []string{"b"}, ISPs: []string{"b"},
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, ISP: "a", UDP: true}, {VPN: constants.OpenVPN, ISP: "a", UDP: true},
{VPN: constants.OpenVPN, ISP: "b", UDP: true}, {VPN: constants.OpenVPN, ISP: "b", UDP: true},
@@ -82,7 +83,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "a", UDP: true},
{VPN: constants.OpenVPN, Hostname: "b", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true},
@@ -97,7 +98,7 @@ func Test_Ivpn_filterServers(t *testing.T) {
OpenVPN: settings.OpenVPNSelection{ OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true), TCP: boolPtr(true),
}, },
}.WithDefaults(constants.Ivpn), }.WithDefaults(providers.Ivpn),
servers: []models.IvpnServer{ servers: []models.IvpnServer{
{VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "a", UDP: true},
{VPN: constants.OpenVPN, Hostname: "b", UDP: true, TCP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true, TCP: true},

View File

@@ -3,7 +3,7 @@ package ivpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.IvpnServer, randSource rand.Source) *Ivpn {
return &Ivpn{ return &Ivpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Ivpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Ivpn),
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -23,7 +24,7 @@ func Test_Mullvad_GetConnection(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -32,7 +33,7 @@ func Test_Mullvad_GetConnection(t *testing.T) {
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
connection: models.Connection{ connection: models.Connection{
Type: constants.OpenVPN, Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1), IP: net.IPv4(1, 1, 1, 1),
@@ -43,7 +44,7 @@ func Test_Mullvad_GetConnection(t *testing.T) {
"target IP": { "target IP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2), TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
@@ -59,7 +60,7 @@ func Test_Mullvad_GetConnection(t *testing.T) {
"with filter": { "with filter": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},

View File

@@ -7,6 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -24,7 +25,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -33,7 +34,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},
{VPN: constants.OpenVPN, Hostname: "c"}, {VPN: constants.OpenVPN, Hostname: "c"},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad),
filtered: []models.MullvadServer{ filtered: []models.MullvadServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},
@@ -43,7 +44,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter OpenVPN out": { "filter OpenVPN out": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
VPN: constants.Wireguard, VPN: constants.Wireguard,
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.Wireguard, Hostname: "b"}, {VPN: constants.Wireguard, Hostname: "b"},
@@ -56,7 +57,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter by country": { "filter by country": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Countries: []string{"b"}, Countries: []string{"b"},
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, Country: "a"}, {VPN: constants.OpenVPN, Country: "a"},
{VPN: constants.OpenVPN, Country: "b"}, {VPN: constants.OpenVPN, Country: "b"},
@@ -69,7 +70,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, City: "a"}, {VPN: constants.OpenVPN, City: "a"},
{VPN: constants.OpenVPN, City: "b"}, {VPN: constants.OpenVPN, City: "b"},
@@ -82,7 +83,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter by ISP": { "filter by ISP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
ISPs: []string{"b"}, ISPs: []string{"b"},
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, ISP: "a"}, {VPN: constants.OpenVPN, ISP: "a"},
{VPN: constants.OpenVPN, ISP: "b"}, {VPN: constants.OpenVPN, ISP: "b"},
@@ -95,7 +96,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},
@@ -108,7 +109,7 @@ func Test_Mullvad_filterServers(t *testing.T) {
"filter by owned": { "filter by owned": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
OwnedOnly: boolPtr(true), OwnedOnly: boolPtr(true),
}.WithDefaults(constants.Mullvad), }.WithDefaults(providers.Mullvad),
servers: []models.MullvadServer{ servers: []models.MullvadServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.OpenVPN, Hostname: "b", Owned: true}, {VPN: constants.OpenVPN, Hostname: "b", Owned: true},

View File

@@ -3,7 +3,7 @@ package mullvad
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.MullvadServer, randSource rand.Source) *Mullvad {
return &Mullvad{ return &Mullvad{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Mullvad), NoPortForwarder: utils.NewNoPortForwarding(providers.Mullvad),
} }
} }

View File

@@ -3,7 +3,7 @@ package nordvpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.NordvpnServer, randSource rand.Source) *Nordvpn {
return &Nordvpn{ return &Nordvpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Nordvpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Nordvpn),
} }
} }

View File

@@ -3,7 +3,7 @@ package perfectprivacy
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.PerfectprivacyServer, randSource rand.Source) *Perfect
return &Perfectprivacy{ return &Perfectprivacy{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Perfectprivacy), NoPortForwarder: utils.NewNoPortForwarding(providers.Perfectprivacy),
} }
} }

View File

@@ -3,7 +3,7 @@ package privado
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.PrivadoServer, randSource rand.Source) *Privado {
return &Privado{ return &Privado{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Privado), NoPortForwarder: utils.NewNoPortForwarding(providers.Privado),
} }
} }

View File

@@ -3,7 +3,7 @@ package privatevpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.PrivatevpnServer, randSource rand.Source) *Privatevpn
return &Privatevpn{ return &Privatevpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Privatevpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Privatevpn),
} }
} }

View File

@@ -3,7 +3,7 @@ package protonvpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.ProtonvpnServer, randSource rand.Source) *Protonvpn {
return &Protonvpn{ return &Protonvpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Protonvpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Protonvpn),
} }
} }

View File

@@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/custom" "github.com/qdm12/gluetun/internal/provider/custom"
"github.com/qdm12/gluetun/internal/provider/cyberghost" "github.com/qdm12/gluetun/internal/provider/cyberghost"
@@ -53,47 +53,47 @@ type PortForwarder interface {
func New(provider string, allServers models.AllServers, timeNow func() time.Time) Provider { func New(provider string, allServers models.AllServers, timeNow func() time.Time) Provider {
randSource := rand.NewSource(timeNow().UnixNano()) randSource := rand.NewSource(timeNow().UnixNano())
switch provider { switch provider {
case constants.Custom: case providers.Custom:
return custom.New() return custom.New()
case constants.Cyberghost: case providers.Cyberghost:
return cyberghost.New(allServers.Cyberghost.Servers, randSource) return cyberghost.New(allServers.Cyberghost.Servers, randSource)
case constants.Expressvpn: case providers.Expressvpn:
return expressvpn.New(allServers.Expressvpn.Servers, randSource) return expressvpn.New(allServers.Expressvpn.Servers, randSource)
case constants.Fastestvpn: case providers.Fastestvpn:
return fastestvpn.New(allServers.Fastestvpn.Servers, randSource) return fastestvpn.New(allServers.Fastestvpn.Servers, randSource)
case constants.HideMyAss: case providers.HideMyAss:
return hidemyass.New(allServers.HideMyAss.Servers, randSource) return hidemyass.New(allServers.HideMyAss.Servers, randSource)
case constants.Ipvanish: case providers.Ipvanish:
return ipvanish.New(allServers.Ipvanish.Servers, randSource) return ipvanish.New(allServers.Ipvanish.Servers, randSource)
case constants.Ivpn: case providers.Ivpn:
return ivpn.New(allServers.Ivpn.Servers, randSource) return ivpn.New(allServers.Ivpn.Servers, randSource)
case constants.Mullvad: case providers.Mullvad:
return mullvad.New(allServers.Mullvad.Servers, randSource) return mullvad.New(allServers.Mullvad.Servers, randSource)
case constants.Nordvpn: case providers.Nordvpn:
return nordvpn.New(allServers.Nordvpn.Servers, randSource) return nordvpn.New(allServers.Nordvpn.Servers, randSource)
case constants.Perfectprivacy: case providers.Perfectprivacy:
return perfectprivacy.New(allServers.Perfectprivacy.Servers, randSource) return perfectprivacy.New(allServers.Perfectprivacy.Servers, randSource)
case constants.Privado: case providers.Privado:
return privado.New(allServers.Privado.Servers, randSource) return privado.New(allServers.Privado.Servers, randSource)
case constants.PrivateInternetAccess: case providers.PrivateInternetAccess:
return privateinternetaccess.New(allServers.Pia.Servers, randSource, timeNow) return privateinternetaccess.New(allServers.Pia.Servers, randSource, timeNow)
case constants.Privatevpn: case providers.Privatevpn:
return privatevpn.New(allServers.Privatevpn.Servers, randSource) return privatevpn.New(allServers.Privatevpn.Servers, randSource)
case constants.Protonvpn: case providers.Protonvpn:
return protonvpn.New(allServers.Protonvpn.Servers, randSource) return protonvpn.New(allServers.Protonvpn.Servers, randSource)
case constants.Purevpn: case providers.Purevpn:
return purevpn.New(allServers.Purevpn.Servers, randSource) return purevpn.New(allServers.Purevpn.Servers, randSource)
case constants.Surfshark: case providers.Surfshark:
return surfshark.New(allServers.Surfshark.Servers, randSource) return surfshark.New(allServers.Surfshark.Servers, randSource)
case constants.Torguard: case providers.Torguard:
return torguard.New(allServers.Torguard.Servers, randSource) return torguard.New(allServers.Torguard.Servers, randSource)
case constants.VPNUnlimited: case providers.VPNUnlimited:
return vpnunlimited.New(allServers.VPNUnlimited.Servers, randSource) return vpnunlimited.New(allServers.VPNUnlimited.Servers, randSource)
case constants.Vyprvpn: case providers.Vyprvpn:
return vyprvpn.New(allServers.Vyprvpn.Servers, randSource) return vyprvpn.New(allServers.Vyprvpn.Servers, randSource)
case constants.Wevpn: case providers.Wevpn:
return wevpn.New(allServers.Wevpn.Servers, randSource) return wevpn.New(allServers.Wevpn.Servers, randSource)
case constants.Windscribe: case providers.Windscribe:
return windscribe.New(allServers.Windscribe.Servers, randSource) return windscribe.New(allServers.Windscribe.Servers, randSource)
default: default:
panic("provider " + provider + " is unknown") // should never occur panic("provider " + provider + " is unknown") // should never occur

View File

@@ -3,7 +3,7 @@ package purevpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.PurevpnServer, randSource rand.Source) *Purevpn {
return &Purevpn{ return &Purevpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Purevpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Purevpn),
} }
} }

View File

@@ -6,7 +6,7 @@ import (
"testing" "testing"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -24,7 +24,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Surfshark), selection: settings.ServerSelection{}.WithDefaults(providers.Surfshark),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -33,7 +33,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
{Hostname: "c", UDP: true}, {Hostname: "c", UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Surfshark), selection: settings.ServerSelection{}.WithDefaults(providers.Surfshark),
filtered: []models.SurfsharkServer{ filtered: []models.SurfsharkServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
@@ -43,7 +43,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
"filter by region": { "filter by region": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Regions: []string{"b"}, Regions: []string{"b"},
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{Region: "a", UDP: true}, {Region: "a", UDP: true},
{Region: "b", UDP: true}, {Region: "b", UDP: true},
@@ -56,7 +56,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
"filter by country": { "filter by country": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Countries: []string{"b"}, Countries: []string{"b"},
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{Country: "a", UDP: true}, {Country: "a", UDP: true},
{Country: "b", UDP: true}, {Country: "b", UDP: true},
@@ -69,7 +69,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{City: "a", UDP: true}, {City: "a", UDP: true},
{City: "b", UDP: true}, {City: "b", UDP: true},
@@ -82,7 +82,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
@@ -97,7 +97,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
OpenVPN: settings.OpenVPNSelection{ OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true), TCP: boolPtr(true),
}, },
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true, TCP: true}, {Hostname: "b", UDP: true, TCP: true},
@@ -110,7 +110,7 @@ func Test_Surfshark_filterServers(t *testing.T) {
"filter by multihop only": { "filter by multihop only": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
MultiHopOnly: boolPtr(true), MultiHopOnly: boolPtr(true),
}.WithDefaults(constants.Surfshark), }.WithDefaults(providers.Surfshark),
servers: []models.SurfsharkServer{ servers: []models.SurfsharkServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", MultiHop: true, UDP: true}, {Hostname: "b", MultiHop: true, UDP: true},

View File

@@ -3,7 +3,7 @@ package surfshark
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.SurfsharkServer, randSource rand.Source) *Surfshark {
return &Surfshark{ return &Surfshark{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Surfshark), NoPortForwarder: utils.NewNoPortForwarding(providers.Surfshark),
} }
} }

View File

@@ -3,7 +3,7 @@ package torguard
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.TorguardServer, randSource rand.Source) *Torguard {
return &Torguard{ return &Torguard{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Torguard), NoPortForwarder: utils.NewNoPortForwarding(providers.Torguard),
} }
} }

View File

@@ -3,7 +3,7 @@ package vpnunlimited
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.VPNUnlimitedServer, randSource rand.Source) *Provider
return &Provider{ return &Provider{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.VPNUnlimited), NoPortForwarder: utils.NewNoPortForwarding(providers.VPNUnlimited),
} }
} }

View File

@@ -3,7 +3,7 @@ package vyprvpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.VyprvpnServer, randSource rand.Source) *Vyprvpn {
return &Vyprvpn{ return &Vyprvpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Vyprvpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Vyprvpn),
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -25,7 +26,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
"no server available": { "no server available": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
VPN: constants.OpenVPN, VPN: constants.OpenVPN,
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -34,7 +35,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
{UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
{UDP: true, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}}, {UDP: true, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn), selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
connection: models.Connection{ connection: models.Connection{
Type: constants.OpenVPN, Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1), IP: net.IPv4(1, 1, 1, 1),
@@ -45,7 +46,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
"target IP": { "target IP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2), TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
servers: []models.WevpnServer{ servers: []models.WevpnServer{
{UDP: true, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {UDP: true, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
@@ -61,7 +62,7 @@ func Test_Wevpn_GetConnection(t *testing.T) {
"with filter": { "with filter": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
servers: []models.WevpnServer{ servers: []models.WevpnServer{
{UDP: true, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {UDP: true, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{UDP: true, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {UDP: true, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},

View File

@@ -6,7 +6,7 @@ import (
"testing" "testing"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -24,7 +24,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn), selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -33,7 +33,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
{Hostname: "c", UDP: true}, {Hostname: "c", UDP: true},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn), selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn),
filtered: []models.WevpnServer{ filtered: []models.WevpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},
@@ -43,7 +43,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
"filter by protocol": { "filter by protocol": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{TCP: boolPtr(true)}, OpenVPN: settings.OpenVPNSelection{TCP: boolPtr(true)},
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
servers: []models.WevpnServer{ servers: []models.WevpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", TCP: true}, {Hostname: "b", TCP: true},
@@ -56,7 +56,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
servers: []models.WevpnServer{ servers: []models.WevpnServer{
{City: "a", UDP: true}, {City: "a", UDP: true},
{City: "b", UDP: true}, {City: "b", UDP: true},
@@ -69,7 +69,7 @@ func Test_Wevpn_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Wevpn), }.WithDefaults(providers.Wevpn),
servers: []models.WevpnServer{ servers: []models.WevpnServer{
{Hostname: "a", UDP: true}, {Hostname: "a", UDP: true},
{Hostname: "b", UDP: true}, {Hostname: "b", UDP: true},

View File

@@ -3,7 +3,7 @@ package wevpn
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.WevpnServer, randSource rand.Source) *Wevpn {
return &Wevpn{ return &Wevpn{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Wevpn), NoPortForwarder: utils.NewNoPortForwarding(providers.Wevpn),
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -23,7 +24,7 @@ func Test_Windscribe_GetConnection(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -32,7 +33,7 @@ func Test_Windscribe_GetConnection(t *testing.T) {
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(3, 3, 3, 3)}},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe),
connection: models.Connection{ connection: models.Connection{
Type: constants.OpenVPN, Type: constants.OpenVPN,
IP: net.IPv4(1, 1, 1, 1), IP: net.IPv4(1, 1, 1, 1),
@@ -43,7 +44,7 @@ func Test_Windscribe_GetConnection(t *testing.T) {
"target IP": { "target IP": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
TargetIP: net.IPv4(2, 2, 2, 2), TargetIP: net.IPv4(2, 2, 2, 2),
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},
@@ -59,7 +60,7 @@ func Test_Windscribe_GetConnection(t *testing.T) {
"with filter": { "with filter": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {VPN: constants.OpenVPN, Hostname: "a", IPs: []net.IP{net.IPv4(1, 1, 1, 1)}},
{VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, {VPN: constants.OpenVPN, Hostname: "b", IPs: []net.IP{net.IPv4(2, 2, 2, 2)}},

View File

@@ -7,6 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@@ -22,7 +23,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
err error err error
}{ }{
"no server available": { "no server available": {
selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe),
err: errors.New("no server found: for VPN openvpn; protocol udp"), err: errors.New("no server found: for VPN openvpn; protocol udp"),
}, },
"no filter": { "no filter": {
@@ -31,7 +32,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},
{VPN: constants.OpenVPN, Hostname: "c"}, {VPN: constants.OpenVPN, Hostname: "c"},
}, },
selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe),
filtered: []models.WindscribeServer{ filtered: []models.WindscribeServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},
@@ -41,7 +42,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
"filter OpenVPN out": { "filter OpenVPN out": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
VPN: constants.Wireguard, VPN: constants.Wireguard,
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.Wireguard, Hostname: "b"}, {VPN: constants.Wireguard, Hostname: "b"},
@@ -54,7 +55,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
"filter by region": { "filter by region": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Regions: []string{"b"}, Regions: []string{"b"},
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, Region: "a"}, {VPN: constants.OpenVPN, Region: "a"},
{VPN: constants.OpenVPN, Region: "b"}, {VPN: constants.OpenVPN, Region: "b"},
@@ -67,7 +68,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
"filter by city": { "filter by city": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Cities: []string{"b"}, Cities: []string{"b"},
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, City: "a"}, {VPN: constants.OpenVPN, City: "a"},
{VPN: constants.OpenVPN, City: "b"}, {VPN: constants.OpenVPN, City: "b"},
@@ -80,7 +81,7 @@ func Test_Windscribe_filterServers(t *testing.T) {
"filter by hostname": { "filter by hostname": {
selection: settings.ServerSelection{ selection: settings.ServerSelection{
Hostnames: []string{"b"}, Hostnames: []string{"b"},
}.WithDefaults(constants.Windscribe), }.WithDefaults(providers.Windscribe),
servers: []models.WindscribeServer{ servers: []models.WindscribeServer{
{VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "a"},
{VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "b"},

View File

@@ -3,7 +3,7 @@ package windscribe
import ( import (
"math/rand" "math/rand"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/provider/utils" "github.com/qdm12/gluetun/internal/provider/utils"
) )
@@ -18,6 +18,6 @@ func New(servers []models.WindscribeServer, randSource rand.Source) *Windscribe
return &Windscribe{ return &Windscribe{
servers: servers, servers: servers,
randSource: randSource, randSource: randSource,
NoPortForwarder: utils.NewNoPortForwarding(constants.Windscribe), NoPortForwarder: utils.NewNoPortForwarding(providers.Windscribe),
} }
} }

View File

@@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/updater/providers/cyberghost" "github.com/qdm12/gluetun/internal/updater/providers/cyberghost"
"github.com/qdm12/gluetun/internal/updater/providers/expressvpn" "github.com/qdm12/gluetun/internal/updater/providers/expressvpn"
"github.com/qdm12/gluetun/internal/updater/providers/fastestvpn" "github.com/qdm12/gluetun/internal/updater/providers/fastestvpn"
@@ -196,7 +196,7 @@ func (u *updater) updatePerfectprivacy(ctx context.Context) (err error) {
servers, warnings, err := perfectprivacy.GetServers(ctx, u.unzipper, minServers) servers, warnings, err := perfectprivacy.GetServers(ctx, u.unzipper, minServers)
if *u.options.CLI { if *u.options.CLI {
for _, warning := range warnings { for _, warning := range warnings {
u.logger.Warn(constants.Perfectprivacy + ": " + warning) u.logger.Warn(providers.Perfectprivacy + ": " + warning)
} }
} }
if err != nil { if err != nil {
@@ -365,7 +365,7 @@ func (u *updater) updateVPNUnlimited(ctx context.Context) (err error) {
ctx, u.unzipper, u.presolver, minServers) ctx, u.unzipper, u.presolver, minServers)
if *u.options.CLI { if *u.options.CLI {
for _, warning := range warnings { for _, warning := range warnings {
u.logger.Warn(constants.VPNUnlimited + ": " + warning) u.logger.Warn(providers.VPNUnlimited + ": " + warning)
} }
} }
if err != nil { if err != nil {

View File

@@ -8,7 +8,7 @@ import (
"time" "time"
"github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants" "github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/updater/resolver" "github.com/qdm12/gluetun/internal/updater/resolver"
"github.com/qdm12/gluetun/internal/updater/unzip" "github.com/qdm12/gluetun/internal/updater/unzip"
@@ -70,47 +70,47 @@ func (u *updater) UpdateServers(ctx context.Context) (allServers models.AllServe
func (u *updater) getUpdateFunction(provider string) (updateFunction updateFunc) { func (u *updater) getUpdateFunction(provider string) (updateFunction updateFunc) {
switch provider { switch provider {
case constants.Custom: case providers.Custom:
panic("cannot update custom provider") panic("cannot update custom provider")
case constants.Cyberghost: case providers.Cyberghost:
return func(ctx context.Context) (err error) { return u.updateCyberghost(ctx) } return func(ctx context.Context) (err error) { return u.updateCyberghost(ctx) }
case constants.Expressvpn: case providers.Expressvpn:
return func(ctx context.Context) (err error) { return u.updateExpressvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateExpressvpn(ctx) }
case constants.Fastestvpn: case providers.Fastestvpn:
return func(ctx context.Context) (err error) { return u.updateFastestvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateFastestvpn(ctx) }
case constants.HideMyAss: case providers.HideMyAss:
return func(ctx context.Context) (err error) { return u.updateHideMyAss(ctx) } return func(ctx context.Context) (err error) { return u.updateHideMyAss(ctx) }
case constants.Ipvanish: case providers.Ipvanish:
return func(ctx context.Context) (err error) { return u.updateIpvanish(ctx) } return func(ctx context.Context) (err error) { return u.updateIpvanish(ctx) }
case constants.Ivpn: case providers.Ivpn:
return func(ctx context.Context) (err error) { return u.updateIvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateIvpn(ctx) }
case constants.Mullvad: case providers.Mullvad:
return func(ctx context.Context) (err error) { return u.updateMullvad(ctx) } return func(ctx context.Context) (err error) { return u.updateMullvad(ctx) }
case constants.Nordvpn: case providers.Nordvpn:
return func(ctx context.Context) (err error) { return u.updateNordvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateNordvpn(ctx) }
case constants.Perfectprivacy: case providers.Perfectprivacy:
return func(ctx context.Context) (err error) { return u.updatePerfectprivacy(ctx) } return func(ctx context.Context) (err error) { return u.updatePerfectprivacy(ctx) }
case constants.Privado: case providers.Privado:
return func(ctx context.Context) (err error) { return u.updatePrivado(ctx) } return func(ctx context.Context) (err error) { return u.updatePrivado(ctx) }
case constants.PrivateInternetAccess: case providers.PrivateInternetAccess:
return func(ctx context.Context) (err error) { return u.updatePIA(ctx) } return func(ctx context.Context) (err error) { return u.updatePIA(ctx) }
case constants.Privatevpn: case providers.Privatevpn:
return func(ctx context.Context) (err error) { return u.updatePrivatevpn(ctx) } return func(ctx context.Context) (err error) { return u.updatePrivatevpn(ctx) }
case constants.Protonvpn: case providers.Protonvpn:
return func(ctx context.Context) (err error) { return u.updateProtonvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateProtonvpn(ctx) }
case constants.Purevpn: case providers.Purevpn:
return func(ctx context.Context) (err error) { return u.updatePurevpn(ctx) } return func(ctx context.Context) (err error) { return u.updatePurevpn(ctx) }
case constants.Surfshark: case providers.Surfshark:
return func(ctx context.Context) (err error) { return u.updateSurfshark(ctx) } return func(ctx context.Context) (err error) { return u.updateSurfshark(ctx) }
case constants.Torguard: case providers.Torguard:
return func(ctx context.Context) (err error) { return u.updateTorguard(ctx) } return func(ctx context.Context) (err error) { return u.updateTorguard(ctx) }
case constants.VPNUnlimited: case providers.VPNUnlimited:
return func(ctx context.Context) (err error) { return u.updateVPNUnlimited(ctx) } return func(ctx context.Context) (err error) { return u.updateVPNUnlimited(ctx) }
case constants.Vyprvpn: case providers.Vyprvpn:
return func(ctx context.Context) (err error) { return u.updateVyprvpn(ctx) } return func(ctx context.Context) (err error) { return u.updateVyprvpn(ctx) }
case constants.Wevpn: case providers.Wevpn:
return func(ctx context.Context) (err error) { return u.updateWevpn(ctx) } return func(ctx context.Context) (err error) { return u.updateWevpn(ctx) }
case constants.Windscribe: case providers.Windscribe:
return func(ctx context.Context) (err error) { return u.updateWindscribe(ctx) } return func(ctx context.Context) (err error) { return u.updateWindscribe(ctx) }
default: default:
panic("provider " + provider + " is unknown") panic("provider " + provider + " is unknown")