Allow empty string for CSV variables with golibs
This commit is contained in:
2
go.mod
2
go.mod
@@ -6,7 +6,7 @@ require (
|
||||
github.com/fatih/color v1.9.0
|
||||
github.com/golang/mock v1.4.4
|
||||
github.com/kyokomi/emoji v2.2.4+incompatible
|
||||
github.com/qdm12/golibs v0.0.0-20201018204514-1d5986880422
|
||||
github.com/qdm12/golibs v0.0.0-20201024185935-092412448c2c
|
||||
github.com/qdm12/ss-server v0.0.0-20200819124651-6428e626ee83
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/vishvananda/netlink v1.1.0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -72,8 +72,8 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/qdm12/golibs v0.0.0-20201018204514-1d5986880422 h1:sk+ri/MsgwBqpN3MqOazV8itCid7F2wGS8PbG1kWg9o=
|
||||
github.com/qdm12/golibs v0.0.0-20201018204514-1d5986880422/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
|
||||
github.com/qdm12/golibs v0.0.0-20201024185935-092412448c2c h1:9EQyDXbeapnPeMeO8Yq7PE6zqYPGkHp/qijNBBTU74c=
|
||||
github.com/qdm12/golibs v0.0.0-20201024185935-092412448c2c/go.mod h1:pikkTN7g7zRuuAnERwqW1yAFq6pYmxrxpjiwGvb0Ysc=
|
||||
github.com/qdm12/ss-server v0.0.0-20200819124651-6428e626ee83 h1:b7sNsgsKxH0mbl9L1hdUp5KSDkZ/1kOQ+iHiBVgFElM=
|
||||
github.com/qdm12/ss-server v0.0.0-20200819124651-6428e626ee83/go.mod h1:ABVUkxubboL3vqBkOwDV9glX1/x7SnYrckBe5d+M/zw=
|
||||
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg=
|
||||
|
||||
@@ -18,8 +18,7 @@ func (p *reader) GetCyberghostGroup() (group string, err error) {
|
||||
// GetCyberghostRegions obtains the country names for the Cyberghost servers from the
|
||||
// environment variable REGION.
|
||||
func (p *reader) GetCyberghostRegions() (regions []string, err error) {
|
||||
choices := append(constants.CyberghostRegionChoices(), "")
|
||||
return p.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return p.envParams.GetCSVInPossibilities("REGION", constants.CyberghostRegionChoices())
|
||||
}
|
||||
|
||||
// GetCyberghostClientKey obtains the one line client key to use for openvpn from the
|
||||
|
||||
@@ -8,22 +8,19 @@ import (
|
||||
// GetMullvadCountries obtains the countries for the Mullvad servers from the
|
||||
// environment variable COUNTRY.
|
||||
func (r *reader) GetMullvadCountries() (countries []string, err error) {
|
||||
choices := append(constants.MullvadCountryChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", constants.MullvadCountryChoices())
|
||||
}
|
||||
|
||||
// GetMullvadCity obtains the cities for the Mullvad servers from the
|
||||
// environment variable CITY.
|
||||
func (r *reader) GetMullvadCities() (cities []string, err error) {
|
||||
choices := append(constants.MullvadCityChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("CITY", constants.MullvadCityChoices())
|
||||
}
|
||||
|
||||
// GetMullvadISPs obtains the ISPs for the Mullvad servers from the
|
||||
// environment variable ISP.
|
||||
func (r *reader) GetMullvadISPs() (isps []string, err error) {
|
||||
choices := append(constants.MullvadISPChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("ISP", choices)
|
||||
return r.envParams.GetCSVInPossibilities("ISP", constants.MullvadISPChoices())
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
|
||||
@@ -10,8 +10,7 @@ import (
|
||||
// GetNordvpnRegions obtains the regions (countries) for the NordVPN server from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetNordvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.NordvpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.NordvpnRegionChoices())
|
||||
}
|
||||
|
||||
// GetNordvpnRegion obtains the server numbers (optional) for the NordVPN servers from the
|
||||
|
||||
@@ -149,7 +149,7 @@ func (r *reader) GetVPNSP() (vpnServiceProvider models.VPNProvider, err error) {
|
||||
"pia", "private internet access", "private internet access old",
|
||||
"mullvad", "windscribe", "surfshark", "cyberghost",
|
||||
"vyprvpn", "nordvpn", "purevpn",
|
||||
})
|
||||
}, libparams.Default("private internet access"))
|
||||
if s == "pia" {
|
||||
s = "private internet access"
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ func (r *reader) GetPIAEncryptionPreset() (preset string, err error) {
|
||||
// Retro-compatibility
|
||||
s, err := r.envParams.GetValueIfInside("ENCRYPTION", []string{
|
||||
constants.PIAEncryptionPresetNormal,
|
||||
constants.PIAEncryptionPresetStrong,
|
||||
""})
|
||||
constants.PIAEncryptionPresetStrong})
|
||||
if err != nil {
|
||||
return "", err
|
||||
} else if len(s) != 0 {
|
||||
@@ -62,13 +61,11 @@ func (r *reader) GetPIAEncryptionPreset() (preset string, err error) {
|
||||
// GetPIARegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPIARegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAGeoChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.PIAGeoChoices())
|
||||
}
|
||||
|
||||
// GetPIAOldRegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPIAOldRegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAOldGeoChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.PIAOldGeoChoices())
|
||||
}
|
||||
|
||||
@@ -7,20 +7,17 @@ import (
|
||||
// GetPurevpnRegions obtains the regions (continents) for the PureVPN servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPurevpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.PurevpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.PurevpnRegionChoices())
|
||||
}
|
||||
|
||||
// GetPurevpnCountries obtains the countries for the PureVPN servers from the
|
||||
// environment variable COUNTRY.
|
||||
func (r *reader) GetPurevpnCountries() (countries []string, err error) {
|
||||
choices := append(constants.PurevpnCountryChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", constants.PurevpnCountryChoices())
|
||||
}
|
||||
|
||||
// GetPurevpnCities obtains the cities for the PureVPN servers from the
|
||||
// environment variable CITY.
|
||||
func (r *reader) GetPurevpnCities() (cities []string, err error) {
|
||||
choices := append(constants.PurevpnCityChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
return r.envParams.GetCSVInPossibilities("CITY", constants.PurevpnCityChoices())
|
||||
}
|
||||
|
||||
@@ -7,6 +7,5 @@ import (
|
||||
// GetSurfsharkRegions obtains the regions for the Surfshark servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetSurfsharkRegions() (regions []string, err error) {
|
||||
choices := append(constants.SurfsharkRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.SurfsharkRegionChoices())
|
||||
}
|
||||
|
||||
@@ -7,6 +7,5 @@ import (
|
||||
// GetVyprvpnRegions obtains the regions for the Vyprvpn servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetVyprvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.VyprvpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.VyprvpnRegionChoices())
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ import (
|
||||
// GetWindscribeRegions obtains the regions for the Windscribe servers from the
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetWindscribeRegions() (regions []string, err error) {
|
||||
choices := append(constants.WindscribeRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
return r.envParams.GetCSVInPossibilities("REGION", constants.WindscribeRegionChoices())
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
|
||||
Reference in New Issue
Block a user