- `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`
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package env
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
|
)
|
|
|
|
func (r *Reader) ReadHealth() (health settings.Health, err error) {
|
|
health.ServerAddress = os.Getenv("HEALTH_SERVER_ADDRESS")
|
|
health.AddressToPing = os.Getenv("HEALTH_ADDRESS_TO_PING")
|
|
|
|
health.VPN.Initial, err = r.readDurationWithRetro(
|
|
"HEALTH_VPN_DURATION_INITIAL",
|
|
"HEALTH_OPENVPN_DURATION_INITIAL")
|
|
if err != nil {
|
|
return health, err
|
|
}
|
|
|
|
health.VPN.Initial, err = r.readDurationWithRetro(
|
|
"HEALTH_VPN_DURATION_ADDITION",
|
|
"HEALTH_OPENVPN_DURATION_ADDITION")
|
|
if err != nil {
|
|
return health, err
|
|
}
|
|
|
|
return health, nil
|
|
}
|
|
|
|
func (r *Reader) readDurationWithRetro(envKey, retroEnvKey string) (d *time.Duration, err error) {
|
|
s := os.Getenv(retroEnvKey)
|
|
if s == "" {
|
|
s = os.Getenv(envKey)
|
|
if s == "" {
|
|
return nil, nil //nolint:nilnil
|
|
}
|
|
} else {
|
|
r.onRetroActive(envKey, retroEnvKey)
|
|
envKey = retroEnvKey
|
|
}
|
|
|
|
d = new(time.Duration)
|
|
*d, err = time.ParseDuration(s)
|
|
if err != nil {
|
|
return nil, fmt.Errorf(
|
|
"environment variable %s: %w",
|
|
envKey, err)
|
|
}
|
|
|
|
return d, nil
|
|
}
|