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"
"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
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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, ", "))

View File

@@ -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()
}

View File

@@ -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)

View File

@@ -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}
}
}

View File

@@ -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

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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 {

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"
)
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"

View File

@@ -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,

View File

@@ -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),
}
}

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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},

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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},

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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)}},

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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

View File

@@ -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),
}
}

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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),
}
}

View File

@@ -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)}},

View File

@@ -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},

View File

@@ -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),
}
}

View File

@@ -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)}},

View File

@@ -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"},

View File

@@ -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),
}
}

View File

@@ -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 {

View File

@@ -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")