fix(env): Retro-compatible precedence order for variables with defaults set in Dockerfile

- `BLOCK_NSA` has precedence over `BLOCK_SURVEILLANCE`
- `HEALTH_OPENVPN_DURATION_ADDITION` has precedence over `HEALTH_VPN_DURATION_ADDITION`
- `HEALTH_OPENVPN_DURATION_INITIAL` has precendence over `HEALTH_VPN_DURATION_INITIAL`
- Chain of precedence: `PROXY` > `TINYPROXY` > `HTTPPROXY`
- Chain of precedence: `PROXY_LOG_LEVEL` > `TINYPROXY_LOG` > `HTTPPROXY_LOG`
- `PROTOCOL` has precendence over `OPENVPN_PROTOCOL`
- `IP_STATUS_FILE` has precendence over `PUBLICIP_FILE`
- `SHADOWSOCKS_PORT` has precedence over `SHADOWSOCKS_LISTENING_ADDRESS`
- `SHADOWSOCKS_METHOD` has precedence over `SHADOWSOCKS_CIPHER`
This commit is contained in:
Quentin McGaw
2022-01-29 14:54:47 +00:00
parent fd23f1a29b
commit e7e4cfca4c
6 changed files with 43 additions and 47 deletions

View File

@@ -36,16 +36,17 @@ func (r *Reader) readOpenVPNSelection() (
var ErrOpenVPNProtocolNotValid = errors.New("OpenVPN protocol is not valid")
func (r *Reader) readOpenVPNProtocol() (tcp *bool, err error) {
envKey := "OPENVPN_PROTOCOL"
protocol := strings.ToLower(os.Getenv("OPENVPN_PROTOCOL"))
if protocol == "" {
// Retro-compatibility
protocol = strings.ToLower(os.Getenv("PROTOCOL"))
envKey := "PROTOCOL"
protocol := strings.ToLower(os.Getenv("PROTOCOL"))
if protocol == "" {
protocol = strings.ToLower(os.Getenv("OPENVPN_PROTOCOL"))
if protocol != "" {
envKey = "PROTOCOL"
envKey = "OPENVPN_PROTOCOL"
}
} else {
r.onRetroActive("PROTOCOL", "OPENVPN_PROTOCOL")
}
}
switch protocol {
case "":