* OWNED environment variable for Mullvad * CSV are now accepted for all servers filtering environment variables
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user