From 0a9d28a105dca4635ce6f0a40ee69538b9c87dad Mon Sep 17 00:00:00 2001 From: iacore Date: Thu, 5 Sep 2024 17:26:50 +0000 Subject: [PATCH] document the change in format of PROXY_CHECKER_INTERVAL clean up --- config/config.go | 11 ++++------- config/constants.go | 1 - doc/environment-variables.md | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/config/config.go b/config/config.go index 25c4133..1d98a08 100644 --- a/config/config.go +++ b/config/config.go @@ -33,10 +33,9 @@ type ServerConfig struct { RequestLimit int `env:"PIXIVFE_REQUESTLIMIT"` // if 0, request limit is disabled ProxyServer_staging string `env:"PIXIVFE_IMAGEPROXY,overwrite"` - ProxyServer url.URL // proxy server, may contain prefix as well + ProxyServer url.URL // proxy server URL, may or may not contain authority part of the URL - ProxyCheckInterval_staging int `env:"PIXIVFE_PROXY_CHECK_INTERVAL,overwrite"` - ProxyCheckInterval time.Duration // Proxy check interval + ProxyCheckInterval time.Duration `env:"PIXIVFE_PROXY_CHECK_INTERVAL,overwrite"` } func (s *ServerConfig) LoadConfig() error { @@ -49,7 +48,7 @@ func (s *ServerConfig) LoadConfig() error { s.UserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0" s.AcceptLanguage = "en-US,en;q=0.5" s.ProxyServer_staging = BuiltinProxyUrl - s.ProxyCheckInterval_staging = 480 + s.ProxyCheckInterval = 8 * time.Hour // load config from from env vars if err := envconfig.Process(context.Background(), s); err != nil { @@ -74,9 +73,7 @@ func (s *ServerConfig) LoadConfig() error { log.Panicf("proxy server path (%s) has cannot end in /: %s\nPixivFE does not support this now, sorry", proxyUrl.Path, proxyUrl.String()) } } - log.Printf("Set %s to: %s\n", "proxy server", &s.ProxyServer) - - s.ProxyCheckInterval = time.Duration(s.ProxyCheckInterval_staging) * time.Minute + log.Printf("Proxy server set to: %s\n", s.ProxyServer.String()) log.Printf("Proxy check interval set to: %v\n", s.ProxyCheckInterval) return nil diff --git a/config/constants.go b/config/constants.go index 2a3b70c..472eb23 100644 --- a/config/constants.go +++ b/config/constants.go @@ -3,5 +3,4 @@ package config import "time" // todo: make this configurable -const ExpiresIn = 5 * time.Minute const ProxyCheckerTimeout = 10 * time.Second diff --git a/doc/environment-variables.md b/doc/environment-variables.md index e60aa87..e1f0c07 100644 --- a/doc/environment-variables.md +++ b/doc/environment-variables.md @@ -90,9 +90,10 @@ The value of the `Accept-Language` header used for requests to Pixiv's API. Chan **Required**: No -**Default:** `480` +**Default:** `8h` -The interval in minutes between proxy checks. Defaults to 480 minutes (8 hours) if not set. +The interval in minutes between proxy checks. Defaults to 8 hours if not set. +Please specify this value in Go's `time.Duration` notation, e.g. `2h3m5s`. You can disable this by setting the value to 0. Then, proxies will only be checked once at server initialization. ### `PIXIVFE_DEV`