include prefix for all environment variables
All checks were successful
CI / build (push) Successful in 1m4s
All checks were successful
CI / build (push) Successful in 1m4s
This commit is contained in:
parent
f66aa3efa6
commit
6f4567df0c
1 changed files with 20 additions and 14 deletions
|
@ -163,6 +163,12 @@ func beforeProxy(next http.HandlerFunc) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getenv(key string) string {
|
||||||
|
// `YTPROXY_` as a prefix
|
||||||
|
v, _ := syscall.Getenv("YTPROXY_" + key)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
defaultHost := "0.0.0.0"
|
defaultHost := "0.0.0.0"
|
||||||
defaultPort := "8080"
|
defaultPort := "8080"
|
||||||
|
@ -175,55 +181,55 @@ func main() {
|
||||||
var ipv6 bool = false
|
var ipv6 bool = false
|
||||||
var bc bool = true
|
var bc bool = true
|
||||||
|
|
||||||
if strings.ToLower(os.Getenv("HTTPS")) == "true" {
|
if strings.ToLower(getenv("HTTPS")) == "true" {
|
||||||
https = true
|
https = true
|
||||||
}
|
}
|
||||||
if strings.ToLower(os.Getenv("H3C")) == "true" {
|
if strings.ToLower(getenv("H3C")) == "true" {
|
||||||
h3c = true
|
h3c = true
|
||||||
}
|
}
|
||||||
if strings.ToLower(os.Getenv("H3S")) == "true" {
|
if strings.ToLower(getenv("H3S")) == "true" {
|
||||||
h3s = true
|
h3s = true
|
||||||
}
|
}
|
||||||
if strings.ToLower(os.Getenv("IPV6_ONLY")) == "true" {
|
if strings.ToLower(getenv("IPV6_ONLY")) == "true" {
|
||||||
ipv6 = true
|
ipv6 = true
|
||||||
}
|
}
|
||||||
if strings.ToLower(os.Getenv("BLOCK_CHECKER")) == "false" {
|
if strings.ToLower(getenv("BLOCK_CHECKER")) == "false" {
|
||||||
bc = false
|
bc = false
|
||||||
}
|
}
|
||||||
if strings.ToLower(os.Getenv("DOMAIN_ONLY_ACCESS")) == "true" {
|
if strings.ToLower(getenv("DOMAIN_ONLY_ACCESS")) == "true" {
|
||||||
domain_only_access = true
|
domain_only_access = true
|
||||||
}
|
}
|
||||||
|
|
||||||
tls_cert := os.Getenv("TLS_CERT")
|
tls_cert := getenv("TLS_CERT")
|
||||||
if tls_cert == "" {
|
if tls_cert == "" {
|
||||||
tls_cert = defaultTLSCert
|
tls_cert = defaultTLSCert
|
||||||
}
|
}
|
||||||
tls_key := os.Getenv("TLS_KEY")
|
tls_key := getenv("TLS_KEY")
|
||||||
if tls_key == "" {
|
if tls_key == "" {
|
||||||
tls_key = defaultTLSKey
|
tls_key = defaultTLSKey
|
||||||
}
|
}
|
||||||
sock := os.Getenv("SOCK_PATH")
|
sock := getenv("SOCK_PATH")
|
||||||
if sock == "" {
|
if sock == "" {
|
||||||
sock = defaultSock
|
sock = defaultSock
|
||||||
}
|
}
|
||||||
port := os.Getenv("PORT")
|
port := getenv("PORT")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = defaultPort
|
port = defaultPort
|
||||||
}
|
}
|
||||||
host := os.Getenv("HOST")
|
host := getenv("HOST")
|
||||||
if host == "" {
|
if host == "" {
|
||||||
host = defaultHost
|
host = defaultHost
|
||||||
}
|
}
|
||||||
// gh is where the gluetun api is located
|
// gh is where the gluetun api is located
|
||||||
gh := os.Getenv("GLUETUN_HOSTNAME")
|
gh := getenv("GLUETUN_HOSTNAME")
|
||||||
if gh == "" {
|
if gh == "" {
|
||||||
gh = "127.0.0.1:8000"
|
gh = "127.0.0.1:8000"
|
||||||
}
|
}
|
||||||
bc_cooldown := os.Getenv("BLOCK_CHECKER_COOLDOWN")
|
bc_cooldown := getenv("BLOCK_CHECKER_COOLDOWN")
|
||||||
if bc_cooldown == "" {
|
if bc_cooldown == "" {
|
||||||
bc_cooldown = "60"
|
bc_cooldown = "60"
|
||||||
}
|
}
|
||||||
httpc.Proxy = os.Getenv("PROXY")
|
httpc.Proxy = getenv("PROXY")
|
||||||
|
|
||||||
flag.BoolVar(&https, "https", https, "Use built-in https server (recommended)")
|
flag.BoolVar(&https, "https", https, "Use built-in https server (recommended)")
|
||||||
flag.BoolVar(&h3c, "h3c", h3c, "Use HTTP/3 for client requests (high CPU usage)")
|
flag.BoolVar(&h3c, "h3c", h3c, "Use HTTP/3 for client requests (high CPU usage)")
|
||||||
|
|
Loading…
Add table
Reference in a new issue