hotfix(env): read some settings with case sensitivity
This commit is contained in:
2
internal/configuration/sources/env/dns.go
vendored
2
internal/configuration/sources/env/dns.go
vendored
@@ -27,7 +27,7 @@ func (s *Source) readDNS() (dns settings.DNS, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readDNSServerAddress() (address netip.Addr, err error) {
|
||||
key, value := s.getEnvWithRetro("DNS_ADDRESS", "DNS_PLAINTEXT_ADDRESS")
|
||||
key, value := s.getEnvWithRetro("DNS_ADDRESS", []string{"DNS_PLAINTEXT_ADDRESS"})
|
||||
if value == "" {
|
||||
return address, nil
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func (s *Source) readDNSBlacklist() (blacklist settings.DNSBlacklist, err error)
|
||||
}
|
||||
|
||||
func (s *Source) readBlockSurveillance() (blocked *bool, err error) {
|
||||
key, value := s.getEnvWithRetro("BLOCK_SURVEILLANCE", "BLOCK_NSA")
|
||||
key, value := s.getEnvWithRetro("BLOCK_SURVEILLANCE", []string{"BLOCK_NSA"})
|
||||
blocked, err = binary.Validate(value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable %s: %w", key, err)
|
||||
|
||||
@@ -22,7 +22,7 @@ func (s *Source) readFirewall() (firewall settings.Firewall, err error) {
|
||||
return firewall, fmt.Errorf("environment variable FIREWALL_INPUT_PORTS: %w", err)
|
||||
}
|
||||
|
||||
outboundSubnetsKey, _ := s.getEnvWithRetro("FIREWALL_OUTBOUND_SUBNETS", "EXTRA_SUBNETS")
|
||||
outboundSubnetsKey, _ := s.getEnvWithRetro("FIREWALL_OUTBOUND_SUBNETS", []string{"EXTRA_SUBNETS"})
|
||||
outboundSubnetStrings := envToCSV(outboundSubnetsKey)
|
||||
firewall.OutboundSubnets, err = stringsToNetipPrefixes(outboundSubnetStrings)
|
||||
if err != nil {
|
||||
|
||||
4
internal/configuration/sources/env/health.go
vendored
4
internal/configuration/sources/env/health.go
vendored
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func (s *Source) ReadHealth() (health settings.Health, err error) {
|
||||
health.ServerAddress = env.Get("HEALTH_SERVER_ADDRESS")
|
||||
_, health.TargetAddress = s.getEnvWithRetro("HEALTH_TARGET_ADDRESS", "HEALTH_ADDRESS_TO_PING")
|
||||
_, health.TargetAddress = s.getEnvWithRetro("HEALTH_TARGET_ADDRESS", []string{"HEALTH_ADDRESS_TO_PING"})
|
||||
|
||||
successWaitPtr, err := envToDurationPtr("HEALTH_SUCCESS_WAIT_DURATION")
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func (s *Source) ReadHealth() (health settings.Health, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readDurationWithRetro(envKey, retroEnvKey string) (d *time.Duration, err error) {
|
||||
envKey, value := s.getEnvWithRetro(envKey, retroEnvKey)
|
||||
envKey, value := s.getEnvWithRetro(envKey, []string{retroEnvKey})
|
||||
if value == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ func envToFloat64(envKey string) (f float64, err error) {
|
||||
return strconv.ParseFloat(s, bits)
|
||||
}
|
||||
|
||||
func envToStringPtr(envKey string) (stringPtr *string) {
|
||||
s := env.Get(envKey)
|
||||
func envToStringPtr(envKey string, options ...env.Option) (stringPtr *string) {
|
||||
s := env.Get(envKey, options...)
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
16
internal/configuration/sources/env/httproxy.go
vendored
16
internal/configuration/sources/env/httproxy.go
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gosettings/sources/env"
|
||||
"github.com/qdm12/govalid/binary"
|
||||
)
|
||||
|
||||
@@ -31,7 +32,8 @@ func (s *Source) readHTTPProxy() (httpProxy settings.HTTPProxy, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readHTTProxyUser() (user *string) {
|
||||
_, value := s.getEnvWithRetro("HTTPPROXY_USER", "PROXY_USER", "TINYPROXY_USER")
|
||||
_, value := s.getEnvWithRetro("HTTPPROXY_USER",
|
||||
[]string{"PROXY_USER", "TINYPROXY_USER"}, env.ForceLowercase(false))
|
||||
if value != "" {
|
||||
return &value
|
||||
}
|
||||
@@ -39,7 +41,8 @@ func (s *Source) readHTTProxyUser() (user *string) {
|
||||
}
|
||||
|
||||
func (s *Source) readHTTProxyPassword() (user *string) {
|
||||
_, value := s.getEnvWithRetro("HTTPPROXY_PASSWORD", "PROXY_PASSWORD", "TINYPROXY_PASSWORD")
|
||||
_, value := s.getEnvWithRetro("HTTPPROXY_PASSWORD",
|
||||
[]string{"PROXY_PASSWORD", "TINYPROXY_PASSWORD"}, env.ForceLowercase(false))
|
||||
if value != "" {
|
||||
return &value
|
||||
}
|
||||
@@ -47,7 +50,8 @@ func (s *Source) readHTTProxyPassword() (user *string) {
|
||||
}
|
||||
|
||||
func (s *Source) readHTTProxyListeningAddress() (listeningAddress string) {
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY_LISTENING_ADDRESS", "PROXY_PORT", "TINYPROXY_PORT", "HTTPPROXY_PORT")
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY_LISTENING_ADDRESS",
|
||||
[]string{"PROXY_PORT", "TINYPROXY_PORT", "HTTPPROXY_PORT"})
|
||||
if key == "HTTPPROXY_LISTENING_ADDRESS" {
|
||||
return value
|
||||
}
|
||||
@@ -55,7 +59,8 @@ func (s *Source) readHTTProxyListeningAddress() (listeningAddress string) {
|
||||
}
|
||||
|
||||
func (s *Source) readHTTProxyEnabled() (enabled *bool, err error) {
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY", "PROXY", "TINYPROXY")
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY",
|
||||
[]string{"PROXY", "TINYPROXY"})
|
||||
enabled, err = binary.Validate(value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable %s: %w", key, err)
|
||||
@@ -65,7 +70,8 @@ func (s *Source) readHTTProxyEnabled() (enabled *bool, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readHTTProxyLog() (enabled *bool, err error) {
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY_LOG", "PROXY_LOG_LEVEL", "TINYPROXY_LOG")
|
||||
key, value := s.getEnvWithRetro("HTTPPROXY_LOG",
|
||||
[]string{"PROXY_LOG_LEVEL", "TINYPROXY_LOG"})
|
||||
|
||||
var binaryOptions []binary.Option
|
||||
if key != "HTTPROXY_LOG" {
|
||||
|
||||
26
internal/configuration/sources/env/openvpn.go
vendored
26
internal/configuration/sources/env/openvpn.go
vendored
@@ -24,7 +24,7 @@ func (s *Source) readOpenVPN() (
|
||||
openVPN.ConfFile = &confFile
|
||||
}
|
||||
|
||||
ciphersKey, _ := s.getEnvWithRetro("OPENVPN_CIPHERS", "OPENVPN_CIPHER")
|
||||
ciphersKey, _ := s.getEnvWithRetro("OPENVPN_CIPHERS", []string{"OPENVPN_CIPHER"})
|
||||
openVPN.Ciphers = envToCSV(ciphersKey)
|
||||
|
||||
auth := env.Get("OPENVPN_AUTH")
|
||||
@@ -32,9 +32,9 @@ func (s *Source) readOpenVPN() (
|
||||
openVPN.Auth = &auth
|
||||
}
|
||||
|
||||
openVPN.Cert = envToStringPtr("OPENVPN_CERT")
|
||||
openVPN.Key = envToStringPtr("OPENVPN_KEY")
|
||||
openVPN.EncryptedKey = envToStringPtr("OPENVPN_ENCRYPTED_KEY")
|
||||
openVPN.Cert = envToStringPtr("OPENVPN_CERT", env.ForceLowercase(false))
|
||||
openVPN.Key = envToStringPtr("OPENVPN_KEY", env.ForceLowercase(false))
|
||||
openVPN.EncryptedKey = envToStringPtr("OPENVPN_ENCRYPTED_KEY", env.ForceLowercase(false))
|
||||
|
||||
openVPN.KeyPassphrase = s.readOpenVPNKeyPassphrase()
|
||||
|
||||
@@ -45,7 +45,8 @@ func (s *Source) readOpenVPN() (
|
||||
return openVPN, fmt.Errorf("environment variable OPENVPN_MSSFIX: %w", err)
|
||||
}
|
||||
|
||||
_, openVPN.Interface = s.getEnvWithRetro("VPN_INTERFACE", "OPENVPN_INTERFACE")
|
||||
_, openVPN.Interface = s.getEnvWithRetro("VPN_INTERFACE",
|
||||
[]string{"OPENVPN_INTERFACE"}, env.ForceLowercase(false))
|
||||
|
||||
openVPN.ProcessUser, err = s.readOpenVPNProcessUser()
|
||||
if err != nil {
|
||||
@@ -57,7 +58,7 @@ func (s *Source) readOpenVPN() (
|
||||
return openVPN, fmt.Errorf("environment variable OPENVPN_VERBOSITY: %w", err)
|
||||
}
|
||||
|
||||
flagsStr := env.Get("OPENVPN_FLAGS")
|
||||
flagsStr := env.Get("OPENVPN_FLAGS", env.ForceLowercase(false))
|
||||
if flagsStr != "" {
|
||||
openVPN.Flags = strings.Fields(flagsStr)
|
||||
}
|
||||
@@ -67,7 +68,8 @@ func (s *Source) readOpenVPN() (
|
||||
|
||||
func (s *Source) readOpenVPNUser() (user *string) {
|
||||
user = new(string)
|
||||
_, *user = s.getEnvWithRetro("OPENVPN_USER", "USER")
|
||||
_, *user = s.getEnvWithRetro("OPENVPN_USER",
|
||||
[]string{"USER"}, env.ForceLowercase(false))
|
||||
if *user == "" {
|
||||
return nil
|
||||
}
|
||||
@@ -79,7 +81,8 @@ func (s *Source) readOpenVPNUser() (user *string) {
|
||||
|
||||
func (s *Source) readOpenVPNPassword() (password *string) {
|
||||
password = new(string)
|
||||
_, *password = s.getEnvWithRetro("OPENVPN_PASSWORD", "PASSWORD")
|
||||
_, *password = s.getEnvWithRetro("OPENVPN_PASSWORD",
|
||||
[]string{"PASSWORD"}, env.ForceLowercase(false))
|
||||
if *password == "" {
|
||||
return nil
|
||||
}
|
||||
@@ -89,7 +92,7 @@ func (s *Source) readOpenVPNPassword() (password *string) {
|
||||
|
||||
func (s *Source) readOpenVPNKeyPassphrase() (passphrase *string) {
|
||||
passphrase = new(string)
|
||||
*passphrase = env.Get("OPENVPN_KEY_PASSPHRASE")
|
||||
*passphrase = env.Get("OPENVPN_KEY_PASSPHRASE", env.ForceLowercase(false))
|
||||
if *passphrase == "" {
|
||||
return nil
|
||||
}
|
||||
@@ -99,7 +102,7 @@ func (s *Source) readOpenVPNKeyPassphrase() (passphrase *string) {
|
||||
func (s *Source) readPIAEncryptionPreset() (presetPtr *string) {
|
||||
_, preset := s.getEnvWithRetro(
|
||||
"PRIVATE_INTERNET_ACCESS_OPENVPN_ENCRYPTION_PRESET",
|
||||
"PIA_ENCRYPTION", "ENCRYPTION")
|
||||
[]string{"PIA_ENCRYPTION", "ENCRYPTION"})
|
||||
if preset != "" {
|
||||
return &preset
|
||||
}
|
||||
@@ -107,7 +110,8 @@ func (s *Source) readPIAEncryptionPreset() (presetPtr *string) {
|
||||
}
|
||||
|
||||
func (s *Source) readOpenVPNProcessUser() (processUser string, err error) {
|
||||
key, value := s.getEnvWithRetro("OPENVPN_PROCESS_USER", "OPENVPN_ROOT")
|
||||
key, value := s.getEnvWithRetro("OPENVPN_PROCESS_USER",
|
||||
[]string{"OPENVPN_ROOT"})
|
||||
if key == "OPENVPN_PROCESS_USER" {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func (s *Source) readOpenVPNSelection() (
|
||||
selection settings.OpenVPNSelection, err error) {
|
||||
confFile := env.Get("OPENVPN_CUSTOM_CONFIG")
|
||||
confFile := env.Get("OPENVPN_CUSTOM_CONFIG", env.ForceLowercase(false))
|
||||
if confFile != "" {
|
||||
selection.ConfFile = &confFile
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func (s *Source) readOpenVPNSelection() (
|
||||
var ErrOpenVPNProtocolNotValid = errors.New("OpenVPN protocol is not valid")
|
||||
|
||||
func (s *Source) readOpenVPNProtocol() (tcp *bool, err error) {
|
||||
envKey, protocol := s.getEnvWithRetro("OPENVPN_PROTOCOL", "PROTOCOL")
|
||||
envKey, protocol := s.getEnvWithRetro("OPENVPN_PROTOCOL", []string{"PROTOCOL"})
|
||||
|
||||
switch strings.ToLower(protocol) {
|
||||
case "":
|
||||
@@ -52,7 +52,7 @@ func (s *Source) readOpenVPNProtocol() (tcp *bool, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readOpenVPNCustomPort() (customPort *uint16, err error) {
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_PORT", "PORT", "OPENVPN_PORT")
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_PORT", []string{"PORT", "OPENVPN_PORT"})
|
||||
if value == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
@@ -4,23 +4,26 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gosettings/sources/env"
|
||||
)
|
||||
|
||||
func (s *Source) readPortForward() (
|
||||
portForwarding settings.PortForwarding, err error) {
|
||||
key, _ := s.getEnvWithRetro(
|
||||
"VPN_PORT_FORWARDING",
|
||||
key, _ := s.getEnvWithRetro("VPN_PORT_FORWARDING",
|
||||
[]string{
|
||||
"PRIVATE_INTERNET_ACCESS_VPN_PORT_FORWARDING",
|
||||
"PORT_FORWARDING")
|
||||
"PORT_FORWARDING",
|
||||
})
|
||||
portForwarding.Enabled, err = envToBoolPtr(key)
|
||||
if err != nil {
|
||||
return portForwarding, fmt.Errorf("environment variable %s: %w", key, err)
|
||||
}
|
||||
|
||||
_, value := s.getEnvWithRetro(
|
||||
"VPN_PORT_FORWARDING_STATUS_FILE",
|
||||
_, value := s.getEnvWithRetro("VPN_PORT_FORWARDING_STATUS_FILE",
|
||||
[]string{
|
||||
"PRIVATE_INTERNET_ACCESS_VPN_PORT_FORWARDING_STATUS_FILE",
|
||||
"PORT_FORWARDING_STATUS_FILE")
|
||||
"PORT_FORWARDING_STATUS_FILE",
|
||||
}, env.ForceLowercase(false))
|
||||
if value != "" {
|
||||
portForwarding.Filepath = stringPtr(value)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (s *Source) readProvider(vpnType string) (provider settings.Provider, err e
|
||||
}
|
||||
|
||||
func (s *Source) readVPNServiceProvider(vpnType string) (vpnProviderPtr *string) {
|
||||
_, value := s.getEnvWithRetro("VPN_SERVICE_PROVIDER", "VPNSP")
|
||||
_, value := s.getEnvWithRetro("VPN_SERVICE_PROVIDER", []string{"VPNSP"})
|
||||
if value == "" {
|
||||
if vpnType != vpn.Wireguard && env.Get("OPENVPN_CUSTOM_CONFIG") != "" {
|
||||
// retro compatibility
|
||||
|
||||
@@ -35,7 +35,8 @@ func readPublicIPPeriod() (period *time.Duration, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readPublicIPFilepath() (filepath *string) {
|
||||
_, value := s.getEnvWithRetro("PUBLICIP_FILE", "IP_STATUS_FILE")
|
||||
_, value := s.getEnvWithRetro("PUBLICIP_FILE",
|
||||
[]string{"IP_STATUS_FILE"}, env.ForceLowercase(false))
|
||||
if value != "" {
|
||||
return &value
|
||||
}
|
||||
|
||||
6
internal/configuration/sources/env/reader.go
vendored
6
internal/configuration/sources/env/reader.go
vendored
@@ -103,16 +103,16 @@ func (s *Source) onRetroActive(oldKey, newKey string) {
|
||||
// Note retroKeys should be in order from oldest to most
|
||||
// recent retro-compatibility key.
|
||||
func (s *Source) getEnvWithRetro(currentKey string,
|
||||
retroKeys ...string) (key, value string) {
|
||||
retroKeys []string, options ...env.Option) (key, value string) {
|
||||
// We check retro-compatibility keys first since
|
||||
// the current key might be set in the Dockerfile.
|
||||
for _, key = range retroKeys {
|
||||
value = env.Get(key)
|
||||
value = env.Get(key, options...)
|
||||
if value != "" {
|
||||
s.onRetroActive(key, currentKey)
|
||||
return key, value
|
||||
}
|
||||
}
|
||||
|
||||
return currentKey, env.Get(currentKey)
|
||||
return currentKey, env.Get(currentKey, options...)
|
||||
}
|
||||
|
||||
3
internal/configuration/sources/env/server.go
vendored
3
internal/configuration/sources/env/server.go
vendored
@@ -29,7 +29,8 @@ func readControlServerLog() (enabled *bool, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readControlServerAddress() (address *string) {
|
||||
key, value := s.getEnvWithRetro("HTTP_CONTROL_SERVER_ADDRESS", "HTTP_CONTROL_SERVER_PORT")
|
||||
key, value := s.getEnvWithRetro("HTTP_CONTROL_SERVER_ADDRESS",
|
||||
[]string{"CONTROL_SERVER_ADDRESS"})
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (s *Source) readServerSelection(vpnProvider, vpnType string) (
|
||||
return ss, err
|
||||
}
|
||||
|
||||
countriesKey, _ := s.getEnvWithRetro("SERVER_COUNTRIES", "COUNTRY")
|
||||
countriesKey, _ := s.getEnvWithRetro("SERVER_COUNTRIES", []string{"COUNTRY"})
|
||||
ss.Countries = envToCSV(countriesKey)
|
||||
if vpnProvider == providers.Cyberghost && len(ss.Countries) == 0 {
|
||||
// Retro-compatibility for Cyberghost using the REGION variable
|
||||
@@ -35,18 +35,18 @@ func (s *Source) readServerSelection(vpnProvider, vpnType string) (
|
||||
}
|
||||
}
|
||||
|
||||
regionsKey, _ := s.getEnvWithRetro("SERVER_REGIONS", "REGION")
|
||||
regionsKey, _ := s.getEnvWithRetro("SERVER_REGIONS", []string{"REGION"})
|
||||
ss.Regions = envToCSV(regionsKey)
|
||||
|
||||
citiesKey, _ := s.getEnvWithRetro("SERVER_CITIES", "CITY")
|
||||
citiesKey, _ := s.getEnvWithRetro("SERVER_CITIES", []string{"CITY"})
|
||||
ss.Cities = envToCSV(citiesKey)
|
||||
|
||||
ss.ISPs = envToCSV("ISP")
|
||||
|
||||
hostnamesKey, _ := s.getEnvWithRetro("SERVER_HOSTNAMES", "SERVER_HOSTNAME")
|
||||
hostnamesKey, _ := s.getEnvWithRetro("SERVER_HOSTNAMES", []string{"SERVER_HOSTNAME"})
|
||||
ss.Hostnames = envToCSV(hostnamesKey)
|
||||
|
||||
serverNamesKey, _ := s.getEnvWithRetro("SERVER_NAMES", "SERVER_NAME")
|
||||
serverNamesKey, _ := s.getEnvWithRetro("SERVER_NAMES", []string{"SERVER_NAME"})
|
||||
ss.Names = envToCSV(serverNamesKey)
|
||||
|
||||
if csv := env.Get("SERVER_NUMBER"); csv != "" {
|
||||
@@ -115,7 +115,7 @@ var (
|
||||
)
|
||||
|
||||
func (s *Source) readOpenVPNTargetIP() (ip netip.Addr, err error) {
|
||||
envKey, value := s.getEnvWithRetro("VPN_ENDPOINT_IP", "OPENVPN_TARGET_IP")
|
||||
envKey, value := s.getEnvWithRetro("VPN_ENDPOINT_IP", []string{"OPENVPN_TARGET_IP"})
|
||||
if value == "" {
|
||||
return ip, nil
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func (s *Source) readOpenVPNTargetIP() (ip netip.Addr, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readOwnedOnly() (ownedOnly *bool, err error) {
|
||||
envKey, _ := s.getEnvWithRetro("OWNED_ONLY", "OWNED")
|
||||
envKey, _ := s.getEnvWithRetro("OWNED_ONLY", []string{"OWNED"})
|
||||
ownedOnly, err = envToBoolPtr(envKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable %s: %w", envKey, err)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gosettings/sources/env"
|
||||
)
|
||||
|
||||
func (s *Source) readShadowsocks() (shadowsocks settings.Shadowsocks, err error) {
|
||||
@@ -19,13 +20,14 @@ func (s *Source) readShadowsocks() (shadowsocks settings.Shadowsocks, err error)
|
||||
return shadowsocks, fmt.Errorf("environment variable SHADOWSOCKS_LOG: %w", err)
|
||||
}
|
||||
shadowsocks.CipherName = s.readShadowsocksCipher()
|
||||
shadowsocks.Password = envToStringPtr("SHADOWSOCKS_PASSWORD")
|
||||
shadowsocks.Password = envToStringPtr("SHADOWSOCKS_PASSWORD", env.ForceLowercase(false))
|
||||
|
||||
return shadowsocks, nil
|
||||
}
|
||||
|
||||
func (s *Source) readShadowsocksAddress() (address string) {
|
||||
key, value := s.getEnvWithRetro("SHADOWSOCKS_LISTENING_ADDRESS", "SHADOWSOCKS_PORT")
|
||||
key, value := s.getEnvWithRetro("SHADOWSOCKS_LISTENING_ADDRESS",
|
||||
[]string{"SHADOWSOCKS_PORT"})
|
||||
if value == "" {
|
||||
return ""
|
||||
}
|
||||
@@ -39,6 +41,7 @@ func (s *Source) readShadowsocksAddress() (address string) {
|
||||
}
|
||||
|
||||
func (s *Source) readShadowsocksCipher() (cipher string) {
|
||||
_, cipher = s.getEnvWithRetro("SHADOWSOCKS_CIPHER", "SHADOWSOCKS_METHOD")
|
||||
_, cipher = s.getEnvWithRetro("SHADOWSOCKS_CIPHER",
|
||||
[]string{"SHADOWSOCKS_METHOD"})
|
||||
return strings.ToLower(cipher)
|
||||
}
|
||||
|
||||
2
internal/configuration/sources/env/system.go
vendored
2
internal/configuration/sources/env/system.go
vendored
@@ -35,7 +35,7 @@ var ErrSystemIDNotValid = errors.New("system ID is not valid")
|
||||
|
||||
func (s *Source) readID(key, retroKey string) (
|
||||
id *uint32, err error) {
|
||||
idEnvKey, idString := s.getEnvWithRetro(key, retroKey)
|
||||
idEnvKey, idString := s.getEnvWithRetro(key, []string{retroKey})
|
||||
if idString == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
10
internal/configuration/sources/env/wireguard.go
vendored
10
internal/configuration/sources/env/wireguard.go
vendored
@@ -13,9 +13,10 @@ func (s *Source) readWireguard() (wireguard settings.Wireguard, err error) {
|
||||
defer func() {
|
||||
err = unsetEnvKeys([]string{"WIREGUARD_PRIVATE_KEY", "WIREGUARD_PRESHARED_KEY"}, err)
|
||||
}()
|
||||
wireguard.PrivateKey = envToStringPtr("WIREGUARD_PRIVATE_KEY")
|
||||
wireguard.PreSharedKey = envToStringPtr("WIREGUARD_PRESHARED_KEY")
|
||||
_, wireguard.Interface = s.getEnvWithRetro("VPN_INTERFACE", "WIREGUARD_INTERFACE")
|
||||
wireguard.PrivateKey = envToStringPtr("WIREGUARD_PRIVATE_KEY", env.ForceLowercase(false))
|
||||
wireguard.PreSharedKey = envToStringPtr("WIREGUARD_PRESHARED_KEY", env.ForceLowercase(false))
|
||||
_, wireguard.Interface = s.getEnvWithRetro("VPN_INTERFACE",
|
||||
[]string{"WIREGUARD_INTERFACE"}, env.ForceLowercase(false))
|
||||
wireguard.Implementation = env.Get("WIREGUARD_IMPLEMENTATION")
|
||||
wireguard.Addresses, err = s.readWireguardAddresses()
|
||||
if err != nil {
|
||||
@@ -31,7 +32,8 @@ func (s *Source) readWireguard() (wireguard settings.Wireguard, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readWireguardAddresses() (addresses []netip.Prefix, err error) {
|
||||
key, addressesCSV := s.getEnvWithRetro("WIREGUARD_ADDRESSES", "WIREGUARD_ADDRESS")
|
||||
key, addressesCSV := s.getEnvWithRetro("WIREGUARD_ADDRESSES",
|
||||
[]string{"WIREGUARD_ADDRESS"})
|
||||
if addressesCSV == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ func (s *Source) readWireguardSelection() (
|
||||
return selection, err
|
||||
}
|
||||
|
||||
selection.PublicKey = env.Get("WIREGUARD_PUBLIC_KEY")
|
||||
selection.PublicKey = env.Get("WIREGUARD_PUBLIC_KEY", env.ForceLowercase(false))
|
||||
|
||||
return selection, nil
|
||||
}
|
||||
|
||||
func (s *Source) readWireguardEndpointIP() (endpointIP netip.Addr, err error) {
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_IP", "WIREGUARD_ENDPOINT_IP")
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_IP", []string{"WIREGUARD_ENDPOINT_IP"})
|
||||
if value == "" {
|
||||
return endpointIP, nil
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func (s *Source) readWireguardEndpointIP() (endpointIP netip.Addr, err error) {
|
||||
}
|
||||
|
||||
func (s *Source) readWireguardCustomPort() (customPort *uint16, err error) {
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_PORT", "WIREGUARD_ENDPOINT_PORT")
|
||||
key, value := s.getEnvWithRetro("VPN_ENDPOINT_PORT", []string{"WIREGUARD_ENDPOINT_PORT"})
|
||||
if value == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user