* OWNED environment variable for Mullvad * CSV are now accepted for all servers filtering environment variables
This commit is contained in:
@@ -14,12 +14,11 @@ func (p *reader) GetCyberghostGroup() (group string, err error) {
|
||||
return s, err
|
||||
}
|
||||
|
||||
// GetCyberghostRegion obtains the country name for the Cyberghost server from the
|
||||
// GetCyberghostRegions obtains the country names for the Cyberghost servers from the
|
||||
// environment variable REGION
|
||||
func (p *reader) GetCyberghostRegion() (region string, err error) {
|
||||
func (p *reader) GetCyberghostRegions() (regions []string, err error) {
|
||||
choices := append(constants.CyberghostRegionChoices(), "")
|
||||
s, err := p.envParams.GetValueIfInside("REGION", choices)
|
||||
return s, err
|
||||
return p.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetCyberghostClientKey obtains the one line client key to use for openvpn from the
|
||||
|
||||
@@ -5,25 +5,25 @@ import (
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetMullvadCountry obtains the country for the Mullvad server from the
|
||||
// GetMullvadCountries obtains the countries for the Mullvad servers from the
|
||||
// environment variable COUNTRY
|
||||
func (r *reader) GetMullvadCountry() (country string, err error) {
|
||||
func (r *reader) GetMullvadCountries() (countries []string, err error) {
|
||||
choices := append(constants.MullvadCountryChoices(), "")
|
||||
return r.envParams.GetValueIfInside("COUNTRY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
}
|
||||
|
||||
// GetMullvadCity obtains the city for the Mullvad server from the
|
||||
// GetMullvadCity obtains the cities for the Mullvad servers from the
|
||||
// environment variable CITY
|
||||
func (r *reader) GetMullvadCity() (country string, err error) {
|
||||
func (r *reader) GetMullvadCities() (cities []string, err error) {
|
||||
choices := append(constants.MullvadCityChoices(), "")
|
||||
return r.envParams.GetValueIfInside("CITY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
}
|
||||
|
||||
// GetMullvadISP obtains the ISP for the Mullvad server from the
|
||||
// GetMullvadISPs obtains the ISPs for the Mullvad servers from the
|
||||
// environment variable ISP
|
||||
func (r *reader) GetMullvadISP() (isp string, err error) {
|
||||
func (r *reader) GetMullvadISPs() (isps []string, err error) {
|
||||
choices := append(constants.MullvadISPChoices(), "")
|
||||
return r.envParams.GetValueIfInside("ISP", choices)
|
||||
return r.envParams.GetCSVInPossibilities("ISP", choices)
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
@@ -32,3 +32,9 @@ func (r *reader) GetMullvadPort() (port uint16, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
||||
return uint16(n), err
|
||||
}
|
||||
|
||||
// GetMullvadOwned obtains if the server should be owned by Mullvad or not from the
|
||||
// environment variable OWNED
|
||||
func (r *reader) GetMullvadOwned() (owned bool, err error) {
|
||||
return r.envParams.GetYesNo("OWNED", libparams.Default("no"))
|
||||
}
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetNordvpnRegion obtains the region (country) for the NordVPN server from the
|
||||
// GetNordvpnRegions obtains the regions (countries) for the NordVPN server from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetNordvpnRegion() (region string, err error) {
|
||||
func (r *reader) GetNordvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.NordvpnRegionChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetNordvpnRegion obtains the server number (optional) for the NordVPN server from the
|
||||
// GetNordvpnRegion obtains the server numbers (optional) for the NordVPN servers from the
|
||||
// environment variable SERVER_NUMBER
|
||||
func (r *reader) GetNordvpnNumber() (number uint16, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("SERVER_NUMBER", 0, 65535, libparams.Default("0"))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
func (r *reader) GetNordvpnNumbers() (numbers []uint16, err error) {
|
||||
possibilities := make([]string, 65536)
|
||||
for i := range possibilities {
|
||||
possibilities[i] = fmt.Sprintf("%d", i)
|
||||
}
|
||||
return uint16(n), nil
|
||||
values, err := r.envParams.GetCSVInPossibilities("SERVER_NUMBER", possibilities)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
numbers = make([]uint16, len(values))
|
||||
for i := range values {
|
||||
n, err := strconv.Atoi(values[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
numbers[i] = uint16(n)
|
||||
}
|
||||
return numbers, nil
|
||||
}
|
||||
|
||||
@@ -61,38 +61,39 @@ type Reader interface {
|
||||
GetPortForwarding() (activated bool, err error)
|
||||
GetPortForwardingStatusFilepath() (filepath models.Filepath, err error)
|
||||
GetPIAEncryptionPreset() (preset string, err error)
|
||||
GetPIARegion() (region string, err error)
|
||||
GetPIAOldRegion() (region string, err error)
|
||||
GetPIARegions() (regions []string, err error)
|
||||
GetPIAOldRegions() (regions []string, err error)
|
||||
|
||||
// Mullvad getters
|
||||
GetMullvadCountry() (country string, err error)
|
||||
GetMullvadCity() (country string, err error)
|
||||
GetMullvadISP() (country string, err error)
|
||||
GetMullvadCountries() (countries []string, err error)
|
||||
GetMullvadCities() (cities []string, err error)
|
||||
GetMullvadISPs() (ips []string, err error)
|
||||
GetMullvadPort() (port uint16, err error)
|
||||
GetMullvadOwned() (owned bool, err error)
|
||||
|
||||
// Windscribe getters
|
||||
GetWindscribeRegion() (country string, err error)
|
||||
GetWindscribeRegions() (countries []string, err error)
|
||||
GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error)
|
||||
|
||||
// Surfshark getters
|
||||
GetSurfsharkRegion() (country string, err error)
|
||||
GetSurfsharkRegions() (countries []string, err error)
|
||||
|
||||
// Cyberghost getters
|
||||
GetCyberghostGroup() (group string, err error)
|
||||
GetCyberghostRegion() (region string, err error)
|
||||
GetCyberghostRegions() (regions []string, err error)
|
||||
GetCyberghostClientKey() (clientKey string, err error)
|
||||
|
||||
// Vyprvpn getters
|
||||
GetVyprvpnRegion() (region string, err error)
|
||||
GetVyprvpnRegions() (regions []string, err error)
|
||||
|
||||
// NordVPN getters
|
||||
GetNordvpnRegion() (region string, err error)
|
||||
GetNordvpnNumber() (number uint16, err error)
|
||||
GetNordvpnRegions() (regions []string, err error)
|
||||
GetNordvpnNumbers() (numbers []uint16, err error)
|
||||
|
||||
// PureVPN getters
|
||||
GetPurevpnRegion() (region string, err error)
|
||||
GetPurevpnCountry() (country string, err error)
|
||||
GetPurevpnCity() (city string, err error)
|
||||
GetPurevpnRegions() (regions []string, err error)
|
||||
GetPurevpnCountries() (countries []string, err error)
|
||||
GetPurevpnCities() (cities []string, err error)
|
||||
|
||||
// Shadowsocks getters
|
||||
GetShadowSocks() (activated bool, err error)
|
||||
|
||||
@@ -56,16 +56,16 @@ func (r *reader) GetPIAEncryptionPreset() (preset string, err error) {
|
||||
libparams.Default(constants.PIAEncryptionPresetStrong))
|
||||
}
|
||||
|
||||
// GetPIARegion obtains the region for the PIA server from the
|
||||
// GetPIARegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetPIARegion() (region string, err error) {
|
||||
func (r *reader) GetPIARegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAGeoChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetPIAOldRegion obtains the region for the PIA server from the
|
||||
// GetPIAOldRegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetPIAOldRegion() (region string, err error) {
|
||||
func (r *reader) GetPIAOldRegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAOldGeoChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
)
|
||||
|
||||
// GetPurevpnRegion obtains the region (continent) for the PureVPN server from the
|
||||
// GetPurevpnRegions obtains the regions (continents) for the PureVPN servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetPurevpnRegion() (region string, err error) {
|
||||
func (r *reader) GetPurevpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.PurevpnRegionChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetPurevpnCountry obtains the country for the PureVPN server from the
|
||||
// GetPurevpnCountries obtains the countries for the PureVPN servers from the
|
||||
// environment variable COUNTRY
|
||||
func (r *reader) GetPurevpnCountry() (country string, err error) {
|
||||
func (r *reader) GetPurevpnCountries() (countries []string, err error) {
|
||||
choices := append(constants.PurevpnCountryChoices(), "")
|
||||
return r.envParams.GetValueIfInside("COUNTRY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
}
|
||||
|
||||
// GetPurevpnCity obtains the city for the PureVPN server from the
|
||||
// GetPurevpnCities obtains the cities for the PureVPN servers from the
|
||||
// environment variable CITY
|
||||
func (r *reader) GetPurevpnCity() (city string, err error) {
|
||||
func (r *reader) GetPurevpnCities() (cities []string, err error) {
|
||||
choices := append(constants.PurevpnCityChoices(), "")
|
||||
return r.envParams.GetValueIfInside("CITY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
)
|
||||
|
||||
// GetSurfsharkRegion obtains the region for the Surfshark server from the
|
||||
// GetSurfsharkRegions obtains the regions for the Surfshark servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetSurfsharkRegion() (region string, err error) {
|
||||
func (r *reader) GetSurfsharkRegions() (regions []string, err error) {
|
||||
choices := append(constants.SurfsharkRegionChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
)
|
||||
|
||||
// GetVyprvpnRegion obtains the region for the Vyprvpn server from the
|
||||
// GetVyprvpnRegions obtains the regions for the Vyprvpn servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetVyprvpnRegion() (region string, err error) {
|
||||
func (r *reader) GetVyprvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.VyprvpnRegionChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetWindscribeRegion obtains the region for the Windscribe server from the
|
||||
// GetWindscribeRegions obtains the regions for the Windscribe servers from the
|
||||
// environment variable REGION
|
||||
func (r *reader) GetWindscribeRegion() (region string, err error) {
|
||||
func (r *reader) GetWindscribeRegions() (regions []string, err error) {
|
||||
choices := append(constants.WindscribeRegionChoices(), "")
|
||||
return r.envParams.GetValueIfInside("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
|
||||
Reference in New Issue
Block a user