Replace p with r for params reader (lint issue)
This commit is contained in:
@@ -13,14 +13,14 @@ import (
|
|||||||
|
|
||||||
// GetDNSOverTLS obtains if the DNS over TLS should be enabled
|
// GetDNSOverTLS obtains if the DNS over TLS should be enabled
|
||||||
// from the environment variable DOT
|
// from the environment variable DOT
|
||||||
func (p *reader) GetDNSOverTLS() (DNSOverTLS bool, err error) { //nolint:gocritic
|
func (r *reader) GetDNSOverTLS() (DNSOverTLS bool, err error) { //nolint:gocritic
|
||||||
return p.envParams.GetOnOff("DOT", libparams.Default("on"))
|
return r.envParams.GetOnOff("DOT", libparams.Default("on"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSOverTLSProviders obtains the DNS over TLS providers to use
|
// GetDNSOverTLSProviders obtains the DNS over TLS providers to use
|
||||||
// from the environment variable DOT_PROVIDERS
|
// from the environment variable DOT_PROVIDERS
|
||||||
func (p *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err error) {
|
func (r *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err error) {
|
||||||
s, err := p.envParams.GetEnv("DOT_PROVIDERS", libparams.Default("cloudflare"))
|
s, err := r.envParams.GetEnv("DOT_PROVIDERS", libparams.Default("cloudflare"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -38,56 +38,56 @@ func (p *reader) GetDNSOverTLSProviders() (providers []models.DNSProvider, err e
|
|||||||
|
|
||||||
// GetDNSOverTLSVerbosity obtains the verbosity level to use for Unbound
|
// GetDNSOverTLSVerbosity obtains the verbosity level to use for Unbound
|
||||||
// from the environment variable DOT_VERBOSITY
|
// from the environment variable DOT_VERBOSITY
|
||||||
func (p *reader) GetDNSOverTLSVerbosity() (verbosityLevel uint8, err error) {
|
func (r *reader) GetDNSOverTLSVerbosity() (verbosityLevel uint8, err error) {
|
||||||
n, err := p.envParams.GetEnvIntRange("DOT_VERBOSITY", 0, 5, libparams.Default("1"))
|
n, err := r.envParams.GetEnvIntRange("DOT_VERBOSITY", 0, 5, libparams.Default("1"))
|
||||||
return uint8(n), err
|
return uint8(n), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSOverTLSVerbosityDetails obtains the log level to use for Unbound
|
// GetDNSOverTLSVerbosityDetails obtains the log level to use for Unbound
|
||||||
// from the environment variable DOT_VERBOSITY_DETAILS
|
// from the environment variable DOT_VERBOSITY_DETAILS
|
||||||
func (p *reader) GetDNSOverTLSVerbosityDetails() (verbosityDetailsLevel uint8, err error) {
|
func (r *reader) GetDNSOverTLSVerbosityDetails() (verbosityDetailsLevel uint8, err error) {
|
||||||
n, err := p.envParams.GetEnvIntRange("DOT_VERBOSITY_DETAILS", 0, 4, libparams.Default("0"))
|
n, err := r.envParams.GetEnvIntRange("DOT_VERBOSITY_DETAILS", 0, 4, libparams.Default("0"))
|
||||||
return uint8(n), err
|
return uint8(n), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSOverTLSValidationLogLevel obtains the log level to use for Unbound DOT validation
|
// 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 (p *reader) GetDNSOverTLSValidationLogLevel() (validationLogLevel uint8, err error) {
|
func (r *reader) GetDNSOverTLSValidationLogLevel() (validationLogLevel uint8, err error) {
|
||||||
n, err := p.envParams.GetEnvIntRange("DOT_VALIDATION_LOGLEVEL", 0, 2, libparams.Default("0"))
|
n, err := r.envParams.GetEnvIntRange("DOT_VALIDATION_LOGLEVEL", 0, 2, libparams.Default("0"))
|
||||||
return uint8(n), err
|
return uint8(n), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSMaliciousBlocking obtains if malicious hostnames/IPs should be blocked
|
// 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 (p *reader) GetDNSMaliciousBlocking() (blocking bool, err error) {
|
func (r *reader) GetDNSMaliciousBlocking() (blocking bool, err error) {
|
||||||
return p.envParams.GetOnOff("BLOCK_MALICIOUS", libparams.Default("on"))
|
return r.envParams.GetOnOff("BLOCK_MALICIOUS", libparams.Default("on"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSSurveillanceBlocking obtains if surveillance hostnames/IPs should be blocked
|
// GetDNSSurveillanceBlocking obtains if surveillance hostnames/IPs should be blocked
|
||||||
// from being resolved by Unbound, using the environment variable BLOCK_SURVEILLANCE
|
// from being resolved by Unbound, using the environment variable BLOCK_SURVEILLANCE
|
||||||
// and BLOCK_NSA for retrocompatibility
|
// and BLOCK_NSA for retrocompatibility
|
||||||
func (p *reader) GetDNSSurveillanceBlocking() (blocking bool, err error) {
|
func (r *reader) GetDNSSurveillanceBlocking() (blocking bool, err error) {
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
s, err := p.envParams.GetEnv("BLOCK_NSA")
|
s, err := r.envParams.GetEnv("BLOCK_NSA")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if len(s) != 0 {
|
} else if len(s) != 0 {
|
||||||
p.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")
|
||||||
return p.envParams.GetOnOff("BLOCK_NSA", libparams.Compulsory())
|
return r.envParams.GetOnOff("BLOCK_NSA", libparams.Compulsory())
|
||||||
}
|
}
|
||||||
return p.envParams.GetOnOff("BLOCK_SURVEILLANCE", libparams.Default("off"))
|
return r.envParams.GetOnOff("BLOCK_SURVEILLANCE", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSAdsBlocking obtains if ads hostnames/IPs should be blocked
|
// 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 (p *reader) GetDNSAdsBlocking() (blocking bool, err error) {
|
func (r *reader) GetDNSAdsBlocking() (blocking bool, err error) {
|
||||||
return p.envParams.GetOnOff("BLOCK_ADS", libparams.Default("off"))
|
return r.envParams.GetOnOff("BLOCK_ADS", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSUnblockedHostnames obtains a list of hostnames to unblock from block lists
|
// 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 (p *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
func (r *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
||||||
s, err := p.envParams.GetEnv("UNBLOCK")
|
s, err := r.envParams.GetEnv("UNBLOCK")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if len(s) == 0 {
|
} else if len(s) == 0 {
|
||||||
@@ -95,7 +95,7 @@ func (p *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
|||||||
}
|
}
|
||||||
hostnames = strings.Split(s, ",")
|
hostnames = strings.Split(s, ",")
|
||||||
for _, hostname := range hostnames {
|
for _, hostname := range hostnames {
|
||||||
if !p.verifier.MatchHostname(hostname) {
|
if !r.verifier.MatchHostname(hostname) {
|
||||||
return nil, fmt.Errorf("hostname %q does not seem valid", hostname)
|
return nil, fmt.Errorf("hostname %q does not seem valid", hostname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,14 +104,14 @@ func (p *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {
|
|||||||
|
|
||||||
// GetDNSOverTLSCaching obtains if Unbound caching should be enable or not
|
// GetDNSOverTLSCaching obtains if Unbound caching should be enable or not
|
||||||
// from the environment variable DOT_CACHING
|
// from the environment variable DOT_CACHING
|
||||||
func (p *reader) GetDNSOverTLSCaching() (caching bool, err error) {
|
func (r *reader) GetDNSOverTLSCaching() (caching bool, err error) {
|
||||||
return p.envParams.GetOnOff("DOT_CACHING")
|
return r.envParams.GetOnOff("DOT_CACHING")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSOverTLSPrivateAddresses obtains if Unbound caching should be enable or not
|
// 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 (p *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err error) {
|
func (r *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err error) {
|
||||||
s, err := p.envParams.GetEnv("DOT_PRIVATE_ADDRESS")
|
s, err := r.envParams.GetEnv("DOT_PRIVATE_ADDRESS")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if len(s) == 0 {
|
} else if len(s) == 0 {
|
||||||
@@ -130,14 +130,14 @@ func (p *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err
|
|||||||
|
|
||||||
// GetDNSOverTLSIPv6 obtains if Unbound should resolve ipv6 addresses using ipv6 DNS over TLS
|
// 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 (p *reader) GetDNSOverTLSIPv6() (ipv6 bool, err error) {
|
func (r *reader) GetDNSOverTLSIPv6() (ipv6 bool, err error) {
|
||||||
return p.envParams.GetOnOff("DOT_IPV6", libparams.Default("off"))
|
return r.envParams.GetOnOff("DOT_IPV6", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDNSUpdatePeriod obtains the period to use to update the block lists and cryptographic files
|
// 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 (p *reader) GetDNSUpdatePeriod() (period time.Duration, err error) {
|
func (r *reader) GetDNSUpdatePeriod() (period time.Duration, err error) {
|
||||||
s, err := p.envParams.GetEnv("DNS_UPDATE_PERIOD", libparams.Default("24h"))
|
s, err := r.envParams.GetEnv("DNS_UPDATE_PERIOD", libparams.Default("24h"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return period, err
|
return period, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import (
|
|||||||
|
|
||||||
// GetExtraSubnets obtains the CIDR subnets from the comma separated list of the
|
// GetExtraSubnets obtains the CIDR subnets from the comma separated list of the
|
||||||
// environment variable EXTRA_SUBNETS
|
// environment variable EXTRA_SUBNETS
|
||||||
func (p *reader) GetExtraSubnets() (extraSubnets []net.IPNet, err error) {
|
func (r *reader) GetExtraSubnets() (extraSubnets []net.IPNet, err error) {
|
||||||
s, err := p.envParams.GetEnv("EXTRA_SUBNETS")
|
s, err := r.envParams.GetEnv("EXTRA_SUBNETS")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if s == "" {
|
} else if s == "" {
|
||||||
|
|||||||
@@ -10,31 +10,31 @@ 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 *reader) GetMullvadCountry() (country models.MullvadCountry, err error) {
|
func (r *reader) GetMullvadCountry() (country models.MullvadCountry, err error) {
|
||||||
choices := append(constants.MullvadCountryChoices(), "")
|
choices := append(constants.MullvadCountryChoices(), "")
|
||||||
s, err := p.envParams.GetValueIfInside("COUNTRY", choices)
|
s, err := r.envParams.GetValueIfInside("COUNTRY", choices)
|
||||||
return models.MullvadCountry(strings.ToLower(s)), err
|
return models.MullvadCountry(strings.ToLower(s)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMullvadCity obtains the city for the Mullvad server from the
|
// GetMullvadCity obtains the city for the Mullvad server from the
|
||||||
// environment variable CITY
|
// environment variable CITY
|
||||||
func (p *reader) GetMullvadCity() (country models.MullvadCity, err error) {
|
func (r *reader) GetMullvadCity() (country models.MullvadCity, err error) {
|
||||||
choices := append(constants.MullvadCityChoices(), "")
|
choices := append(constants.MullvadCityChoices(), "")
|
||||||
s, err := p.envParams.GetValueIfInside("CITY", choices)
|
s, err := r.envParams.GetValueIfInside("CITY", choices)
|
||||||
return models.MullvadCity(strings.ToLower(s)), err
|
return models.MullvadCity(strings.ToLower(s)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMullvadISP obtains the ISP for the Mullvad server from the
|
// GetMullvadISP obtains the ISP for the Mullvad server from the
|
||||||
// environment variable ISP
|
// environment variable ISP
|
||||||
func (p *reader) GetMullvadISP() (country models.MullvadProvider, err error) {
|
func (r *reader) GetMullvadISP() (country models.MullvadProvider, err error) {
|
||||||
choices := append(constants.MullvadProviderChoices(), "")
|
choices := append(constants.MullvadProviderChoices(), "")
|
||||||
s, err := p.envParams.GetValueIfInside("ISP", choices)
|
s, err := r.envParams.GetValueIfInside("ISP", choices)
|
||||||
return models.MullvadProvider(strings.ToLower(s)), err
|
return models.MullvadProvider(strings.ToLower(s)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||||
// environment variable PORT
|
// environment variable PORT
|
||||||
func (p *reader) GetMullvadPort() (port uint16, err error) {
|
func (r *reader) GetMullvadPort() (port uint16, err error) {
|
||||||
n, err := p.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
n, err := r.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
||||||
return uint16(n), err
|
return uint16(n), err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,51 +10,51 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 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 (p *reader) GetUser() (s string, err error) {
|
func (r *reader) GetUser() (s string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetenvErr := p.unsetEnv("USER")
|
unsetenvErr := r.unsetEnv("USER")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetenvErr
|
err = unsetenvErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return p.envParams.GetEnv("USER", libparams.CaseSensitiveValue(), libparams.Compulsory())
|
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 (p *reader) GetPassword() (s string, err error) {
|
func (r *reader) GetPassword() (s string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetenvErr := p.unsetEnv("PASSWORD")
|
unsetenvErr := r.unsetEnv("PASSWORD")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetenvErr
|
err = unsetenvErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return p.envParams.GetEnv("PASSWORD", libparams.CaseSensitiveValue(), libparams.Compulsory())
|
return r.envParams.GetEnv("PASSWORD", libparams.CaseSensitiveValue(), libparams.Compulsory())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNetworkProtocol obtains the network protocol to use to connect to the
|
// 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 (p *reader) GetNetworkProtocol() (protocol models.NetworkProtocol, err error) {
|
func (r *reader) GetNetworkProtocol() (protocol models.NetworkProtocol, err error) {
|
||||||
s, err := p.envParams.GetValueIfInside("PROTOCOL", []string{"tcp", "udp"}, libparams.Default("udp"))
|
s, err := r.envParams.GetValueIfInside("PROTOCOL", []string{"tcp", "udp"}, libparams.Default("udp"))
|
||||||
return models.NetworkProtocol(s), err
|
return models.NetworkProtocol(s), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOpenVPNVerbosity obtains the verbosity level for verbosity between 0 and 6
|
// GetOpenVPNVerbosity obtains the verbosity level for verbosity between 0 and 6
|
||||||
// from the environment variable OPENVPN_VERBOSITY
|
// from the environment variable OPENVPN_VERBOSITY
|
||||||
func (p *reader) GetOpenVPNVerbosity() (verbosity int, err error) {
|
func (r *reader) GetOpenVPNVerbosity() (verbosity int, err error) {
|
||||||
return p.envParams.GetEnvIntRange("OPENVPN_VERBOSITY", 0, 6, libparams.Default("1"))
|
return r.envParams.GetEnvIntRange("OPENVPN_VERBOSITY", 0, 6, libparams.Default("1"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOpenVPNRoot obtains if openvpn should be run as root
|
// GetOpenVPNRoot obtains if openvpn should be run as root
|
||||||
// from the environment variable OPENVPN_ROOT
|
// from the environment variable OPENVPN_ROOT
|
||||||
func (p *reader) GetOpenVPNRoot() (root bool, err error) {
|
func (r *reader) GetOpenVPNRoot() (root bool, err error) {
|
||||||
return p.envParams.GetYesNo("OPENVPN_ROOT", libparams.Default("no"))
|
return r.envParams.GetYesNo("OPENVPN_ROOT", libparams.Default("no"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTargetIP obtains the IP address to choose from the list of IP addresses
|
// GetTargetIP obtains the IP address to choose from the list of IP addresses
|
||||||
// available for a particular region, from the environment variable
|
// available for a particular region, from the environment variable
|
||||||
// OPENVPN_TARGET_IP
|
// OPENVPN_TARGET_IP
|
||||||
func (p *reader) GetTargetIP() (ip net.IP, err error) {
|
func (r *reader) GetTargetIP() (ip net.IP, err error) {
|
||||||
s, err := p.envParams.GetEnv("OPENVPN_TARGET_IP")
|
s, err := r.envParams.GetEnv("OPENVPN_TARGET_IP")
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
@@ -69,14 +69,14 @@ func (p *reader) GetTargetIP() (ip net.IP, err error) {
|
|||||||
|
|
||||||
// GetOpenVPNCipher obtains a custom cipher to use with OpenVPN
|
// GetOpenVPNCipher obtains a custom cipher to use with OpenVPN
|
||||||
// from the environment variable OPENVPN_CIPHER
|
// from the environment variable OPENVPN_CIPHER
|
||||||
func (p *reader) GetOpenVPNCipher() (cipher string, err error) {
|
func (r *reader) GetOpenVPNCipher() (cipher string, err error) {
|
||||||
cipher, err = p.envParams.GetEnv("OPENVPN_CIPHER")
|
cipher, err = r.envParams.GetEnv("OPENVPN_CIPHER")
|
||||||
return strings.ToLower(cipher), err
|
return strings.ToLower(cipher), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetOpenVPNAuth obtains a custom auth algorithm to use with OpenVPN
|
// GetOpenVPNAuth obtains a custom auth algorithm to use with OpenVPN
|
||||||
// from the environment variable OPENVPN_AUTH
|
// from the environment variable OPENVPN_AUTH
|
||||||
func (p *reader) GetOpenVPNAuth() (auth string, err error) {
|
func (r *reader) GetOpenVPNAuth() (auth string, err error) {
|
||||||
auth, err = p.envParams.GetEnv("OPENVPN_AUTH")
|
auth, err = r.envParams.GetEnv("OPENVPN_AUTH")
|
||||||
return strings.ToLower(auth), err
|
return strings.ToLower(auth), err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ func NewReader(logger logging.Logger) 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 (p *reader) GetVPNSP() (vpnServiceProvider models.VPNProvider, err error) {
|
func (r *reader) GetVPNSP() (vpnServiceProvider models.VPNProvider, err error) {
|
||||||
s, err := p.envParams.GetValueIfInside("VPNSP", []string{"pia", "private internet access", "mullvad", "windscribe", "surfshark"})
|
s, err := r.envParams.GetValueIfInside("VPNSP", []string{"pia", "private internet access", "mullvad", "windscribe", "surfshark"})
|
||||||
if s == "pia" {
|
if s == "pia" {
|
||||||
s = "private internet access"
|
s = "private internet access"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
// GetPortForwarding obtains if port forwarding on the VPN provider server
|
// GetPortForwarding obtains if port forwarding on the VPN provider server
|
||||||
// side is enabled or not from the environment variable PORT_FORWARDING
|
// side is enabled or not from the environment variable PORT_FORWARDING
|
||||||
func (p *reader) GetPortForwarding() (activated bool, err error) {
|
func (r *reader) GetPortForwarding() (activated bool, err error) {
|
||||||
s, err := p.envParams.GetEnv("PORT_FORWARDING", libparams.Default("off"))
|
s, err := r.envParams.GetEnv("PORT_FORWARDING", libparams.Default("off"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -27,32 +27,32 @@ func (p *reader) GetPortForwarding() (activated bool, err error) {
|
|||||||
|
|
||||||
// GetPortForwardingStatusFilepath obtains the port forwarding status file path
|
// 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 (p *reader) GetPortForwardingStatusFilepath() (filepath models.Filepath, err error) {
|
func (r *reader) GetPortForwardingStatusFilepath() (filepath models.Filepath, err error) {
|
||||||
filepathStr, err := p.envParams.GetPath("PORT_FORWARDING_STATUS_FILE", libparams.Default("/forwarded_port"), libparams.CaseSensitiveValue())
|
filepathStr, err := r.envParams.GetPath("PORT_FORWARDING_STATUS_FILE", libparams.Default("/forwarded_port"), libparams.CaseSensitiveValue())
|
||||||
return models.Filepath(filepathStr), err
|
return models.Filepath(filepathStr), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPIAEncryption obtains the encryption level for the PIA connection
|
// GetPIAEncryption obtains the encryption level for the PIA connection
|
||||||
// from the environment variable PIA_ENCRYPTION, and using ENCRYPTION for
|
// from the environment variable PIA_ENCRYPTION, and using ENCRYPTION for
|
||||||
// retro compatibility
|
// retro compatibility
|
||||||
func (p *reader) GetPIAEncryption() (models.PIAEncryption, error) {
|
func (r *reader) GetPIAEncryption() (models.PIAEncryption, error) {
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
s, err := p.envParams.GetValueIfInside("ENCRYPTION", []string{"normal", "strong", ""})
|
s, err := r.envParams.GetValueIfInside("ENCRYPTION", []string{"normal", "strong", ""})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else if len(s) != 0 {
|
} else if len(s) != 0 {
|
||||||
p.logger.Warn("You are using the old environment variable ENCRYPTION, please consider changing it to PIA_ENCRYPTION")
|
r.logger.Warn("You are using the old environment variable ENCRYPTION, please consider changing it to PIA_ENCRYPTION")
|
||||||
return models.PIAEncryption(s), nil
|
return models.PIAEncryption(s), nil
|
||||||
}
|
}
|
||||||
s, err = p.envParams.GetValueIfInside("PIA_ENCRYPTION", []string{"normal", "strong"}, libparams.Default("strong"))
|
s, err = r.envParams.GetValueIfInside("PIA_ENCRYPTION", []string{"normal", "strong"}, libparams.Default("strong"))
|
||||||
return models.PIAEncryption(s), err
|
return models.PIAEncryption(s), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPIARegion obtains the region for the PIA server from the
|
// GetPIARegion obtains the region for the PIA server from the
|
||||||
// environment variable REGION
|
// environment variable REGION
|
||||||
func (p *reader) GetPIARegion() (region models.PIARegion, err error) {
|
func (r *reader) GetPIARegion() (region models.PIARegion, err error) {
|
||||||
choices := append(constants.PIAGeoChoices(), "")
|
choices := append(constants.PIAGeoChoices(), "")
|
||||||
s, err := p.envParams.GetValueIfInside("REGION", choices)
|
s, err := r.envParams.GetValueIfInside("REGION", choices)
|
||||||
if len(s) == 0 { // Suggestion by @rorph https://github.com/rorph
|
if len(s) == 0 { // Suggestion by @rorph https://github.com/rorph
|
||||||
s = choices[rand.Int()%len(choices)] //nolint:gosec
|
s = choices[rand.Int()%len(choices)] //nolint:gosec
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,24 +8,24 @@ import (
|
|||||||
|
|
||||||
// GetShadowSocks obtains if ShadowSocks is on from the environment variable
|
// GetShadowSocks obtains if ShadowSocks is on from the environment variable
|
||||||
// SHADOWSOCKS
|
// SHADOWSOCKS
|
||||||
func (p *reader) GetShadowSocks() (activated bool, err error) {
|
func (r *reader) GetShadowSocks() (activated bool, err error) {
|
||||||
return p.envParams.GetOnOff("SHADOWSOCKS", libparams.Default("off"))
|
return r.envParams.GetOnOff("SHADOWSOCKS", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetShadowSocksLog obtains the ShadowSocks log level from the environment variable
|
// GetShadowSocksLog obtains the ShadowSocks log level from the environment variable
|
||||||
// SHADOWSOCKS_LOG
|
// SHADOWSOCKS_LOG
|
||||||
func (p *reader) GetShadowSocksLog() (activated bool, err error) {
|
func (r *reader) GetShadowSocksLog() (activated bool, err error) {
|
||||||
return p.envParams.GetOnOff("SHADOWSOCKS_LOG", libparams.Default("off"))
|
return r.envParams.GetOnOff("SHADOWSOCKS_LOG", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetShadowSocksPort obtains the ShadowSocks listening port from the environment variable
|
// GetShadowSocksPort obtains the ShadowSocks listening port from the environment variable
|
||||||
// SHADOWSOCKS_PORT
|
// SHADOWSOCKS_PORT
|
||||||
func (p *reader) GetShadowSocksPort() (port uint16, err error) {
|
func (r *reader) GetShadowSocksPort() (port uint16, err error) {
|
||||||
portStr, err := p.envParams.GetEnv("SHADOWSOCKS_PORT", libparams.Default("8388"))
|
portStr, err := r.envParams.GetEnv("SHADOWSOCKS_PORT", libparams.Default("8388"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if err := p.verifier.VerifyPort(portStr); err != nil {
|
if err := r.verifier.VerifyPort(portStr); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
portUint64, err := strconv.ParseUint(portStr, 10, 16)
|
portUint64, err := strconv.ParseUint(portStr, 10, 16)
|
||||||
@@ -34,18 +34,18 @@ func (p *reader) GetShadowSocksPort() (port uint16, err error) {
|
|||||||
|
|
||||||
// GetShadowSocksPassword obtains the ShadowSocks server password from the environment variable
|
// GetShadowSocksPassword obtains the ShadowSocks server password from the environment variable
|
||||||
// SHADOWSOCKS_PASSWORD
|
// SHADOWSOCKS_PASSWORD
|
||||||
func (p *reader) GetShadowSocksPassword() (password string, err error) {
|
func (r *reader) GetShadowSocksPassword() (password string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetErr := p.unsetEnv("SHADOWSOCKS_PASSWORD")
|
unsetErr := r.unsetEnv("SHADOWSOCKS_PASSWORD")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetErr
|
err = unsetErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return p.envParams.GetEnv("SHADOWSOCKS_PASSWORD", libparams.CaseSensitiveValue())
|
return r.envParams.GetEnv("SHADOWSOCKS_PASSWORD", libparams.CaseSensitiveValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetShadowSocksMethod obtains the ShadowSocks method to use from the environment variable
|
// GetShadowSocksMethod obtains the ShadowSocks method to use from the environment variable
|
||||||
// SHADOWSOCKS_METHOD
|
// SHADOWSOCKS_METHOD
|
||||||
func (p *reader) GetShadowSocksMethod() (method string, err error) {
|
func (r *reader) GetShadowSocksMethod() (method string, err error) {
|
||||||
return p.envParams.GetEnv("SHADOWSOCKS_METHOD", libparams.Default("chacha20-ietf-poly1305"))
|
return r.envParams.GetEnv("SHADOWSOCKS_METHOD", libparams.Default("chacha20-ietf-poly1305"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// GetSurfsharkRegion obtains the region for the Surfshark server from the
|
// GetSurfsharkRegion obtains the region for the Surfshark server from the
|
||||||
// environment variable REGION
|
// environment variable REGION
|
||||||
func (p *reader) GetSurfsharkRegion() (region models.SurfsharkRegion, err error) {
|
func (r *reader) GetSurfsharkRegion() (region models.SurfsharkRegion, err error) {
|
||||||
s, err := p.envParams.GetValueIfInside("REGION", constants.SurfsharkRegionChoices())
|
s, err := r.envParams.GetValueIfInside("REGION", constants.SurfsharkRegionChoices())
|
||||||
return models.SurfsharkRegion(strings.ToLower(s)), err
|
return models.SurfsharkRegion(strings.ToLower(s)), err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 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 (p *reader) GetUID() (uid int, err error) {
|
func (r *reader) GetUID() (uid int, err error) {
|
||||||
return p.envParams.GetEnvIntRange("UID", 0, 65535, libparams.Default("1000"))
|
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 (p *reader) GetGID() (gid int, err error) {
|
func (r *reader) GetGID() (gid int, err error) {
|
||||||
return p.envParams.GetEnvIntRange("GID", 0, 65535, libparams.Default("1000"))
|
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 (p *reader) GetTimezone() (timezone string, err error) {
|
func (r *reader) GetTimezone() (timezone string, err error) {
|
||||||
return p.envParams.GetEnv("TZ")
|
return r.envParams.GetEnv("TZ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIPStatusFilepath obtains the IP status file path
|
// GetIPStatusFilepath obtains the IP status file path
|
||||||
// from the environment variable IP_STATUS_FILE
|
// from the environment variable IP_STATUS_FILE
|
||||||
func (p *reader) GetIPStatusFilepath() (filepath models.Filepath, err error) {
|
func (r *reader) GetIPStatusFilepath() (filepath models.Filepath, err error) {
|
||||||
filepathStr, err := p.envParams.GetPath("IP_STATUS_FILE", libparams.Default("/ip"), libparams.CaseSensitiveValue())
|
filepathStr, err := r.envParams.GetPath("IP_STATUS_FILE", libparams.Default("/ip"), libparams.CaseSensitiveValue())
|
||||||
return models.Filepath(filepathStr), err
|
return models.Filepath(filepathStr), err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,51 +9,51 @@ import (
|
|||||||
|
|
||||||
// GetTinyProxy obtains if TinyProxy is on from the environment variable
|
// 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 (p *reader) GetTinyProxy() (activated bool, err error) {
|
func (r *reader) GetTinyProxy() (activated bool, err error) {
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
s, err := p.envParams.GetEnv("PROXY")
|
s, err := r.envParams.GetEnv("PROXY")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if len(s) != 0 {
|
} else if len(s) != 0 {
|
||||||
p.logger.Warn("You are using the old environment variable PROXY, please consider changing it to TINYPROXY")
|
r.logger.Warn("You are using the old environment variable PROXY, please consider changing it to TINYPROXY")
|
||||||
return p.envParams.GetOnOff("PROXY", libparams.Compulsory())
|
return r.envParams.GetOnOff("PROXY", libparams.Compulsory())
|
||||||
}
|
}
|
||||||
return p.envParams.GetOnOff("TINYPROXY", libparams.Default("off"))
|
return r.envParams.GetOnOff("TINYPROXY", libparams.Default("off"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTinyProxyLog obtains the TinyProxy log level from the environment variable
|
// 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 (p *reader) GetTinyProxyLog() (models.TinyProxyLogLevel, error) {
|
func (r *reader) GetTinyProxyLog() (models.TinyProxyLogLevel, error) {
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
s, err := p.envParams.GetEnv("PROXY_LOG_LEVEL")
|
s, err := r.envParams.GetEnv("PROXY_LOG_LEVEL")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.TinyProxyLogLevel(s), err
|
return models.TinyProxyLogLevel(s), err
|
||||||
} else if len(s) != 0 {
|
} else if len(s) != 0 {
|
||||||
p.logger.Warn("You are using the old environment variable PROXY_LOG_LEVEL, please consider changing it to TINYPROXY_LOG")
|
r.logger.Warn("You are using the old environment variable PROXY_LOG_LEVEL, please consider changing it to TINYPROXY_LOG")
|
||||||
s, err = p.envParams.GetValueIfInside("PROXY_LOG_LEVEL", []string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"}, libparams.Compulsory())
|
s, err = r.envParams.GetValueIfInside("PROXY_LOG_LEVEL", []string{"Info", "Connect", "Notice", "Warning", "Error", "Critical"}, libparams.Compulsory())
|
||||||
return models.TinyProxyLogLevel(s), err
|
return models.TinyProxyLogLevel(s), err
|
||||||
}
|
}
|
||||||
s, err = p.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
|
return models.TinyProxyLogLevel(s), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTinyProxyPort obtains the TinyProxy listening port from the environment variable
|
// 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 (p *reader) GetTinyProxyPort() (port uint16, err error) {
|
func (r *reader) GetTinyProxyPort() (port uint16, err error) {
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
portStr, err := p.envParams.GetEnv("PROXY_PORT")
|
portStr, err := r.envParams.GetEnv("PROXY_PORT")
|
||||||
switch {
|
switch {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return 0, err
|
return 0, err
|
||||||
case len(portStr) != 0:
|
case len(portStr) != 0:
|
||||||
p.logger.Warn("You are using the old environment variable PROXY_PORT, please consider changing it to TINYPROXY_PORT")
|
r.logger.Warn("You are using the old environment variable PROXY_PORT, please consider changing it to TINYPROXY_PORT")
|
||||||
default:
|
default:
|
||||||
portStr, err = p.envParams.GetEnv("TINYPROXY_PORT", libparams.Default("8888"))
|
portStr, err = r.envParams.GetEnv("TINYPROXY_PORT", libparams.Default("8888"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := p.verifier.VerifyPort(portStr); err != nil {
|
if err := r.verifier.VerifyPort(portStr); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
portUint64, err := strconv.ParseUint(portStr, 10, 16)
|
portUint64, err := strconv.ParseUint(portStr, 10, 16)
|
||||||
@@ -62,55 +62,55 @@ func (p *reader) GetTinyProxyPort() (port uint16, err error) {
|
|||||||
|
|
||||||
// GetTinyProxyUser obtains the TinyProxy server user from the environment variable
|
// 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 (p *reader) GetTinyProxyUser() (user string, err error) {
|
func (r *reader) GetTinyProxyUser() (user string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetErr := p.unsetEnv("PROXY_USER")
|
unsetErr := r.unsetEnv("PROXY_USER")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetErr
|
err = unsetErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetErr := p.unsetEnv("TINYPROXY_USER")
|
unsetErr := r.unsetEnv("TINYPROXY_USER")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetErr
|
err = unsetErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
user, err = p.envParams.GetEnv("PROXY_USER", libparams.CaseSensitiveValue())
|
user, err = r.envParams.GetEnv("PROXY_USER", libparams.CaseSensitiveValue())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
if len(user) != 0 {
|
if len(user) != 0 {
|
||||||
p.logger.Warn("You are using the old environment variable PROXY_USER, please consider changing it to TINYPROXY_USER")
|
r.logger.Warn("You are using the old environment variable PROXY_USER, please consider changing it to TINYPROXY_USER")
|
||||||
return user, nil
|
return user, nil
|
||||||
}
|
}
|
||||||
return p.envParams.GetEnv("TINYPROXY_USER", libparams.CaseSensitiveValue())
|
return r.envParams.GetEnv("TINYPROXY_USER", libparams.CaseSensitiveValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTinyProxyPassword obtains the TinyProxy server password from the environment variable
|
// 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 (p *reader) GetTinyProxyPassword() (password string, err error) {
|
func (r *reader) GetTinyProxyPassword() (password string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetErr := p.unsetEnv("PROXY_PASSWORD")
|
unsetErr := r.unsetEnv("PROXY_PASSWORD")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetErr
|
err = unsetErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer func() {
|
defer func() {
|
||||||
unsetErr := p.unsetEnv("TINYPROXY_PASSWORD")
|
unsetErr := r.unsetEnv("TINYPROXY_PASSWORD")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = unsetErr
|
err = unsetErr
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Retro-compatibility
|
// Retro-compatibility
|
||||||
password, err = p.envParams.GetEnv("PROXY_PASSWORD", libparams.CaseSensitiveValue())
|
password, err = r.envParams.GetEnv("PROXY_PASSWORD", libparams.CaseSensitiveValue())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return password, err
|
return password, err
|
||||||
}
|
}
|
||||||
if len(password) != 0 {
|
if len(password) != 0 {
|
||||||
p.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")
|
||||||
return password, nil
|
return password, nil
|
||||||
}
|
}
|
||||||
return p.envParams.GetEnv("TINYPROXY_PASSWORD", libparams.CaseSensitiveValue())
|
return r.envParams.GetEnv("TINYPROXY_PASSWORD", libparams.CaseSensitiveValue())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ import (
|
|||||||
libparams "github.com/qdm12/golibs/params"
|
libparams "github.com/qdm12/golibs/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *reader) GetVersion() string {
|
func (r *reader) GetVersion() string {
|
||||||
version, _ := p.envParams.GetEnv("VERSION", libparams.Default("?"), libparams.CaseSensitiveValue())
|
version, _ := r.envParams.GetEnv("VERSION", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *reader) GetBuildDate() string {
|
func (r *reader) GetBuildDate() string {
|
||||||
buildDate, _ := p.envParams.GetEnv("BUILD_DATE", libparams.Default("?"), libparams.CaseSensitiveValue())
|
buildDate, _ := r.envParams.GetEnv("BUILD_DATE", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||||
return buildDate
|
return buildDate
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *reader) GetVcsRef() string {
|
func (r *reader) GetVcsRef() string {
|
||||||
buildDate, _ := p.envParams.GetEnv("VCS_REF", libparams.Default("?"), libparams.CaseSensitiveValue())
|
buildDate, _ := r.envParams.GetEnv("VCS_REF", libparams.Default("?"), libparams.CaseSensitiveValue())
|
||||||
return buildDate
|
return buildDate
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import (
|
|||||||
|
|
||||||
// GetWindscribeRegion obtains the region for the Windscribe server from the
|
// GetWindscribeRegion obtains the region for the Windscribe server from the
|
||||||
// environment variable REGION
|
// environment variable REGION
|
||||||
func (p *reader) GetWindscribeRegion() (region models.WindscribeRegion, err error) {
|
func (r *reader) GetWindscribeRegion() (region models.WindscribeRegion, err error) {
|
||||||
s, err := p.envParams.GetValueIfInside("REGION", constants.WindscribeRegionChoices())
|
s, err := r.envParams.GetValueIfInside("REGION", constants.WindscribeRegionChoices())
|
||||||
return models.WindscribeRegion(strings.ToLower(s)), err
|
return models.WindscribeRegion(strings.ToLower(s)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
// GetMullvadPort obtains the port to reach the Mullvad server on from the
|
||||||
// environment variable PORT
|
// environment variable PORT
|
||||||
func (p *reader) GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error) {
|
func (r *reader) GetWindscribePort(protocol models.NetworkProtocol) (port uint16, err error) {
|
||||||
n, err := p.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
n, err := r.envParams.GetEnvIntRange("PORT", 0, 65535, libparams.Default("0"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user