Add linters and fix lint issues
This commit is contained in:
@@ -8,21 +8,22 @@ import (
|
||||
)
|
||||
|
||||
// GetCyberghostGroup obtains the server group for the Cyberghost server from the
|
||||
// environment variable CYBERGHOST_GROUP
|
||||
// environment variable CYBERGHOST_GROUP.
|
||||
func (p *reader) GetCyberghostGroup() (group string, err error) {
|
||||
s, err := p.envParams.GetValueIfInside("CYBERGHOST_GROUP", constants.CyberghostGroupChoices(), libparams.Default("Premium UDP Europe"))
|
||||
s, err := p.envParams.GetValueIfInside("CYBERGHOST_GROUP",
|
||||
constants.CyberghostGroupChoices(), libparams.Default("Premium UDP Europe"))
|
||||
return s, err
|
||||
}
|
||||
|
||||
// GetCyberghostRegions obtains the country names for the Cyberghost servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (p *reader) GetCyberghostRegions() (regions []string, err error) {
|
||||
choices := append(constants.CyberghostRegionChoices(), "")
|
||||
return p.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetCyberghostClientKey obtains the one line client key to use for openvpn from the
|
||||
// environment variable CLIENT_KEY
|
||||
// environment variable CLIENT_KEY.
|
||||
func (p *reader) GetCyberghostClientKey() (clientKey string, err error) {
|
||||
clientKey, err = p.envParams.GetEnv("CLIENT_KEY", libparams.CaseSensitiveValue())
|
||||
if err != nil {
|
||||
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
// GetDNSOverTLS obtains if the DNS over TLS should be enabled
|
||||
// from the environment variable DOT
|
||||
// from the environment variable DOT.
|
||||
func (r *reader) GetDNSOverTLS() (DNSOverTLS bool, err error) { //nolint:gocritic
|
||||
return r.envParams.GetOnOff("DOT", libparams.Default("on"))
|
||||
}
|
||||
|
||||
// GetDNSOverTLSProviders obtains the DNS over TLS providers to use
|
||||
// from the environment variable DOT_PROVIDERS
|
||||
// from the environment variable DOT_PROVIDERS.
|
||||
func (r *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err error) {
|
||||
s, err := r.envParams.GetEnv("DOT_PROVIDERS", libparams.Default("cloudflare"))
|
||||
if err != nil {
|
||||
@@ -27,7 +27,9 @@ func (r *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err e
|
||||
for _, word := range strings.Split(s, ",") {
|
||||
provider := models.DNSProvider(word)
|
||||
switch provider {
|
||||
case constants.Cloudflare, constants.Google, constants.Quad9, constants.Quadrant, constants.CleanBrowsing, constants.SecureDNS, constants.LibreDNS:
|
||||
case constants.Cloudflare, constants.Google, constants.Quad9,
|
||||
constants.Quadrant, constants.CleanBrowsing, constants.SecureDNS,
|
||||
constants.LibreDNS:
|
||||
providers = append(providers, provider)
|
||||
default:
|
||||
return nil, fmt.Errorf("DNS over TLS provider %q is not valid", provider)
|
||||
@@ -37,55 +39,55 @@ func (r *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err e
|
||||
}
|
||||
|
||||
// GetDNSOverTLSVerbosity obtains the verbosity level to use for Unbound
|
||||
// from the environment variable DOT_VERBOSITY
|
||||
// from the environment variable DOT_VERBOSITY.
|
||||
func (r *reader) GetDNSOverTLSVerbosity() (verbosityLevel uint8, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("DOT_VERBOSITY", 0, 5, libparams.Default("1"))
|
||||
return uint8(n), err
|
||||
}
|
||||
|
||||
// GetDNSOverTLSVerbosityDetails obtains the log level to use for Unbound
|
||||
// from the environment variable DOT_VERBOSITY_DETAILS
|
||||
// from the environment variable DOT_VERBOSITY_DETAILS.
|
||||
func (r *reader) GetDNSOverTLSVerbosityDetails() (verbosityDetailsLevel uint8, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("DOT_VERBOSITY_DETAILS", 0, 4, libparams.Default("0"))
|
||||
return uint8(n), err
|
||||
}
|
||||
|
||||
// GetDNSOverTLSValidationLogLevel obtains the log level to use for Unbound DOT validation
|
||||
// from the environment variable DOT_VALIDATION_LOGLEVEL
|
||||
// from the environment variable DOT_VALIDATION_LOGLEVEL.
|
||||
func (r *reader) GetDNSOverTLSValidationLogLevel() (validationLogLevel uint8, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("DOT_VALIDATION_LOGLEVEL", 0, 2, libparams.Default("0"))
|
||||
return uint8(n), err
|
||||
}
|
||||
|
||||
// GetDNSMaliciousBlocking obtains if malicious hostnames/IPs should be blocked
|
||||
// from being resolved by Unbound, using the environment variable BLOCK_MALICIOUS
|
||||
// from being resolved by Unbound, using the environment variable BLOCK_MALICIOUS.
|
||||
func (r *reader) GetDNSMaliciousBlocking() (blocking bool, err error) {
|
||||
return r.envParams.GetOnOff("BLOCK_MALICIOUS", libparams.Default("on"))
|
||||
}
|
||||
|
||||
// GetDNSSurveillanceBlocking obtains if surveillance hostnames/IPs should be blocked
|
||||
// from being resolved by Unbound, using the environment variable BLOCK_SURVEILLANCE
|
||||
// and BLOCK_NSA for retrocompatibility
|
||||
// and BLOCK_NSA for retrocompatibility.
|
||||
func (r *reader) GetDNSSurveillanceBlocking() (blocking bool, err error) {
|
||||
// Retro-compatibility
|
||||
s, err := r.envParams.GetEnv("BLOCK_NSA")
|
||||
if err != nil {
|
||||
return false, err
|
||||
} else if len(s) != 0 {
|
||||
r.logger.Warn("You are using the old environment variable BLOCK_NSA, please consider changing it to BLOCK_SURVEILLANCE")
|
||||
r.logger.Warn("You are using the old environment variable BLOCK_NSA, please consider changing it to BLOCK_SURVEILLANCE") //nolint:lll
|
||||
return r.envParams.GetOnOff("BLOCK_NSA", libparams.Compulsory())
|
||||
}
|
||||
return r.envParams.GetOnOff("BLOCK_SURVEILLANCE", libparams.Default("off"))
|
||||
}
|
||||
|
||||
// GetDNSAdsBlocking obtains if ads hostnames/IPs should be blocked
|
||||
// from being resolved by Unbound, using the environment variable BLOCK_ADS
|
||||
// from being resolved by Unbound, using the environment variable BLOCK_ADS.
|
||||
func (r *reader) GetDNSAdsBlocking() (blocking bool, err error) {
|
||||
return r.envParams.GetOnOff("BLOCK_ADS", libparams.Default("off"))
|
||||
}
|
||||
|
||||
// GetDNSUnblockedHostnames obtains a list of hostnames to unblock from block lists
|
||||
// from the comma separated list for the environment variable UNBLOCK
|
||||
// from the comma separated list for the environment variable UNBLOCK.
|
||||
func (r *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
||||
s, err := r.envParams.GetEnv("UNBLOCK")
|
||||
if err != nil {
|
||||
@@ -103,13 +105,13 @@ func (r *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
||||
}
|
||||
|
||||
// GetDNSOverTLSCaching obtains if Unbound caching should be enable or not
|
||||
// from the environment variable DOT_CACHING
|
||||
// from the environment variable DOT_CACHING.
|
||||
func (r *reader) GetDNSOverTLSCaching() (caching bool, err error) {
|
||||
return r.envParams.GetOnOff("DOT_CACHING")
|
||||
}
|
||||
|
||||
// GetDNSOverTLSPrivateAddresses obtains if Unbound caching should be enable or not
|
||||
// from the environment variable DOT_PRIVATE_ADDRESS
|
||||
// from the environment variable DOT_PRIVATE_ADDRESS.
|
||||
func (r *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err error) {
|
||||
s, err := r.envParams.GetEnv("DOT_PRIVATE_ADDRESS")
|
||||
if err != nil {
|
||||
@@ -129,13 +131,13 @@ func (r *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err
|
||||
}
|
||||
|
||||
// GetDNSOverTLSIPv6 obtains if Unbound should resolve ipv6 addresses using ipv6 DNS over TLS
|
||||
// servers from the environment variable DOT_IPV6
|
||||
// servers from the environment variable DOT_IPV6.
|
||||
func (r *reader) GetDNSOverTLSIPv6() (ipv6 bool, err error) {
|
||||
return r.envParams.GetOnOff("DOT_IPV6", libparams.Default("off"))
|
||||
}
|
||||
|
||||
// GetDNSUpdatePeriod obtains the period to use to update the block lists and cryptographic files
|
||||
// and restart Unbound from the environment variable DNS_UPDATE_PERIOD
|
||||
// and restart Unbound from the environment variable DNS_UPDATE_PERIOD.
|
||||
func (r *reader) GetDNSUpdatePeriod() (period time.Duration, err error) {
|
||||
s, err := r.envParams.GetEnv("DNS_UPDATE_PERIOD", libparams.Default("24h"))
|
||||
if err != nil {
|
||||
@@ -145,7 +147,7 @@ func (r *reader) GetDNSUpdatePeriod() (period time.Duration, err error) {
|
||||
}
|
||||
|
||||
// GetDNSPlaintext obtains the plaintext DNS address to use if DNS over TLS is disabled
|
||||
// from the environment variable DNS_PLAINTEXT_ADDRESS
|
||||
// from the environment variable DNS_PLAINTEXT_ADDRESS.
|
||||
func (r *reader) GetDNSPlaintext() (ip net.IP, err error) {
|
||||
s, err := r.envParams.GetEnv("DNS_PLAINTEXT_ADDRESS", libparams.Default("1.1.1.1"))
|
||||
if err != nil {
|
||||
@@ -159,7 +161,7 @@ func (r *reader) GetDNSPlaintext() (ip net.IP, err error) {
|
||||
}
|
||||
|
||||
// GetDNSKeepNameserver obtains if the nameserver present in /etc/resolv.conf
|
||||
// should be kept instead of overridden, from the environment variable DNS_KEEP_NAMESERVER
|
||||
// should be kept instead of overridden, from the environment variable DNS_KEEP_NAMESERVER.
|
||||
func (r *reader) GetDNSKeepNameserver() (on bool, err error) {
|
||||
return r.envParams.GetOnOff("DNS_KEEP_NAMESERVER", libparams.Default("off"))
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetFirewall obtains if the firewall should be enabled from the environment variable FIREWALL
|
||||
// GetFirewall obtains if the firewall should be enabled from the environment variable FIREWALL.
|
||||
func (r *reader) GetFirewall() (enabled bool, err error) {
|
||||
return r.envParams.GetOnOff("FIREWALL", libparams.Default("on"))
|
||||
}
|
||||
|
||||
// GetExtraSubnets obtains the CIDR subnets from the comma separated list of the
|
||||
// environment variable EXTRA_SUBNETS
|
||||
// environment variable EXTRA_SUBNETS.
|
||||
func (r *reader) GetExtraSubnets() (extraSubnets []net.IPNet, err error) {
|
||||
s, err := r.envParams.GetEnv("EXTRA_SUBNETS")
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func (r *reader) GetExtraSubnets() (extraSubnets []net.IPNet, err error) {
|
||||
}
|
||||
|
||||
// GetAllowedVPNInputPorts obtains a list of input ports to allow from the
|
||||
// VPN server side in the firewall, from the environment variable FIREWALL_VPN_INPUT_PORTS
|
||||
// VPN server side in the firewall, from the environment variable FIREWALL_VPN_INPUT_PORTS.
|
||||
func (r *reader) GetVPNInputPorts() (ports []uint16, err error) {
|
||||
s, err := r.envParams.GetEnv("FIREWALL_VPN_INPUT_PORTS", libparams.Default(""))
|
||||
if err != nil {
|
||||
@@ -61,7 +61,7 @@ func (r *reader) GetVPNInputPorts() (ports []uint16, err error) {
|
||||
}
|
||||
|
||||
// GetInputPorts obtains a list of input ports to allow through the
|
||||
// default interface in the firewall, from the environment variable FIREWALL_INPUT_PORTS
|
||||
// default interface in the firewall, from the environment variable FIREWALL_INPUT_PORTS.
|
||||
func (r *reader) GetInputPorts() (ports []uint16, err error) {
|
||||
s, err := r.envParams.GetEnv("FIREWALL_INPUT_PORTS", libparams.Default(""))
|
||||
if err != nil {
|
||||
@@ -84,7 +84,8 @@ func (r *reader) GetInputPorts() (ports []uint16, err error) {
|
||||
return ports, nil
|
||||
}
|
||||
|
||||
// GetFirewallDebug obtains if the firewall should run in debug verbose mode from the environment variable FIREWALL_DEBUG
|
||||
// GetFirewallDebug obtains if the firewall should run in debug verbose mode
|
||||
// from the environment variable FIREWALL_DEBUG.
|
||||
func (r *reader) GetFirewallDebug() (debug bool, err error) {
|
||||
return r.envParams.GetOnOff("FIREWALL_DEBUG", libparams.Default("off"))
|
||||
}
|
||||
|
||||
@@ -6,35 +6,35 @@ import (
|
||||
)
|
||||
|
||||
// GetMullvadCountries obtains the countries for the Mullvad servers from the
|
||||
// environment variable COUNTRY
|
||||
// environment variable COUNTRY.
|
||||
func (r *reader) GetMullvadCountries() (countries []string, err error) {
|
||||
choices := append(constants.MullvadCountryChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
}
|
||||
|
||||
// GetMullvadCity obtains the cities for the Mullvad servers from the
|
||||
// environment variable CITY
|
||||
// environment variable CITY.
|
||||
func (r *reader) GetMullvadCities() (cities []string, err error) {
|
||||
choices := append(constants.MullvadCityChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
}
|
||||
|
||||
// GetMullvadISPs obtains the ISPs for the Mullvad servers from the
|
||||
// environment variable ISP
|
||||
// environment variable ISP.
|
||||
func (r *reader) GetMullvadISPs() (isps []string, err error) {
|
||||
choices := append(constants.MullvadISPChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("ISP", choices)
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
// environment variable PORT
|
||||
// environment variable PORT.
|
||||
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
|
||||
// environment variable OWNED.
|
||||
func (r *reader) GetMullvadOwned() (owned bool, err error) {
|
||||
return r.envParams.GetYesNo("OWNED", libparams.Default("no"))
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
)
|
||||
|
||||
// GetNordvpnRegions obtains the regions (countries) for the NordVPN server from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetNordvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.NordvpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetNordvpnRegion obtains the server numbers (optional) for the NordVPN servers from the
|
||||
// environment variable SERVER_NUMBER
|
||||
// environment variable SERVER_NUMBER.
|
||||
func (r *reader) GetNordvpnNumbers() (numbers []uint16, err error) {
|
||||
possibilities := make([]string, 65536)
|
||||
for i := range possibilities {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetUser obtains the user to use to connect to the VPN servers
|
||||
// GetUser obtains the user to use to connect to the VPN servers.
|
||||
func (r *reader) GetUser() (s string, err error) {
|
||||
defer func() {
|
||||
unsetenvErr := r.unsetEnv("USER")
|
||||
@@ -19,7 +19,7 @@ func (r *reader) GetUser() (s string, err error) {
|
||||
return r.envParams.GetEnv("USER", libparams.CaseSensitiveValue(), libparams.Compulsory())
|
||||
}
|
||||
|
||||
// GetPassword obtains the password to use to connect to the VPN servers
|
||||
// GetPassword obtains the password to use to connect to the VPN servers.
|
||||
func (r *reader) GetPassword(required bool) (s string, err error) {
|
||||
defer func() {
|
||||
unsetenvErr := r.unsetEnv("PASSWORD")
|
||||
@@ -35,26 +35,26 @@ func (r *reader) GetPassword(required bool) (s string, err error) {
|
||||
}
|
||||
|
||||
// GetNetworkProtocol obtains the network protocol to use to connect to the
|
||||
// VPN servers from the environment variable PROTOCOL
|
||||
// VPN servers from the environment variable PROTOCOL.
|
||||
func (r *reader) GetNetworkProtocol() (protocol models.NetworkProtocol, err error) {
|
||||
s, err := r.envParams.GetValueIfInside("PROTOCOL", []string{"tcp", "udp"}, libparams.Default("udp"))
|
||||
return models.NetworkProtocol(s), err
|
||||
}
|
||||
|
||||
// GetOpenVPNVerbosity obtains the verbosity level for verbosity between 0 and 6
|
||||
// from the environment variable OPENVPN_VERBOSITY
|
||||
// from the environment variable OPENVPN_VERBOSITY.
|
||||
func (r *reader) GetOpenVPNVerbosity() (verbosity int, err error) {
|
||||
return r.envParams.GetEnvIntRange("OPENVPN_VERBOSITY", 0, 6, libparams.Default("1"))
|
||||
}
|
||||
|
||||
// GetOpenVPNRoot obtains if openvpn should be run as root
|
||||
// from the environment variable OPENVPN_ROOT
|
||||
// from the environment variable OPENVPN_ROOT.
|
||||
func (r *reader) GetOpenVPNRoot() (root bool, err error) {
|
||||
return r.envParams.GetYesNo("OPENVPN_ROOT", libparams.Default("no"))
|
||||
}
|
||||
|
||||
// GetTargetIP obtains the IP address to override over the list of IP addresses filtered
|
||||
// from the environment variable OPENVPN_TARGET_IP
|
||||
// from the environment variable OPENVPN_TARGET_IP.
|
||||
func (r *reader) GetTargetIP() (ip net.IP, err error) {
|
||||
s, err := r.envParams.GetEnv("OPENVPN_TARGET_IP")
|
||||
if len(s) == 0 {
|
||||
@@ -70,19 +70,19 @@ func (r *reader) GetTargetIP() (ip net.IP, err error) {
|
||||
}
|
||||
|
||||
// GetOpenVPNCipher obtains a custom cipher to use with OpenVPN
|
||||
// from the environment variable OPENVPN_CIPHER
|
||||
// from the environment variable OPENVPN_CIPHER.
|
||||
func (r *reader) GetOpenVPNCipher() (cipher string, err error) {
|
||||
return r.envParams.GetEnv("OPENVPN_CIPHER")
|
||||
}
|
||||
|
||||
// GetOpenVPNAuth obtains a custom auth algorithm to use with OpenVPN
|
||||
// from the environment variable OPENVPN_AUTH
|
||||
// from the environment variable OPENVPN_AUTH.
|
||||
func (r *reader) GetOpenVPNAuth() (auth string, err error) {
|
||||
return r.envParams.GetEnv("OPENVPN_AUTH")
|
||||
}
|
||||
|
||||
// GetOpenVPNIPv6 obtains if ipv6 should be tunneled through the
|
||||
// openvpn tunnel from the environment variable OPENVPN_IPV6
|
||||
// openvpn tunnel from the environment variable OPENVPN_IPV6.
|
||||
func (r *reader) GetOpenVPNIPv6() (ipv6 bool, err error) {
|
||||
return r.envParams.GetOnOff("OPENVPN_IPV6", libparams.Default("off"))
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/qdm12/golibs/verification"
|
||||
)
|
||||
|
||||
// Reader contains methods to obtain parameters
|
||||
// Reader contains methods to obtain parameters.
|
||||
type Reader interface {
|
||||
GetVPNSP() (vpnServiceProvider models.VPNProvider, err error)
|
||||
|
||||
@@ -130,7 +130,7 @@ type reader struct {
|
||||
}
|
||||
|
||||
// Newreader returns a paramsReadeer object to read parameters from
|
||||
// environment variables
|
||||
// environment variables.
|
||||
func NewReader(logger logging.Logger, fileManager files.FileManager) Reader {
|
||||
return &reader{
|
||||
envParams: libparams.NewEnvParams(),
|
||||
@@ -141,9 +141,15 @@ func NewReader(logger logging.Logger, fileManager files.FileManager) Reader {
|
||||
}
|
||||
}
|
||||
|
||||
// GetVPNSP obtains the VPN service provider to use from the environment variable VPNSP
|
||||
// GetVPNSP obtains the VPN service provider to use from the environment variable VPNSP.
|
||||
func (r *reader) GetVPNSP() (vpnServiceProvider models.VPNProvider, err error) {
|
||||
s, err := r.envParams.GetValueIfInside("VPNSP", []string{"pia", "private internet access", "private internet access old", "mullvad", "windscribe", "surfshark", "cyberghost", "vyprvpn", "nordvpn", "purevpn"})
|
||||
s, err := r.envParams.GetValueIfInside(
|
||||
"VPNSP",
|
||||
[]string{
|
||||
"pia", "private internet access", "private internet access old",
|
||||
"mullvad", "windscribe", "surfshark", "cyberghost",
|
||||
"vyprvpn", "nordvpn", "purevpn",
|
||||
})
|
||||
if s == "pia" {
|
||||
s = "private internet access"
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// GetPortForwarding obtains if port forwarding on the VPN provider server
|
||||
// side is enabled or not from the environment variable PORT_FORWARDING
|
||||
// Only valid for older PIA servers for now
|
||||
// Only valid for older PIA servers for now.
|
||||
func (r *reader) GetPortForwarding() (activated bool, err error) {
|
||||
s, err := r.envParams.GetEnv("PORT_FORWARDING", libparams.Default("off"))
|
||||
if err != nil {
|
||||
@@ -26,15 +26,18 @@ func (r *reader) GetPortForwarding() (activated bool, err error) {
|
||||
}
|
||||
|
||||
// GetPortForwardingStatusFilepath obtains the port forwarding status file path
|
||||
// from the environment variable PORT_FORWARDING_STATUS_FILE
|
||||
// from the environment variable PORT_FORWARDING_STATUS_FILE.
|
||||
func (r *reader) GetPortForwardingStatusFilepath() (filepath models.Filepath, err error) {
|
||||
filepathStr, err := r.envParams.GetPath("PORT_FORWARDING_STATUS_FILE", libparams.Default("/tmp/gluetun/forwarded_port"), libparams.CaseSensitiveValue())
|
||||
filepathStr, err := r.envParams.GetPath(
|
||||
"PORT_FORWARDING_STATUS_FILE",
|
||||
libparams.Default("/tmp/gluetun/forwarded_port"),
|
||||
libparams.CaseSensitiveValue())
|
||||
return models.Filepath(filepathStr), err
|
||||
}
|
||||
|
||||
// GetPIAEncryptionPreset obtains the encryption level for the PIA connection
|
||||
// from the environment variable PIA_ENCRYPTION, and using ENCRYPTION for
|
||||
// retro compatibility
|
||||
// retro compatibility.
|
||||
func (r *reader) GetPIAEncryptionPreset() (preset string, err error) {
|
||||
// Retro-compatibility
|
||||
s, err := r.envParams.GetValueIfInside("ENCRYPTION", []string{
|
||||
@@ -57,14 +60,14 @@ func (r *reader) GetPIAEncryptionPreset() (preset string, err error) {
|
||||
}
|
||||
|
||||
// GetPIARegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPIARegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAGeoChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetPIAOldRegions obtains the regions for the PIA servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPIAOldRegions() (regions []string, err error) {
|
||||
choices := append(constants.PIAOldGeoChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// GetPublicIPPeriod obtains the period to fetch the IP address periodically.
|
||||
// Set to 0 to disable
|
||||
// Set to 0 to disable.
|
||||
func (r *reader) GetPublicIPPeriod() (period time.Duration, err error) {
|
||||
s, err := r.envParams.GetEnv("PUBLICIP_PERIOD", libparams.Default("12h"))
|
||||
if err != nil {
|
||||
|
||||
@@ -5,21 +5,21 @@ import (
|
||||
)
|
||||
|
||||
// GetPurevpnRegions obtains the regions (continents) for the PureVPN servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetPurevpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.PurevpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetPurevpnCountries obtains the countries for the PureVPN servers from the
|
||||
// environment variable COUNTRY
|
||||
// environment variable COUNTRY.
|
||||
func (r *reader) GetPurevpnCountries() (countries []string, err error) {
|
||||
choices := append(constants.PurevpnCountryChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("COUNTRY", choices)
|
||||
}
|
||||
|
||||
// GetPurevpnCities obtains the cities for the PureVPN servers from the
|
||||
// environment variable CITY
|
||||
// environment variable CITY.
|
||||
func (r *reader) GetPurevpnCities() (cities []string, err error) {
|
||||
choices := append(constants.PurevpnCityChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("CITY", choices)
|
||||
|
||||
@@ -7,19 +7,19 @@ import (
|
||||
)
|
||||
|
||||
// GetShadowSocks obtains if ShadowSocks is on from the environment variable
|
||||
// SHADOWSOCKS
|
||||
// SHADOWSOCKS.
|
||||
func (r *reader) GetShadowSocks() (activated bool, err error) {
|
||||
return r.envParams.GetOnOff("SHADOWSOCKS", libparams.Default("off"))
|
||||
}
|
||||
|
||||
// GetShadowSocksLog obtains the ShadowSocks log level from the environment variable
|
||||
// SHADOWSOCKS_LOG
|
||||
// SHADOWSOCKS_LOG.
|
||||
func (r *reader) GetShadowSocksLog() (activated bool, err error) {
|
||||
return r.envParams.GetOnOff("SHADOWSOCKS_LOG", libparams.Default("off"))
|
||||
}
|
||||
|
||||
// GetShadowSocksPort obtains the ShadowSocks listening port from the environment variable
|
||||
// SHADOWSOCKS_PORT
|
||||
// SHADOWSOCKS_PORT.
|
||||
func (r *reader) GetShadowSocksPort() (port uint16, err error) {
|
||||
portStr, err := r.envParams.GetEnv("SHADOWSOCKS_PORT", libparams.Default("8388"))
|
||||
if err != nil {
|
||||
@@ -33,7 +33,7 @@ func (r *reader) GetShadowSocksPort() (port uint16, err error) {
|
||||
}
|
||||
|
||||
// GetShadowSocksPassword obtains the ShadowSocks server password from the environment variable
|
||||
// SHADOWSOCKS_PASSWORD
|
||||
// SHADOWSOCKS_PASSWORD.
|
||||
func (r *reader) GetShadowSocksPassword() (password string, err error) {
|
||||
defer func() {
|
||||
unsetErr := r.unsetEnv("SHADOWSOCKS_PASSWORD")
|
||||
@@ -45,7 +45,7 @@ func (r *reader) GetShadowSocksPassword() (password string, err error) {
|
||||
}
|
||||
|
||||
// GetShadowSocksMethod obtains the ShadowSocks method to use from the environment variable
|
||||
// SHADOWSOCKS_METHOD
|
||||
// SHADOWSOCKS_METHOD.
|
||||
func (r *reader) GetShadowSocksMethod() (method string, err error) {
|
||||
return r.envParams.GetEnv("SHADOWSOCKS_METHOD", libparams.Default("chacha20-ietf-poly1305"))
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// GetSurfsharkRegions obtains the regions for the Surfshark servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetSurfsharkRegions() (regions []string, err error) {
|
||||
choices := append(constants.SurfsharkRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
|
||||
@@ -5,24 +5,25 @@ import (
|
||||
libparams "github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
// GetUID obtains the user ID to use from the environment variable UID
|
||||
// GetUID obtains the user ID to use from the environment variable UID.
|
||||
func (r *reader) GetUID() (uid int, err error) {
|
||||
return r.envParams.GetEnvIntRange("UID", 0, 65535, libparams.Default("1000"))
|
||||
}
|
||||
|
||||
// GetGID obtains the group ID to use from the environment variable GID
|
||||
// GetGID obtains the group ID to use from the environment variable GID.
|
||||
func (r *reader) GetGID() (gid int, err error) {
|
||||
return r.envParams.GetEnvIntRange("GID", 0, 65535, libparams.Default("1000"))
|
||||
}
|
||||
|
||||
// GetTZ obtains the timezone from the environment variable TZ
|
||||
// GetTZ obtains the timezone from the environment variable TZ.
|
||||
func (r *reader) GetTimezone() (timezone string, err error) {
|
||||
return r.envParams.GetEnv("TZ")
|
||||
}
|
||||
|
||||
// GetIPStatusFilepath obtains the IP status file path
|
||||
// from the environment variable IP_STATUS_FILE
|
||||
// from the environment variable IP_STATUS_FILE.
|
||||
func (r *reader) GetIPStatusFilepath() (filepath models.Filepath, err error) {
|
||||
filepathStr, err := r.envParams.GetPath("IP_STATUS_FILE", libparams.Default("/tmp/gluetun/ip"), libparams.CaseSensitiveValue())
|
||||
filepathStr, err := r.envParams.GetPath("IP_STATUS_FILE",
|
||||
libparams.Default("/tmp/gluetun/ip"), libparams.CaseSensitiveValue())
|
||||
return models.Filepath(filepathStr), err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// GetTinyProxy obtains if TinyProxy is on from the environment variable
|
||||
// TINYPROXY, and using PROXY as a retro-compatibility name
|
||||
// TINYPROXY, and using PROXY as a retro-compatibility name.
|
||||
func (r *reader) GetTinyProxy() (activated bool, err error) {
|
||||
// Retro-compatibility
|
||||
s, err := r.envParams.GetEnv("PROXY")
|
||||
@@ -22,23 +22,27 @@ func (r *reader) GetTinyProxy() (activated bool, err error) {
|
||||
}
|
||||
|
||||
// GetTinyProxyLog obtains the TinyProxy log level from the environment variable
|
||||
// TINYPROXY_LOG, and using PROXY_LOG_LEVEL as a retro-compatibility name
|
||||
// TINYPROXY_LOG, and using PROXY_LOG_LEVEL as a retro-compatibility name.
|
||||
func (r *reader) GetTinyProxyLog() (models.TinyProxyLogLevel, error) {
|
||||
// Retro-compatibility
|
||||
s, err := r.envParams.GetEnv("PROXY_LOG_LEVEL")
|
||||
if err != nil {
|
||||
return models.TinyProxyLogLevel(s), err
|
||||
} else if len(s) != 0 {
|
||||
r.logger.Warn("You are using the old environment variable PROXY_LOG_LEVEL, please consider changing it to TINYPROXY_LOG")
|
||||
s, err = r.envParams.GetValueIfInside("PROXY_LOG_LEVEL", []string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"}, libparams.Compulsory())
|
||||
r.logger.Warn("You are using the old environment variable PROXY_LOG_LEVEL, please consider changing it to TINYPROXY_LOG") //nolint:lll
|
||||
s, err = r.envParams.GetValueIfInside("PROXY_LOG_LEVEL",
|
||||
[]string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"},
|
||||
libparams.Compulsory())
|
||||
return models.TinyProxyLogLevel(s), err
|
||||
}
|
||||
s, err = r.envParams.GetValueIfInside("TINYPROXY_LOG", []string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"}, libparams.Default("Connect"))
|
||||
s, err = r.envParams.GetValueIfInside("TINYPROXY_LOG",
|
||||
[]string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"},
|
||||
libparams.Default("Connect"))
|
||||
return models.TinyProxyLogLevel(s), err
|
||||
}
|
||||
|
||||
// GetTinyProxyPort obtains the TinyProxy listening port from the environment variable
|
||||
// TINYPROXY_PORT, and using PROXY_PORT as a retro-compatibility name
|
||||
// TINYPROXY_PORT, and using PROXY_PORT as a retro-compatibility name.
|
||||
func (r *reader) GetTinyProxyPort() (port uint16, err error) {
|
||||
// Retro-compatibility
|
||||
portStr, err := r.envParams.GetEnv("PROXY_PORT")
|
||||
@@ -61,7 +65,7 @@ func (r *reader) GetTinyProxyPort() (port uint16, err error) {
|
||||
}
|
||||
|
||||
// GetTinyProxyUser obtains the TinyProxy server user from the environment variable
|
||||
// TINYPROXY_USER, and using PROXY_USER as a retro-compatibility name
|
||||
// TINYPROXY_USER, and using PROXY_USER as a retro-compatibility name.
|
||||
func (r *reader) GetTinyProxyUser() (user string, err error) {
|
||||
defer func() {
|
||||
unsetErr := r.unsetEnv("PROXY_USER")
|
||||
@@ -88,7 +92,7 @@ func (r *reader) GetTinyProxyUser() (user string, err error) {
|
||||
}
|
||||
|
||||
// GetTinyProxyPassword obtains the TinyProxy server password from the environment variable
|
||||
// TINYPROXY_PASSWORD, and using PROXY_PASSWORD as a retro-compatibility name
|
||||
// TINYPROXY_PASSWORD, and using PROXY_PASSWORD as a retro-compatibility name.
|
||||
func (r *reader) GetTinyProxyPassword() (password string, err error) {
|
||||
defer func() {
|
||||
unsetErr := r.unsetEnv("PROXY_PASSWORD")
|
||||
@@ -109,7 +113,7 @@ func (r *reader) GetTinyProxyPassword() (password string, err error) {
|
||||
return password, err
|
||||
}
|
||||
if len(password) != 0 {
|
||||
r.logger.Warn("You are using the old environment variable PROXY_PASSWORD, please consider changing it to TINYPROXY_PASSWORD")
|
||||
r.logger.Warn("You are using the old environment variable PROXY_PASSWORD, please consider changing it to TINYPROXY_PASSWORD") //nolint:lll
|
||||
return password, nil
|
||||
}
|
||||
return r.envParams.GetEnv("TINYPROXY_PASSWORD", libparams.CaseSensitiveValue())
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// GetUpdaterPeriod obtains the period to fetch the servers information when the tunnel is up.
|
||||
// Set to 0 to disable
|
||||
// Set to 0 to disable.
|
||||
func (r *reader) GetUpdaterPeriod() (period time.Duration, err error) {
|
||||
s, err := r.envParams.GetEnv("UPDATER_PERIOD", libparams.Default("0"))
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// GetVyprvpnRegions obtains the regions for the Vyprvpn servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetVyprvpnRegions() (regions []string, err error) {
|
||||
choices := append(constants.VyprvpnRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
|
||||
@@ -9,14 +9,15 @@ import (
|
||||
)
|
||||
|
||||
// GetWindscribeRegions obtains the regions for the Windscribe servers from the
|
||||
// environment variable REGION
|
||||
// environment variable REGION.
|
||||
func (r *reader) GetWindscribeRegions() (regions []string, err error) {
|
||||
choices := append(constants.WindscribeRegionChoices(), "")
|
||||
return r.envParams.GetCSVInPossibilities("REGION", choices)
|
||||
}
|
||||
|
||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||
// environment variable PORT
|
||||
// environment variable PORT.
|
||||
//nolint:gomnd
|
||||
func (r *reader) GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error) {
|
||||
n, err := r.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user