2020-02-16 20:30:29 +00:00
|
|
|
package params
|
|
|
|
|
|
|
|
|
|
import (
|
2020-07-26 12:07:06 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
2020-02-16 20:30:29 +00:00
|
|
|
libparams "github.com/qdm12/golibs/params"
|
|
|
|
|
)
|
|
|
|
|
|
2020-10-18 17:15:42 -04:00
|
|
|
// GetMullvadCountries obtains the countries for the Mullvad servers from the
|
2020-02-16 20:30:29 +00:00
|
|
|
// environment variable COUNTRY
|
2020-10-18 17:15:42 -04:00
|
|
|
func (r *reader) GetMullvadCountries() (countries []string, err error) {
|
2020-02-22 17:55:49 +00:00
|
|
|
choices := append(constants.MullvadCountryChoices(), "")
|
2020-10-18 17:15:42 -04:00
|
|
|
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
2020-02-16 20:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-18 17:15:42 -04:00
|
|
|
// GetMullvadCity obtains the cities for the Mullvad servers from the
|
2020-02-16 20:30:29 +00:00
|
|
|
// environment variable CITY
|
2020-10-18 17:15:42 -04:00
|
|
|
func (r *reader) GetMullvadCities() (cities []string, err error) {
|
2020-02-16 20:30:29 +00:00
|
|
|
choices := append(constants.MullvadCityChoices(), "")
|
2020-10-18 17:15:42 -04:00
|
|
|
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
2020-02-16 20:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-18 17:15:42 -04:00
|
|
|
// GetMullvadISPs obtains the ISPs for the Mullvad servers from the
|
2020-02-16 20:30:29 +00:00
|
|
|
// environment variable ISP
|
2020-10-18 17:15:42 -04:00
|
|
|
func (r *reader) GetMullvadISPs() (isps []string, err error) {
|
2020-06-13 14:08:29 -04:00
|
|
|
choices := append(constants.MullvadISPChoices(), "")
|
2020-10-18 17:15:42 -04:00
|
|
|
return r.envParams.GetCSVInPossibilities("ISP", choices)
|
2020-02-16 20:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
|
|
|
|
// environment variable PORT
|
2020-06-12 17:07:32 +00:00
|
|
|
func (r *reader) GetMullvadPort() (port uint16, err error) {
|
|
|
|
|
n, err := r.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
2020-02-16 20:30:29 +00:00
|
|
|
return uint16(n), err
|
|
|
|
|
}
|
2020-10-18 17:15:42 -04:00
|
|
|
|
|
|
|
|
// 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"))
|
|
|
|
|
}
|