Applied JeordyR's changes

This commit is contained in:
Quentin McGaw (desktop)
2020-02-22 17:55:49 +00:00
parent 5ee4e2fde0
commit 3ad60349db
3 changed files with 4 additions and 1 deletions

View File

@@ -126,6 +126,7 @@ docker run --rm --network=container:pia alpine:3.11 wget -qO- https://ipinfo.io
| Environment variable | Default | Description | | Environment variable | Default | Description |
| --- | --- | --- | | --- | --- | --- |
| `VPNSP` | `pia` | VPN Service Provider, one of `pia`, `mullvad` |
| `REGION` | `CA Montreal` | (PIA only) one of the [PIA regions](https://www.privateinternetaccess.com/pages/network/) | | `REGION` | `CA Montreal` | (PIA only) one of the [PIA regions](https://www.privateinternetaccess.com/pages/network/) |
| `COUNTRY` | `Sweden` | (Mullvad only) one of the [Mullvad countries](https://mullvad.net/en/servers/#openvpn) | | `COUNTRY` | `Sweden` | (Mullvad only) one of the [Mullvad countries](https://mullvad.net/en/servers/#openvpn) |
| `CITY` | | (Mullvad only, *optional*) one of the [Mullvad cities](https://mullvad.net/en/servers/#openvpn) | | `CITY` | | (Mullvad only, *optional*) one of the [Mullvad cities](https://mullvad.net/en/servers/#openvpn) |

View File

@@ -11,7 +11,7 @@ import (
// GetMullvadCountry obtains the country for the Mullvad server from the // GetMullvadCountry obtains the country for the Mullvad server from the
// environment variable COUNTRY // environment variable COUNTRY
func (p *paramsReader) GetMullvadCountry() (country models.MullvadCountry, err error) { func (p *paramsReader) GetMullvadCountry() (country models.MullvadCountry, err error) {
choices := append(constants.MullvadCityChoices(), "") choices := append(constants.MullvadCountryChoices(), "")
s, err := p.envParams.GetValueIfInside("COUNTRY", choices) s, err := p.envParams.GetValueIfInside("COUNTRY", choices)
return models.MullvadCountry(strings.ToLower(s)), err return models.MullvadCountry(strings.ToLower(s)), err
} }

View File

@@ -35,6 +35,8 @@ func GetMullvadSettings(params params.ParamsReader) (settings Mullvad, err error
if err != nil { if err != nil {
return settings, err return settings, err
} }
// Remove spaces in user ID to simplify user's life, thanks @JeordyR
settings.User = strings.ReplaceAll(settings.User, " ", "")
settings.Country, err = params.GetMullvadCountry() settings.Country, err = params.GetMullvadCountry()
if err != nil { if err != nil {
return settings, err return settings, err