From 54b7e23974007742f1348af76f25b93116fc133b Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Sat, 16 Apr 2022 19:30:26 +0000 Subject: [PATCH] chore(constants): `internal/constants/providers` - New package to avoid package import cycles --- internal/cli/formatservers.go | 41 +++++++------- internal/cli/update.go | 5 +- internal/configuration/settings/openvpn.go | 19 ++++--- .../settings/openvpnselection.go | 41 +++++++------- .../configuration/settings/portforward.go | 4 +- internal/configuration/settings/provider.go | 13 +++-- .../configuration/settings/serverselection.go | 55 ++++++++++--------- internal/configuration/settings/updater.go | 8 +-- internal/configuration/settings/wireguard.go | 10 ++-- .../settings/wireguardselection.go | 20 +++---- .../configuration/sources/env/provider.go | 5 +- .../sources/env/serverselection.go | 4 +- internal/constants/providers.go | 27 --------- internal/constants/providers/providers.go | 53 ++++++++++++++++++ internal/constants/vpn.go | 46 ---------------- internal/provider/custom/openvpnconf_test.go | 3 +- internal/provider/custom/provider.go | 4 +- internal/provider/cyberghost/filter_test.go | 12 ++-- internal/provider/cyberghost/provider.go | 4 +- .../provider/expressvpn/connection_test.go | 9 +-- internal/provider/expressvpn/filter_test.go | 14 ++--- internal/provider/expressvpn/provider.go | 4 +- internal/provider/fastestvpn/provider.go | 4 +- internal/provider/hidemyass/provider.go | 4 +- internal/provider/ipvanish/provider.go | 4 +- internal/provider/ivpn/connection_test.go | 9 +-- internal/provider/ivpn/filter_test.go | 15 ++--- internal/provider/ivpn/provider.go | 4 +- internal/provider/mullvad/connection_test.go | 9 +-- internal/provider/mullvad/filter_test.go | 17 +++--- internal/provider/mullvad/provider.go | 4 +- internal/provider/nordvpn/provider.go | 4 +- internal/provider/perfectprivacy/provider.go | 4 +- internal/provider/privado/provider.go | 4 +- internal/provider/privatevpn/provider.go | 4 +- internal/provider/protonvpn/provider.go | 4 +- internal/provider/provider.go | 44 +++++++-------- internal/provider/purevpn/provider.go | 4 +- internal/provider/surfshark/filter_test.go | 18 +++--- internal/provider/surfshark/provider.go | 4 +- internal/provider/torguard/provider.go | 4 +- internal/provider/vpnunlimited/provider.go | 4 +- internal/provider/vyprvpn/provider.go | 4 +- internal/provider/wevpn/connection_test.go | 9 +-- internal/provider/wevpn/filter_test.go | 12 ++-- internal/provider/wevpn/provider.go | 4 +- .../provider/windscribe/connection_test.go | 9 +-- internal/provider/windscribe/filter_test.go | 13 +++-- internal/provider/windscribe/provider.go | 4 +- internal/updater/providers.go | 6 +- internal/updater/updater.go | 44 +++++++-------- 51 files changed, 335 insertions(+), 339 deletions(-) delete mode 100644 internal/constants/providers.go create mode 100644 internal/constants/providers/providers.go diff --git a/internal/cli/formatservers.go b/internal/cli/formatservers.go index 271097b3..977ad0f2 100644 --- a/internal/cli/formatservers.go +++ b/internal/cli/formatservers.go @@ -8,6 +8,7 @@ import ( "path/filepath" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/storage" ) @@ -28,26 +29,26 @@ func (c *CLI) FormatServers(args []string) error { flagSet := flag.NewFlagSet("markdown", flag.ExitOnError) 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.BoolVar(&cyberghost, "cyberghost", false, "Format Cyberghost servers") - flagSet.BoolVar(&expressvpn, "expressvpn", false, "Format ExpressVPN servers") - flagSet.BoolVar(&fastestvpn, "fastestvpn", false, "Format FastestVPN servers") - flagSet.BoolVar(&hideMyAss, "hidemyass", false, "Format HideMyAss servers") - flagSet.BoolVar(&ipvanish, "ipvanish", false, "Format IpVanish servers") - flagSet.BoolVar(&ivpn, "ivpn", false, "Format IVPN servers") - flagSet.BoolVar(&mullvad, "mullvad", false, "Format Mullvad servers") - flagSet.BoolVar(&nordvpn, "nordvpn", false, "Format Nordvpn servers") - flagSet.BoolVar(&perfectPrivacy, "perfectprivacy", false, "Format Perfect Privacy servers") - flagSet.BoolVar(&pia, "pia", false, "Format Private Internet Access servers") - flagSet.BoolVar(&privado, "privado", false, "Format Privado servers") - flagSet.BoolVar(&privatevpn, "privatevpn", false, "Format Private VPN servers") - flagSet.BoolVar(&protonvpn, "protonvpn", false, "Format Protonvpn servers") - flagSet.BoolVar(&purevpn, "purevpn", false, "Format Purevpn servers") - flagSet.BoolVar(&surfshark, "surfshark", false, "Format Surfshark servers") - flagSet.BoolVar(&torguard, "torguard", false, "Format Torguard servers") - flagSet.BoolVar(&vpnUnlimited, "vpnunlimited", false, "Format VPN Unlimited servers") - flagSet.BoolVar(&vyprvpn, "vyprvpn", false, "Format Vyprvpn servers") - flagSet.BoolVar(&wevpn, "wevpn", false, "Format WeVPN servers") - flagSet.BoolVar(&windscribe, "windscribe", false, "Format Windscribe servers") + flagSet.BoolVar(&cyberghost, providers.Cyberghost, false, "Format Cyberghost servers") + flagSet.BoolVar(&expressvpn, providers.Expressvpn, false, "Format ExpressVPN servers") + flagSet.BoolVar(&fastestvpn, providers.Fastestvpn, false, "Format FastestVPN servers") + flagSet.BoolVar(&hideMyAss, providers.HideMyAss, false, "Format HideMyAss servers") + flagSet.BoolVar(&ipvanish, providers.Ipvanish, false, "Format IpVanish servers") + flagSet.BoolVar(&ivpn, providers.Ivpn, false, "Format IVPN servers") + flagSet.BoolVar(&mullvad, providers.Mullvad, false, "Format Mullvad servers") + flagSet.BoolVar(&nordvpn, providers.Nordvpn, false, "Format Nordvpn servers") + flagSet.BoolVar(&perfectPrivacy, providers.Perfectprivacy, false, "Format Perfect Privacy servers") + flagSet.BoolVar(&pia, providers.PrivateInternetAccess, false, "Format Private Internet Access servers") + flagSet.BoolVar(&privado, providers.Privado, false, "Format Privado servers") + flagSet.BoolVar(&privatevpn, providers.Privatevpn, false, "Format Private VPN servers") + flagSet.BoolVar(&protonvpn, providers.Protonvpn, false, "Format Protonvpn servers") + flagSet.BoolVar(&purevpn, providers.Purevpn, false, "Format Purevpn servers") + flagSet.BoolVar(&surfshark, providers.Surfshark, false, "Format Surfshark servers") + flagSet.BoolVar(&torguard, providers.Torguard, false, "Format Torguard servers") + flagSet.BoolVar(&vpnUnlimited, providers.VPNUnlimited, false, "Format VPN Unlimited servers") + flagSet.BoolVar(&vyprvpn, providers.Vyprvpn, false, "Format Vyprvpn servers") + flagSet.BoolVar(&wevpn, providers.Wevpn, false, "Format WeVPN servers") + flagSet.BoolVar(&windscribe, providers.Windscribe, false, "Format Windscribe servers") if err := flagSet.Parse(args); err != nil { return err } diff --git a/internal/cli/update.go b/internal/cli/update.go index c1a3daad..79cfe284 100644 --- a/internal/cli/update.go +++ b/internal/cli/update.go @@ -14,6 +14,7 @@ import ( "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/storage" "github.com/qdm12/gluetun/internal/updater" @@ -62,8 +63,8 @@ func (c *CLI) Update(ctx context.Context, args []string, logger UpdaterLogger) e } if updateAll { - for _, provider := range constants.AllProviders() { - if provider == constants.Custom { + for _, provider := range providers.All() { + if provider == providers.Custom { continue } options.Providers = append(options.Providers, provider) diff --git a/internal/configuration/settings/openvpn.go b/internal/configuration/settings/openvpn.go index e4b7752a..031fef95 100644 --- a/internal/configuration/settings/openvpn.go +++ b/internal/configuration/settings/openvpn.go @@ -7,6 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/openvpn/parse" "github.com/qdm12/gotree" ) @@ -84,14 +85,14 @@ func (o OpenVPN) validate(vpnProvider string) (err error) { ErrOpenVPNVersionIsNotValid, o.Version, strings.Join(validVersions, ", ")) } - isCustom := vpnProvider == constants.Custom + isCustom := vpnProvider == providers.Custom if !isCustom && o.User == "" { return ErrOpenVPNUserIsEmpty } passwordRequired := !isCustom && - (vpnProvider != constants.Ivpn || !ivpnAccountID.MatchString(o.User)) + (vpnProvider != providers.Ivpn || !ivpnAccountID.MatchString(o.User)) if passwordRequired && o.Password == "" { return ErrOpenVPNPasswordIsEmpty @@ -153,8 +154,8 @@ func validateOpenVPNClientCertificate(vpnProvider, clientCert string) (err error) { switch vpnProvider { case - constants.Cyberghost, - constants.VPNUnlimited: + providers.Cyberghost, + providers.VPNUnlimited: if clientCert == "" { return ErrMissingValue } @@ -174,9 +175,9 @@ func validateOpenVPNClientCertificate(vpnProvider, func validateOpenVPNClientKey(vpnProvider, clientKey string) (err error) { switch vpnProvider { case - constants.Cyberghost, - constants.VPNUnlimited, - constants.Wevpn: + providers.Cyberghost, + providers.VPNUnlimited, + providers.Wevpn: if clientKey == "" { return ErrMissingValue } @@ -256,7 +257,7 @@ func (o *OpenVPN) overrideWith(other OpenVPN) { func (o *OpenVPN) setDefaults(vpnProvider string) { o.Version = helpers.DefaultString(o.Version, constants.Openvpn25) - if vpnProvider == constants.Mullvad { + if vpnProvider == providers.Mullvad { o.Password = "m" } @@ -266,7 +267,7 @@ func (o *OpenVPN) setDefaults(vpnProvider string) { o.ClientKey = helpers.DefaultStringPtr(o.ClientKey, "") var defaultEncPreset string - if vpnProvider == constants.PrivateInternetAccess { + if vpnProvider == providers.PrivateInternetAccess { defaultEncPreset = constants.PIAEncryptionPresetStrong } o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset) diff --git a/internal/configuration/settings/openvpnselection.go b/internal/configuration/settings/openvpnselection.go index 659556f5..67f8a140 100644 --- a/internal/configuration/settings/openvpnselection.go +++ b/internal/configuration/settings/openvpnselection.go @@ -5,6 +5,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gotree" ) @@ -39,11 +40,11 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) { // Validate TCP if *o.TCP && helpers.IsOneOf(vpnProvider, - constants.Ipvanish, - constants.Perfectprivacy, - constants.Privado, - constants.VPNUnlimited, - constants.Vyprvpn, + providers.Ipvanish, + providers.Perfectprivacy, + providers.Privado, + providers.VPNUnlimited, + providers.Vyprvpn, ) { return fmt.Errorf("%w: for VPN service provider %s", ErrOpenVPNTCPNotSupported, vpnProvider) @@ -53,33 +54,33 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) { if *o.CustomPort != 0 { switch vpnProvider { // no restriction on port - case constants.Cyberghost, constants.HideMyAss, - constants.PrivateInternetAccess, constants.Privatevpn, - constants.Protonvpn, constants.Torguard: + case providers.Cyberghost, providers.HideMyAss, + providers.PrivateInternetAccess, providers.Privatevpn, + providers.Protonvpn, providers.Torguard: // no custom port allowed - case constants.Expressvpn, constants.Fastestvpn, - constants.Ipvanish, constants.Nordvpn, - constants.Privado, constants.Purevpn, - constants.Surfshark, constants.VPNUnlimited, - constants.Vyprvpn: + case providers.Expressvpn, providers.Fastestvpn, + providers.Ipvanish, providers.Nordvpn, + providers.Privado, providers.Purevpn, + providers.Surfshark, providers.VPNUnlimited, + providers.Vyprvpn: return fmt.Errorf("%w: for VPN service provider %s", ErrOpenVPNCustomPortNotAllowed, vpnProvider) default: var allowedTCP, allowedUDP []uint16 switch vpnProvider { - case constants.Ivpn: + case providers.Ivpn: allowedTCP = []uint16{80, 443, 1143} allowedUDP = []uint16{53, 1194, 2049, 2050} - case constants.Mullvad: + case providers.Mullvad: allowedTCP = []uint16{80, 443, 1401} allowedUDP = []uint16{53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400} - case constants.Perfectprivacy: + case providers.Perfectprivacy: allowedTCP = []uint16{44, 443, 4433} allowedUDP = []uint16{44, 443, 4433} - case constants.Wevpn: + case providers.Wevpn: allowedTCP = []uint16{53, 1195, 1199, 2018} allowedUDP = []uint16{80, 1194, 1198} - case constants.Windscribe: + case providers.Windscribe: allowedTCP = []uint16{21, 22, 80, 123, 143, 443, 587, 1194, 3306, 8080, 54783} allowedUDP = []uint16{53, 80, 123, 443, 1194, 54783} } @@ -97,7 +98,7 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) { } // Validate EncPreset - if vpnProvider == constants.PrivateInternetAccess { + if vpnProvider == providers.PrivateInternetAccess { validEncryptionPresets := []string{ constants.PIAEncryptionPresetNone, constants.PIAEncryptionPresetNormal, @@ -142,7 +143,7 @@ func (o *OpenVPNSelection) setDefaults(vpnProvider string) { o.CustomPort = helpers.DefaultUint16(o.CustomPort, 0) var defaultEncPreset string - if vpnProvider == constants.PrivateInternetAccess { + if vpnProvider == providers.PrivateInternetAccess { defaultEncPreset = constants.PIAEncryptionPresetStrong } o.PIAEncPreset = helpers.DefaultStringPtr(o.PIAEncPreset, defaultEncPreset) diff --git a/internal/configuration/settings/portforward.go b/internal/configuration/settings/portforward.go index d9de6870..42b83a6d 100644 --- a/internal/configuration/settings/portforward.go +++ b/internal/configuration/settings/portforward.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/qdm12/gluetun/internal/configuration/settings/helpers" - "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gotree" ) @@ -28,7 +28,7 @@ func (p PortForwarding) validate(vpnProvider string) (err error) { } // Validate Enabled - validProviders := []string{constants.PrivateInternetAccess} + validProviders := []string{providers.PrivateInternetAccess} if !helpers.IsOneOf(vpnProvider, validProviders...) { return fmt.Errorf("%w: for provider %s, it is only available for %s", ErrPortForwardingEnabled, vpnProvider, strings.Join(validProviders, ", ")) diff --git a/internal/configuration/settings/provider.go b/internal/configuration/settings/provider.go index 4a03d9fa..f39ed1fc 100644 --- a/internal/configuration/settings/provider.go +++ b/internal/configuration/settings/provider.go @@ -5,6 +5,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gotree" ) @@ -26,14 +27,14 @@ func (p *Provider) validate(vpnType string, allServers models.AllServers) (err e // Validate Name var validNames []string if vpnType == constants.OpenVPN { - validNames = constants.AllProviders() + validNames = providers.All() validNames = append(validNames, "pia") // Retro-compatibility } else { // Wireguard validNames = []string{ - constants.Custom, - constants.Ivpn, - constants.Mullvad, - constants.Windscribe, + providers.Custom, + providers.Ivpn, + providers.Mullvad, + providers.Windscribe, } } if !helpers.IsOneOf(*p.Name, validNames...) { @@ -75,7 +76,7 @@ func (p *Provider) overrideWith(other Provider) { } func (p *Provider) setDefaults() { - p.Name = helpers.DefaultStringPtr(p.Name, constants.PrivateInternetAccess) + p.Name = helpers.DefaultStringPtr(p.Name, providers.PrivateInternetAccess) p.ServerSelection.setDefaults(*p.Name) p.PortForwarding.setDefaults() } diff --git a/internal/configuration/settings/serverselection.go b/internal/configuration/settings/serverselection.go index 7d86d54c..c9b8d7ee 100644 --- a/internal/configuration/settings/serverselection.go +++ b/internal/configuration/settings/serverselection.go @@ -9,6 +9,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings/helpers" "github.com/qdm12/gluetun/internal/configuration/settings/validation" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/models" "github.com/qdm12/gotree" ) @@ -90,15 +91,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string, } if *ss.OwnedOnly && - vpnServiceProvider != constants.Mullvad { + vpnServiceProvider != providers.Mullvad { return fmt.Errorf("%w: for VPN service provider %s", ErrOwnedOnlyNotSupported, vpnServiceProvider) } if *ss.FreeOnly && !helpers.IsOneOf(vpnServiceProvider, - constants.Protonvpn, - constants.VPNUnlimited, + providers.Protonvpn, + providers.VPNUnlimited, ) { return fmt.Errorf("%w: for VPN service provider %s", ErrFreeOnlyNotSupported, vpnServiceProvider) @@ -106,15 +107,15 @@ func (ss *ServerSelection) validate(vpnServiceProvider string, if *ss.StreamOnly && !helpers.IsOneOf(vpnServiceProvider, - constants.Protonvpn, - constants.VPNUnlimited, + providers.Protonvpn, + providers.VPNUnlimited, ) { return fmt.Errorf("%w: for VPN service provider %s", ErrStreamOnlyNotSupported, vpnServiceProvider) } if *ss.MultiHopOnly && - vpnServiceProvider != constants.Surfshark { + vpnServiceProvider != providers.Surfshark { return fmt.Errorf("%w: for VPN service provider %s", ErrMultiHopOnlyNotSupported, vpnServiceProvider) } @@ -140,80 +141,80 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection, ispChoices, nameChoices, hostnameChoices []string, err error) { switch vpnServiceProvider { - case constants.Custom: - case constants.Cyberghost: + case providers.Custom: + case providers.Cyberghost: servers := allServers.GetCyberghost() countryChoices = validation.CyberghostCountryChoices(servers) hostnameChoices = validation.CyberghostHostnameChoices(servers) - case constants.Expressvpn: + case providers.Expressvpn: servers := allServers.GetExpressvpn() countryChoices = validation.ExpressvpnCountriesChoices(servers) cityChoices = validation.ExpressvpnCityChoices(servers) hostnameChoices = validation.ExpressvpnHostnameChoices(servers) - case constants.Fastestvpn: + case providers.Fastestvpn: servers := allServers.GetFastestvpn() countryChoices = validation.FastestvpnCountriesChoices(servers) hostnameChoices = validation.FastestvpnHostnameChoices(servers) - case constants.HideMyAss: + case providers.HideMyAss: servers := allServers.GetHideMyAss() countryChoices = validation.HideMyAssCountryChoices(servers) regionChoices = validation.HideMyAssRegionChoices(servers) cityChoices = validation.HideMyAssCityChoices(servers) hostnameChoices = validation.HideMyAssHostnameChoices(servers) - case constants.Ipvanish: + case providers.Ipvanish: servers := allServers.GetIpvanish() countryChoices = validation.IpvanishCountryChoices(servers) cityChoices = validation.IpvanishCityChoices(servers) hostnameChoices = validation.IpvanishHostnameChoices(servers) - case constants.Ivpn: + case providers.Ivpn: servers := allServers.GetIvpn() countryChoices = validation.IvpnCountryChoices(servers) cityChoices = validation.IvpnCityChoices(servers) ispChoices = validation.IvpnISPChoices(servers) hostnameChoices = validation.IvpnHostnameChoices(servers) - case constants.Mullvad: + case providers.Mullvad: servers := allServers.GetMullvad() countryChoices = validation.MullvadCountryChoices(servers) cityChoices = validation.MullvadCityChoices(servers) ispChoices = validation.MullvadISPChoices(servers) hostnameChoices = validation.MullvadHostnameChoices(servers) - case constants.Nordvpn: + case providers.Nordvpn: servers := allServers.GetNordvpn() regionChoices = validation.NordvpnRegionChoices(servers) hostnameChoices = validation.NordvpnHostnameChoices(servers) - case constants.Perfectprivacy: + case providers.Perfectprivacy: servers := allServers.GetPerfectprivacy() cityChoices = validation.PerfectprivacyCityChoices(servers) - case constants.Privado: + case providers.Privado: servers := allServers.GetPrivado() countryChoices = validation.PrivadoCountryChoices(servers) regionChoices = validation.PrivadoRegionChoices(servers) cityChoices = validation.PrivadoCityChoices(servers) hostnameChoices = validation.PrivadoHostnameChoices(servers) - case constants.PrivateInternetAccess: + case providers.PrivateInternetAccess: servers := allServers.GetPia() regionChoices = validation.PIAGeoChoices(servers) hostnameChoices = validation.PIAHostnameChoices(servers) nameChoices = validation.PIANameChoices(servers) - case constants.Privatevpn: + case providers.Privatevpn: servers := allServers.GetPrivatevpn() countryChoices = validation.PrivatevpnCountryChoices(servers) cityChoices = validation.PrivatevpnCityChoices(servers) hostnameChoices = validation.PrivatevpnHostnameChoices(servers) - case constants.Protonvpn: + case providers.Protonvpn: servers := allServers.GetProtonvpn() countryChoices = validation.ProtonvpnCountryChoices(servers) regionChoices = validation.ProtonvpnRegionChoices(servers) cityChoices = validation.ProtonvpnCityChoices(servers) nameChoices = validation.ProtonvpnNameChoices(servers) hostnameChoices = validation.ProtonvpnHostnameChoices(servers) - case constants.Purevpn: + case providers.Purevpn: servers := allServers.GetPurevpn() countryChoices = validation.PurevpnCountryChoices(servers) regionChoices = validation.PurevpnRegionChoices(servers) cityChoices = validation.PurevpnCityChoices(servers) hostnameChoices = validation.PurevpnHostnameChoices(servers) - case constants.Surfshark: + case providers.Surfshark: servers := allServers.GetSurfshark() countryChoices = validation.SurfsharkCountryChoices(servers) cityChoices = validation.SurfsharkCityChoices(servers) @@ -227,24 +228,24 @@ func getLocationFilterChoices(vpnServiceProvider string, ss *ServerSelection, // Retro compatibility // TODO remove in v4 *ss = surfsharkRetroRegion(*ss) - case constants.Torguard: + case providers.Torguard: servers := allServers.GetTorguard() countryChoices = validation.TorguardCountryChoices(servers) cityChoices = validation.TorguardCityChoices(servers) hostnameChoices = validation.TorguardHostnameChoices(servers) - case constants.VPNUnlimited: + case providers.VPNUnlimited: servers := allServers.GetVPNUnlimited() countryChoices = validation.VPNUnlimitedCountryChoices(servers) cityChoices = validation.VPNUnlimitedCityChoices(servers) hostnameChoices = validation.VPNUnlimitedHostnameChoices(servers) - case constants.Vyprvpn: + case providers.Vyprvpn: servers := allServers.GetVyprvpn() regionChoices = validation.VyprvpnRegionChoices(servers) - case constants.Wevpn: + case providers.Wevpn: servers := allServers.GetWevpn() cityChoices = validation.WevpnCityChoices(servers) hostnameChoices = validation.WevpnHostnameChoices(servers) - case constants.Windscribe: + case providers.Windscribe: servers := allServers.GetWindscribe() regionChoices = validation.WindscribeRegionChoices(servers) cityChoices = validation.WindscribeCityChoices(servers) diff --git a/internal/configuration/settings/updater.go b/internal/configuration/settings/updater.go index 9eb6ca57..a930f22f 100644 --- a/internal/configuration/settings/updater.go +++ b/internal/configuration/settings/updater.go @@ -7,7 +7,7 @@ import ( "time" "github.com/qdm12/gluetun/internal/configuration/settings/helpers" - "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gotree" ) @@ -42,8 +42,8 @@ func (u Updater) Validate() (err error) { for i, provider := range u.Providers { valid := false - for _, validProvider := range constants.AllProviders() { - if validProvider == constants.Custom { + for _, validProvider := range providers.All() { + if validProvider == providers.Custom { continue } @@ -93,7 +93,7 @@ func (u *Updater) SetDefaults(vpnProvider string) { u.Period = helpers.DefaultDuration(u.Period, 0) u.DNSAddress = helpers.DefaultIP(u.DNSAddress, net.IPv4(1, 1, 1, 1)) u.CLI = helpers.DefaultBool(u.CLI, false) - if len(u.Providers) == 0 && vpnProvider != constants.Custom { + if len(u.Providers) == 0 && vpnProvider != providers.Custom { u.Providers = []string{vpnProvider} } } diff --git a/internal/configuration/settings/wireguard.go b/internal/configuration/settings/wireguard.go index 5ae960b1..367311d8 100644 --- a/internal/configuration/settings/wireguard.go +++ b/internal/configuration/settings/wireguard.go @@ -6,7 +6,7 @@ import ( "regexp" "github.com/qdm12/gluetun/internal/configuration/settings/helpers" - "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gotree" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) @@ -35,10 +35,10 @@ var regexpInterfaceName = regexp.MustCompile(`^[a-zA-Z0-9_]+$`) // It should only be ran if the VPN type chosen is Wireguard. func (w Wireguard) validate(vpnProvider string) (err error) { if !helpers.IsOneOf(vpnProvider, - constants.Custom, - constants.Ivpn, - constants.Mullvad, - constants.Windscribe, + providers.Custom, + providers.Ivpn, + providers.Mullvad, + providers.Windscribe, ) { // do not validate for VPN provider not supporting Wireguard return nil diff --git a/internal/configuration/settings/wireguardselection.go b/internal/configuration/settings/wireguardselection.go index 9d611848..80596cd6 100644 --- a/internal/configuration/settings/wireguardselection.go +++ b/internal/configuration/settings/wireguardselection.go @@ -5,7 +5,7 @@ import ( "net" "github.com/qdm12/gluetun/internal/configuration/settings/helpers" - "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gotree" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) @@ -36,8 +36,8 @@ type WireguardSelection struct { func (w WireguardSelection) validate(vpnProvider string) (err error) { // Validate EndpointIP switch vpnProvider { - case constants.Ivpn, constants.Mullvad, constants.Windscribe: // endpoint IP addresses are baked in - case constants.Custom: + case providers.Ivpn, providers.Mullvad, providers.Windscribe: // endpoint IP addresses are baked in + case providers.Custom: if len(w.EndpointIP) == 0 { return ErrWireguardEndpointIPNotSet } @@ -47,23 +47,23 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) { // Validate EndpointPort switch vpnProvider { // EndpointPort is required - case constants.Custom: + case providers.Custom: if *w.EndpointPort == 0 { return ErrWireguardEndpointPortNotSet } - case constants.Ivpn, constants.Mullvad, constants.Windscribe: + case providers.Ivpn, providers.Mullvad, providers.Windscribe: // EndpointPort is optional and can be 0 if *w.EndpointPort == 0 { break // no custom endpoint port set } - if vpnProvider == constants.Mullvad { + if vpnProvider == providers.Mullvad { break // no restriction on custom endpoint port value } var allowed []uint16 switch vpnProvider { - case constants.Ivpn: + case providers.Ivpn: allowed = []uint16{2049, 2050, 53, 30587, 41893, 48574, 58237} - case constants.Windscribe: + case providers.Windscribe: allowed = []uint16{53, 80, 123, 443, 1194, 65142} } @@ -78,8 +78,8 @@ func (w WireguardSelection) validate(vpnProvider string) (err error) { // Validate PublicKey switch vpnProvider { - case constants.Ivpn, constants.Mullvad, constants.Windscribe: // public keys are baked in - case constants.Custom: + case providers.Ivpn, providers.Mullvad, providers.Windscribe: // public keys are baked in + case providers.Custom: if w.PublicKey == "" { return ErrWireguardPublicKeyNotSet } diff --git a/internal/configuration/sources/env/provider.go b/internal/configuration/sources/env/provider.go index 4c3e45c8..059c6b8c 100644 --- a/internal/configuration/sources/env/provider.go +++ b/internal/configuration/sources/env/provider.go @@ -7,6 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" ) func (r *Reader) readProvider(vpnType string) (provider settings.Provider, err error) { @@ -35,11 +36,11 @@ func (r *Reader) readVPNServiceProvider(vpnType string) (vpnProviderPtr *string) switch { case vpnType != constants.Wireguard && os.Getenv("OPENVPN_CUSTOM_CONFIG") != "": // retro compatibility - return stringPtr(constants.Custom) + return stringPtr(providers.Custom) case s == "": return nil case s == "pia": // retro compatibility - return stringPtr(constants.PrivateInternetAccess) + return stringPtr(providers.PrivateInternetAccess) } return stringPtr(s) } diff --git a/internal/configuration/sources/env/serverselection.go b/internal/configuration/sources/env/serverselection.go index 68b2dded..26cba00e 100644 --- a/internal/configuration/sources/env/serverselection.go +++ b/internal/configuration/sources/env/serverselection.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/qdm12/gluetun/internal/configuration/settings" - "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" ) var ( @@ -27,7 +27,7 @@ func (r *Reader) readServerSelection(vpnProvider, vpnType string) ( countriesKey, _ := r.getEnvWithRetro("SERVER_COUNTRIES", "COUNTRY") ss.Countries = envToCSV(countriesKey) - if vpnProvider == constants.Cyberghost && len(ss.Countries) == 0 { + if vpnProvider == providers.Cyberghost && len(ss.Countries) == 0 { // Retro-compatibility for Cyberghost using the REGION variable ss.Countries = envToCSV("REGION") if len(ss.Countries) > 0 { diff --git a/internal/constants/providers.go b/internal/constants/providers.go deleted file mode 100644 index be76a36e..00000000 --- a/internal/constants/providers.go +++ /dev/null @@ -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, - } -} diff --git a/internal/constants/providers/providers.go b/internal/constants/providers/providers.go new file mode 100644 index 00000000..52ef1ca0 --- /dev/null +++ b/internal/constants/providers/providers.go @@ -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, + } +} diff --git a/internal/constants/vpn.go b/internal/constants/vpn.go index 3abc5a22..0b973b06 100644 --- a/internal/constants/vpn.go +++ b/internal/constants/vpn.go @@ -5,52 +5,6 @@ const ( 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 ( // TCP is a network protocol (reliable and slower than UDP). TCP string = "tcp" diff --git a/internal/provider/custom/openvpnconf_test.go b/internal/provider/custom/openvpnconf_test.go index b3062576..8d8f6076 100644 --- a/internal/provider/custom/openvpnconf_test.go +++ b/internal/provider/custom/openvpnconf_test.go @@ -6,6 +6,7 @@ import ( "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/stretchr/testify/assert" ) @@ -42,7 +43,7 @@ func Test_modifyConfig(t *testing.T) { ProcessUser: "procuser", Interface: "tun3", Verbosity: intPtr(0), - }.WithDefaults(constants.Custom), + }.WithDefaults(providers.Custom), connection: models.Connection{ IP: net.IPv4(1, 2, 3, 4), Port: 1194, diff --git a/internal/provider/custom/provider.go b/internal/provider/custom/provider.go index 28dab95d..fa17deba 100644 --- a/internal/provider/custom/provider.go +++ b/internal/provider/custom/provider.go @@ -1,7 +1,7 @@ package custom 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/provider/utils" ) @@ -14,6 +14,6 @@ type Provider struct { func New() *Provider { return &Provider{ extractor: extract.New(), - NoPortForwarder: utils.NewNoPortForwarding(constants.Custom), + NoPortForwarder: utils.NewNoPortForwarding(providers.Custom), } } diff --git a/internal/provider/cyberghost/filter_test.go b/internal/provider/cyberghost/filter_test.go index bc1d1648..b81c5218 100644 --- a/internal/provider/cyberghost/filter_test.go +++ b/internal/provider/cyberghost/filter_test.go @@ -5,7 +5,7 @@ import ( "testing" "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -22,7 +22,7 @@ func Test_Cyberghost_filterServers(t *testing.T) { err error }{ "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"), }, "servers without filter defaults to UDP": { @@ -32,7 +32,7 @@ func Test_Cyberghost_filterServers(t *testing.T) { {Country: "c", UDP: true}, {Country: "d", UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Cyberghost), + selection: settings.ServerSelection{}.WithDefaults(providers.Cyberghost), filteredServers: []models.CyberghostServer{ {Country: "c", UDP: true}, {Country: "d", UDP: true}, @@ -49,7 +49,7 @@ func Test_Cyberghost_filterServers(t *testing.T) { OpenVPN: settings.OpenVPNSelection{ TCP: boolPtr(true), }, - }.WithDefaults(constants.Cyberghost), + }.WithDefaults(providers.Cyberghost), filteredServers: []models.CyberghostServer{ {Country: "a", TCP: true}, {Country: "b", TCP: true}, @@ -64,7 +64,7 @@ func Test_Cyberghost_filterServers(t *testing.T) { }, selection: settings.ServerSelection{ Countries: []string{"a", "c"}, - }.WithDefaults(constants.Cyberghost), + }.WithDefaults(providers.Cyberghost), filteredServers: []models.CyberghostServer{ {Country: "a", UDP: true}, {Country: "c", UDP: true}, @@ -78,7 +78,7 @@ func Test_Cyberghost_filterServers(t *testing.T) { }, selection: settings.ServerSelection{ Hostnames: []string{"a", "c"}, - }.WithDefaults(constants.Cyberghost), + }.WithDefaults(providers.Cyberghost), filteredServers: []models.CyberghostServer{ {Hostname: "a", UDP: true}, {Hostname: "c", UDP: true}, diff --git a/internal/provider/cyberghost/provider.go b/internal/provider/cyberghost/provider.go index 80ab0514..538094af 100644 --- a/internal/provider/cyberghost/provider.go +++ b/internal/provider/cyberghost/provider.go @@ -3,7 +3,7 @@ package cyberghost import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.CyberghostServer, randSource rand.Source) *Cyberghost return &Cyberghost{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Cyberghost), + NoPortForwarder: utils.NewNoPortForwarding(providers.Cyberghost), } } diff --git a/internal/provider/expressvpn/connection_test.go b/internal/provider/expressvpn/connection_test.go index a49d8b66..db197c46 100644 --- a/internal/provider/expressvpn/connection_test.go +++ b/internal/provider/expressvpn/connection_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +24,7 @@ func Test_Provider_GetConnection(t *testing.T) { err error }{ "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"), }, "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(3, 3, 3, 3)}, UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn), connection: models.Connection{ Type: constants.OpenVPN, IP: net.IPv4(1, 1, 1, 1), @@ -43,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) { "target IP": { selection: settings.ServerSelection{ TargetIP: net.IPv4(2, 2, 2, 2), - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {IPs: []net.IP{net.IPv4(1, 1, 1, 1)}, 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": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {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}, diff --git a/internal/provider/expressvpn/filter_test.go b/internal/provider/expressvpn/filter_test.go index eb599f00..2996fa9c 100644 --- a/internal/provider/expressvpn/filter_test.go +++ b/internal/provider/expressvpn/filter_test.go @@ -6,7 +6,7 @@ import ( "testing" "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +24,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -33,7 +33,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { {Hostname: "b", UDP: true}, {Hostname: "c", UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Expressvpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Expressvpn), filtered: []models.ExpressvpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, @@ -43,7 +43,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { "filter by country": { selection: settings.ServerSelection{ Countries: []string{"b"}, - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {Country: "a", UDP: true}, {Country: "b", UDP: true}, @@ -56,7 +56,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {City: "a", UDP: true}, {City: "b", UDP: true}, @@ -69,7 +69,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, @@ -84,7 +84,7 @@ func Test_Expressvpn_filterServers(t *testing.T) { OpenVPN: settings.OpenVPNSelection{ TCP: boolPtr(true), }, - }.WithDefaults(constants.Expressvpn), + }.WithDefaults(providers.Expressvpn), servers: []models.ExpressvpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true, TCP: true}, diff --git a/internal/provider/expressvpn/provider.go b/internal/provider/expressvpn/provider.go index 54ac4092..07f74327 100644 --- a/internal/provider/expressvpn/provider.go +++ b/internal/provider/expressvpn/provider.go @@ -3,7 +3,7 @@ package expressvpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.ExpressvpnServer, randSource rand.Source) *Provider { return &Provider{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Expressvpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Expressvpn), } } diff --git a/internal/provider/fastestvpn/provider.go b/internal/provider/fastestvpn/provider.go index f63bb8e8..ef43a712 100644 --- a/internal/provider/fastestvpn/provider.go +++ b/internal/provider/fastestvpn/provider.go @@ -3,7 +3,7 @@ package fastestvpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.FastestvpnServer, randSource rand.Source) *Fastestvpn return &Fastestvpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Fastestvpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Fastestvpn), } } diff --git a/internal/provider/hidemyass/provider.go b/internal/provider/hidemyass/provider.go index c5abe28a..f36982ab 100644 --- a/internal/provider/hidemyass/provider.go +++ b/internal/provider/hidemyass/provider.go @@ -3,7 +3,7 @@ package hidemyass import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.HideMyAssServer, randSource rand.Source) *HideMyAss { return &HideMyAss{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.HideMyAss), + NoPortForwarder: utils.NewNoPortForwarding(providers.HideMyAss), } } diff --git a/internal/provider/ipvanish/provider.go b/internal/provider/ipvanish/provider.go index dadef82c..06ca31e1 100644 --- a/internal/provider/ipvanish/provider.go +++ b/internal/provider/ipvanish/provider.go @@ -3,7 +3,7 @@ package ipvanish import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.IpvanishServer, randSource rand.Source) *Ipvanish { return &Ipvanish{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Ipvanish), + NoPortForwarder: utils.NewNoPortForwarding(providers.Ipvanish), } } diff --git a/internal/provider/ivpn/connection_test.go b/internal/provider/ivpn/connection_test.go index 9601e3a6..a7563cce 100644 --- a/internal/provider/ivpn/connection_test.go +++ b/internal/provider/ivpn/connection_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +24,7 @@ func Test_Ivpn_GetConnection(t *testing.T) { err error }{ "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"), }, "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(3, 3, 3, 3)}, UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn), connection: models.Connection{ Type: constants.OpenVPN, IP: net.IPv4(1, 1, 1, 1), @@ -43,7 +44,7 @@ func Test_Ivpn_GetConnection(t *testing.T) { "target IP": { selection: settings.ServerSelection{ TargetIP: net.IPv4(2, 2, 2, 2), - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), 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(2, 2, 2, 2)}, UDP: true}, @@ -59,7 +60,7 @@ func Test_Ivpn_GetConnection(t *testing.T) { "with filter": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {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}, diff --git a/internal/provider/ivpn/filter_test.go b/internal/provider/ivpn/filter_test.go index 7de99c4f..0db6582b 100644 --- a/internal/provider/ivpn/filter_test.go +++ b/internal/provider/ivpn/filter_test.go @@ -7,6 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/models" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +25,7 @@ func Test_Ivpn_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -33,7 +34,7 @@ func Test_Ivpn_filterServers(t *testing.T) { {VPN: constants.OpenVPN, Hostname: "b", UDP: true}, {VPN: constants.OpenVPN, Hostname: "c", UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Ivpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Ivpn), filtered: []models.IvpnServer{ {VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true}, @@ -43,7 +44,7 @@ func Test_Ivpn_filterServers(t *testing.T) { "filter by country": { selection: settings.ServerSelection{ Countries: []string{"b"}, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {VPN: constants.OpenVPN, Country: "a", UDP: true}, {VPN: constants.OpenVPN, Country: "b", UDP: true}, @@ -56,7 +57,7 @@ func Test_Ivpn_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {VPN: constants.OpenVPN, City: "a", UDP: true}, {VPN: constants.OpenVPN, City: "b", UDP: true}, @@ -69,7 +70,7 @@ func Test_Ivpn_filterServers(t *testing.T) { "filter by ISP": { selection: settings.ServerSelection{ ISPs: []string{"b"}, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {VPN: constants.OpenVPN, ISP: "a", UDP: true}, {VPN: constants.OpenVPN, ISP: "b", UDP: true}, @@ -82,7 +83,7 @@ func Test_Ivpn_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true}, @@ -97,7 +98,7 @@ func Test_Ivpn_filterServers(t *testing.T) { OpenVPN: settings.OpenVPNSelection{ TCP: boolPtr(true), }, - }.WithDefaults(constants.Ivpn), + }.WithDefaults(providers.Ivpn), servers: []models.IvpnServer{ {VPN: constants.OpenVPN, Hostname: "a", UDP: true}, {VPN: constants.OpenVPN, Hostname: "b", UDP: true, TCP: true}, diff --git a/internal/provider/ivpn/provider.go b/internal/provider/ivpn/provider.go index d8dd3c28..2676ff9e 100644 --- a/internal/provider/ivpn/provider.go +++ b/internal/provider/ivpn/provider.go @@ -3,7 +3,7 @@ package ivpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.IvpnServer, randSource rand.Source) *Ivpn { return &Ivpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Ivpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Ivpn), } } diff --git a/internal/provider/mullvad/connection_test.go b/internal/provider/mullvad/connection_test.go index 95f528ff..98ac3a77 100644 --- a/internal/provider/mullvad/connection_test.go +++ b/internal/provider/mullvad/connection_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +24,7 @@ func Test_Mullvad_GetConnection(t *testing.T) { err error }{ "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"), }, "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(3, 3, 3, 3)}}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), + selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad), connection: models.Connection{ Type: constants.OpenVPN, IP: net.IPv4(1, 1, 1, 1), @@ -43,7 +44,7 @@ func Test_Mullvad_GetConnection(t *testing.T) { "target IP": { selection: settings.ServerSelection{ TargetIP: net.IPv4(2, 2, 2, 2), - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {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": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {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)}}, diff --git a/internal/provider/mullvad/filter_test.go b/internal/provider/mullvad/filter_test.go index 7e5fd0a0..74622507 100644 --- a/internal/provider/mullvad/filter_test.go +++ b/internal/provider/mullvad/filter_test.go @@ -7,6 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/models" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +25,7 @@ func Test_Mullvad_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -33,7 +34,7 @@ func Test_Mullvad_filterServers(t *testing.T) { {VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "c"}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Mullvad), + selection: settings.ServerSelection{}.WithDefaults(providers.Mullvad), filtered: []models.MullvadServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "b"}, @@ -43,7 +44,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter OpenVPN out": { selection: settings.ServerSelection{ VPN: constants.Wireguard, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.Wireguard, Hostname: "b"}, @@ -56,7 +57,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter by country": { selection: settings.ServerSelection{ Countries: []string{"b"}, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, Country: "a"}, {VPN: constants.OpenVPN, Country: "b"}, @@ -69,7 +70,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, City: "a"}, {VPN: constants.OpenVPN, City: "b"}, @@ -82,7 +83,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter by ISP": { selection: settings.ServerSelection{ ISPs: []string{"b"}, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, ISP: "a"}, {VPN: constants.OpenVPN, ISP: "b"}, @@ -95,7 +96,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "b"}, @@ -108,7 +109,7 @@ func Test_Mullvad_filterServers(t *testing.T) { "filter by owned": { selection: settings.ServerSelection{ OwnedOnly: boolPtr(true), - }.WithDefaults(constants.Mullvad), + }.WithDefaults(providers.Mullvad), servers: []models.MullvadServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "b", Owned: true}, diff --git a/internal/provider/mullvad/provider.go b/internal/provider/mullvad/provider.go index 8941d5cf..80dc9a43 100644 --- a/internal/provider/mullvad/provider.go +++ b/internal/provider/mullvad/provider.go @@ -3,7 +3,7 @@ package mullvad import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.MullvadServer, randSource rand.Source) *Mullvad { return &Mullvad{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Mullvad), + NoPortForwarder: utils.NewNoPortForwarding(providers.Mullvad), } } diff --git a/internal/provider/nordvpn/provider.go b/internal/provider/nordvpn/provider.go index 25f7564b..f17d101b 100644 --- a/internal/provider/nordvpn/provider.go +++ b/internal/provider/nordvpn/provider.go @@ -3,7 +3,7 @@ package nordvpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.NordvpnServer, randSource rand.Source) *Nordvpn { return &Nordvpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Nordvpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Nordvpn), } } diff --git a/internal/provider/perfectprivacy/provider.go b/internal/provider/perfectprivacy/provider.go index 6de0b2ad..19a4be07 100644 --- a/internal/provider/perfectprivacy/provider.go +++ b/internal/provider/perfectprivacy/provider.go @@ -3,7 +3,7 @@ package perfectprivacy import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.PerfectprivacyServer, randSource rand.Source) *Perfect return &Perfectprivacy{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Perfectprivacy), + NoPortForwarder: utils.NewNoPortForwarding(providers.Perfectprivacy), } } diff --git a/internal/provider/privado/provider.go b/internal/provider/privado/provider.go index 9c5fda78..8988dead 100644 --- a/internal/provider/privado/provider.go +++ b/internal/provider/privado/provider.go @@ -3,7 +3,7 @@ package privado import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.PrivadoServer, randSource rand.Source) *Privado { return &Privado{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Privado), + NoPortForwarder: utils.NewNoPortForwarding(providers.Privado), } } diff --git a/internal/provider/privatevpn/provider.go b/internal/provider/privatevpn/provider.go index 11f5a1e2..9811888b 100644 --- a/internal/provider/privatevpn/provider.go +++ b/internal/provider/privatevpn/provider.go @@ -3,7 +3,7 @@ package privatevpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.PrivatevpnServer, randSource rand.Source) *Privatevpn return &Privatevpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Privatevpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Privatevpn), } } diff --git a/internal/provider/protonvpn/provider.go b/internal/provider/protonvpn/provider.go index b9f5bd6a..f8370cfe 100644 --- a/internal/provider/protonvpn/provider.go +++ b/internal/provider/protonvpn/provider.go @@ -3,7 +3,7 @@ package protonvpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.ProtonvpnServer, randSource rand.Source) *Protonvpn { return &Protonvpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Protonvpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Protonvpn), } } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f81cabfc..e0fc93d8 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -9,7 +9,7 @@ import ( "time" "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/provider/custom" "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 { randSource := rand.NewSource(timeNow().UnixNano()) switch provider { - case constants.Custom: + case providers.Custom: return custom.New() - case constants.Cyberghost: + case providers.Cyberghost: return cyberghost.New(allServers.Cyberghost.Servers, randSource) - case constants.Expressvpn: + case providers.Expressvpn: return expressvpn.New(allServers.Expressvpn.Servers, randSource) - case constants.Fastestvpn: + case providers.Fastestvpn: return fastestvpn.New(allServers.Fastestvpn.Servers, randSource) - case constants.HideMyAss: + case providers.HideMyAss: return hidemyass.New(allServers.HideMyAss.Servers, randSource) - case constants.Ipvanish: + case providers.Ipvanish: return ipvanish.New(allServers.Ipvanish.Servers, randSource) - case constants.Ivpn: + case providers.Ivpn: return ivpn.New(allServers.Ivpn.Servers, randSource) - case constants.Mullvad: + case providers.Mullvad: return mullvad.New(allServers.Mullvad.Servers, randSource) - case constants.Nordvpn: + case providers.Nordvpn: return nordvpn.New(allServers.Nordvpn.Servers, randSource) - case constants.Perfectprivacy: + case providers.Perfectprivacy: return perfectprivacy.New(allServers.Perfectprivacy.Servers, randSource) - case constants.Privado: + case providers.Privado: return privado.New(allServers.Privado.Servers, randSource) - case constants.PrivateInternetAccess: + case providers.PrivateInternetAccess: return privateinternetaccess.New(allServers.Pia.Servers, randSource, timeNow) - case constants.Privatevpn: + case providers.Privatevpn: return privatevpn.New(allServers.Privatevpn.Servers, randSource) - case constants.Protonvpn: + case providers.Protonvpn: return protonvpn.New(allServers.Protonvpn.Servers, randSource) - case constants.Purevpn: + case providers.Purevpn: return purevpn.New(allServers.Purevpn.Servers, randSource) - case constants.Surfshark: + case providers.Surfshark: return surfshark.New(allServers.Surfshark.Servers, randSource) - case constants.Torguard: + case providers.Torguard: return torguard.New(allServers.Torguard.Servers, randSource) - case constants.VPNUnlimited: + case providers.VPNUnlimited: return vpnunlimited.New(allServers.VPNUnlimited.Servers, randSource) - case constants.Vyprvpn: + case providers.Vyprvpn: return vyprvpn.New(allServers.Vyprvpn.Servers, randSource) - case constants.Wevpn: + case providers.Wevpn: return wevpn.New(allServers.Wevpn.Servers, randSource) - case constants.Windscribe: + case providers.Windscribe: return windscribe.New(allServers.Windscribe.Servers, randSource) default: panic("provider " + provider + " is unknown") // should never occur diff --git a/internal/provider/purevpn/provider.go b/internal/provider/purevpn/provider.go index 5ffcdf44..6fd977cf 100644 --- a/internal/provider/purevpn/provider.go +++ b/internal/provider/purevpn/provider.go @@ -3,7 +3,7 @@ package purevpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.PurevpnServer, randSource rand.Source) *Purevpn { return &Purevpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Purevpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Purevpn), } } diff --git a/internal/provider/surfshark/filter_test.go b/internal/provider/surfshark/filter_test.go index 4b25a817..5ad3e796 100644 --- a/internal/provider/surfshark/filter_test.go +++ b/internal/provider/surfshark/filter_test.go @@ -6,7 +6,7 @@ import ( "testing" "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +24,7 @@ func Test_Surfshark_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -33,7 +33,7 @@ func Test_Surfshark_filterServers(t *testing.T) { {Hostname: "b", UDP: true}, {Hostname: "c", UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Surfshark), + selection: settings.ServerSelection{}.WithDefaults(providers.Surfshark), filtered: []models.SurfsharkServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, @@ -43,7 +43,7 @@ func Test_Surfshark_filterServers(t *testing.T) { "filter by region": { selection: settings.ServerSelection{ Regions: []string{"b"}, - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {Region: "a", UDP: true}, {Region: "b", UDP: true}, @@ -56,7 +56,7 @@ func Test_Surfshark_filterServers(t *testing.T) { "filter by country": { selection: settings.ServerSelection{ Countries: []string{"b"}, - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {Country: "a", UDP: true}, {Country: "b", UDP: true}, @@ -69,7 +69,7 @@ func Test_Surfshark_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {City: "a", UDP: true}, {City: "b", UDP: true}, @@ -82,7 +82,7 @@ func Test_Surfshark_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, @@ -97,7 +97,7 @@ func Test_Surfshark_filterServers(t *testing.T) { OpenVPN: settings.OpenVPNSelection{ TCP: boolPtr(true), }, - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true, TCP: true}, @@ -110,7 +110,7 @@ func Test_Surfshark_filterServers(t *testing.T) { "filter by multihop only": { selection: settings.ServerSelection{ MultiHopOnly: boolPtr(true), - }.WithDefaults(constants.Surfshark), + }.WithDefaults(providers.Surfshark), servers: []models.SurfsharkServer{ {Hostname: "a", UDP: true}, {Hostname: "b", MultiHop: true, UDP: true}, diff --git a/internal/provider/surfshark/provider.go b/internal/provider/surfshark/provider.go index ca15ec88..2b867a9a 100644 --- a/internal/provider/surfshark/provider.go +++ b/internal/provider/surfshark/provider.go @@ -3,7 +3,7 @@ package surfshark import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.SurfsharkServer, randSource rand.Source) *Surfshark { return &Surfshark{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Surfshark), + NoPortForwarder: utils.NewNoPortForwarding(providers.Surfshark), } } diff --git a/internal/provider/torguard/provider.go b/internal/provider/torguard/provider.go index 6247b3e2..99bf0dbb 100644 --- a/internal/provider/torguard/provider.go +++ b/internal/provider/torguard/provider.go @@ -3,7 +3,7 @@ package torguard import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.TorguardServer, randSource rand.Source) *Torguard { return &Torguard{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Torguard), + NoPortForwarder: utils.NewNoPortForwarding(providers.Torguard), } } diff --git a/internal/provider/vpnunlimited/provider.go b/internal/provider/vpnunlimited/provider.go index f18a41be..635e80b1 100644 --- a/internal/provider/vpnunlimited/provider.go +++ b/internal/provider/vpnunlimited/provider.go @@ -3,7 +3,7 @@ package vpnunlimited import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.VPNUnlimitedServer, randSource rand.Source) *Provider return &Provider{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.VPNUnlimited), + NoPortForwarder: utils.NewNoPortForwarding(providers.VPNUnlimited), } } diff --git a/internal/provider/vyprvpn/provider.go b/internal/provider/vyprvpn/provider.go index 528aec00..c6f3c3d6 100644 --- a/internal/provider/vyprvpn/provider.go +++ b/internal/provider/vyprvpn/provider.go @@ -3,7 +3,7 @@ package vyprvpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.VyprvpnServer, randSource rand.Source) *Vyprvpn { return &Vyprvpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Vyprvpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Vyprvpn), } } diff --git a/internal/provider/wevpn/connection_test.go b/internal/provider/wevpn/connection_test.go index c671e166..9a28c1db 100644 --- a/internal/provider/wevpn/connection_test.go +++ b/internal/provider/wevpn/connection_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,7 +26,7 @@ func Test_Wevpn_GetConnection(t *testing.T) { "no server available": { selection: settings.ServerSelection{ VPN: constants.OpenVPN, - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), err: errors.New("no server found: for VPN openvpn; protocol udp"), }, "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(3, 3, 3, 3)}}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn), connection: models.Connection{ Type: constants.OpenVPN, IP: net.IPv4(1, 1, 1, 1), @@ -45,7 +46,7 @@ func Test_Wevpn_GetConnection(t *testing.T) { "target IP": { selection: settings.ServerSelection{ TargetIP: net.IPv4(2, 2, 2, 2), - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), servers: []models.WevpnServer{ {UDP: true, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {UDP: true, IPs: []net.IP{net.IPv4(2, 2, 2, 2)}}, @@ -61,7 +62,7 @@ func Test_Wevpn_GetConnection(t *testing.T) { "with filter": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), servers: []models.WevpnServer{ {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)}}, diff --git a/internal/provider/wevpn/filter_test.go b/internal/provider/wevpn/filter_test.go index c486a36b..7af28388 100644 --- a/internal/provider/wevpn/filter_test.go +++ b/internal/provider/wevpn/filter_test.go @@ -6,7 +6,7 @@ import ( "testing" "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +24,7 @@ func Test_Wevpn_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -33,7 +33,7 @@ func Test_Wevpn_filterServers(t *testing.T) { {Hostname: "b", UDP: true}, {Hostname: "c", UDP: true}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Wevpn), + selection: settings.ServerSelection{}.WithDefaults(providers.Wevpn), filtered: []models.WevpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, @@ -43,7 +43,7 @@ func Test_Wevpn_filterServers(t *testing.T) { "filter by protocol": { selection: settings.ServerSelection{ OpenVPN: settings.OpenVPNSelection{TCP: boolPtr(true)}, - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), servers: []models.WevpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", TCP: true}, @@ -56,7 +56,7 @@ func Test_Wevpn_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), servers: []models.WevpnServer{ {City: "a", UDP: true}, {City: "b", UDP: true}, @@ -69,7 +69,7 @@ func Test_Wevpn_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Wevpn), + }.WithDefaults(providers.Wevpn), servers: []models.WevpnServer{ {Hostname: "a", UDP: true}, {Hostname: "b", UDP: true}, diff --git a/internal/provider/wevpn/provider.go b/internal/provider/wevpn/provider.go index 64c97c87..eb010ad0 100644 --- a/internal/provider/wevpn/provider.go +++ b/internal/provider/wevpn/provider.go @@ -3,7 +3,7 @@ package wevpn import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.WevpnServer, randSource rand.Source) *Wevpn { return &Wevpn{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Wevpn), + NoPortForwarder: utils.NewNoPortForwarding(providers.Wevpn), } } diff --git a/internal/provider/windscribe/connection_test.go b/internal/provider/windscribe/connection_test.go index b738692f..ff1d344f 100644 --- a/internal/provider/windscribe/connection_test.go +++ b/internal/provider/windscribe/connection_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +24,7 @@ func Test_Windscribe_GetConnection(t *testing.T) { err error }{ "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"), }, "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(3, 3, 3, 3)}}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), + selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe), connection: models.Connection{ Type: constants.OpenVPN, IP: net.IPv4(1, 1, 1, 1), @@ -43,7 +44,7 @@ func Test_Windscribe_GetConnection(t *testing.T) { "target IP": { selection: settings.ServerSelection{ TargetIP: net.IPv4(2, 2, 2, 2), - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {VPN: constants.OpenVPN, IPs: []net.IP{net.IPv4(1, 1, 1, 1)}}, {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": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {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)}}, diff --git a/internal/provider/windscribe/filter_test.go b/internal/provider/windscribe/filter_test.go index 87f98687..9983091d 100644 --- a/internal/provider/windscribe/filter_test.go +++ b/internal/provider/windscribe/filter_test.go @@ -7,6 +7,7 @@ import ( "github.com/qdm12/gluetun/internal/configuration/settings" "github.com/qdm12/gluetun/internal/constants" + "github.com/qdm12/gluetun/internal/constants/providers" "github.com/qdm12/gluetun/internal/models" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -22,7 +23,7 @@ func Test_Windscribe_filterServers(t *testing.T) { err error }{ "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"), }, "no filter": { @@ -31,7 +32,7 @@ func Test_Windscribe_filterServers(t *testing.T) { {VPN: constants.OpenVPN, Hostname: "b"}, {VPN: constants.OpenVPN, Hostname: "c"}, }, - selection: settings.ServerSelection{}.WithDefaults(constants.Windscribe), + selection: settings.ServerSelection{}.WithDefaults(providers.Windscribe), filtered: []models.WindscribeServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "b"}, @@ -41,7 +42,7 @@ func Test_Windscribe_filterServers(t *testing.T) { "filter OpenVPN out": { selection: settings.ServerSelection{ VPN: constants.Wireguard, - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.Wireguard, Hostname: "b"}, @@ -54,7 +55,7 @@ func Test_Windscribe_filterServers(t *testing.T) { "filter by region": { selection: settings.ServerSelection{ Regions: []string{"b"}, - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {VPN: constants.OpenVPN, Region: "a"}, {VPN: constants.OpenVPN, Region: "b"}, @@ -67,7 +68,7 @@ func Test_Windscribe_filterServers(t *testing.T) { "filter by city": { selection: settings.ServerSelection{ Cities: []string{"b"}, - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {VPN: constants.OpenVPN, City: "a"}, {VPN: constants.OpenVPN, City: "b"}, @@ -80,7 +81,7 @@ func Test_Windscribe_filterServers(t *testing.T) { "filter by hostname": { selection: settings.ServerSelection{ Hostnames: []string{"b"}, - }.WithDefaults(constants.Windscribe), + }.WithDefaults(providers.Windscribe), servers: []models.WindscribeServer{ {VPN: constants.OpenVPN, Hostname: "a"}, {VPN: constants.OpenVPN, Hostname: "b"}, diff --git a/internal/provider/windscribe/provider.go b/internal/provider/windscribe/provider.go index bf5219cd..21d9d354 100644 --- a/internal/provider/windscribe/provider.go +++ b/internal/provider/windscribe/provider.go @@ -3,7 +3,7 @@ package windscribe import ( "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/provider/utils" ) @@ -18,6 +18,6 @@ func New(servers []models.WindscribeServer, randSource rand.Source) *Windscribe return &Windscribe{ servers: servers, randSource: randSource, - NoPortForwarder: utils.NewNoPortForwarding(constants.Windscribe), + NoPortForwarder: utils.NewNoPortForwarding(providers.Windscribe), } } diff --git a/internal/updater/providers.go b/internal/updater/providers.go index 54dfe216..dc050482 100644 --- a/internal/updater/providers.go +++ b/internal/updater/providers.go @@ -5,7 +5,7 @@ import ( "fmt" "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/expressvpn" "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) if *u.options.CLI { for _, warning := range warnings { - u.logger.Warn(constants.Perfectprivacy + ": " + warning) + u.logger.Warn(providers.Perfectprivacy + ": " + warning) } } if err != nil { @@ -365,7 +365,7 @@ func (u *updater) updateVPNUnlimited(ctx context.Context) (err error) { ctx, u.unzipper, u.presolver, minServers) if *u.options.CLI { for _, warning := range warnings { - u.logger.Warn(constants.VPNUnlimited + ": " + warning) + u.logger.Warn(providers.VPNUnlimited + ": " + warning) } } if err != nil { diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 488de584..30706492 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -8,7 +8,7 @@ import ( "time" "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/updater/resolver" "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) { switch provider { - case constants.Custom: + case providers.Custom: panic("cannot update custom provider") - case constants.Cyberghost: + case providers.Cyberghost: 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) } - case constants.Fastestvpn: + case providers.Fastestvpn: 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) } - case constants.Ipvanish: + case providers.Ipvanish: 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) } - case constants.Mullvad: + case providers.Mullvad: 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) } - case constants.Perfectprivacy: + case providers.Perfectprivacy: 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) } - case constants.PrivateInternetAccess: + case providers.PrivateInternetAccess: 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) } - case constants.Protonvpn: + case providers.Protonvpn: 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) } - case constants.Surfshark: + case providers.Surfshark: 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) } - case constants.VPNUnlimited: + case providers.VPNUnlimited: 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) } - case constants.Wevpn: + case providers.Wevpn: 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) } default: panic("provider " + provider + " is unknown")