From fc73a7f85e99028066adc98192dc113551e1c51e Mon Sep 17 00:00:00 2001 From: Tim de Boer Date: Thu, 26 Sep 2024 22:55:45 +0200 Subject: [PATCH] Added Envirnoment variabel for the --cache flag (STAYRTR_CACHE) --- cmd/stayrtr/stayrtr.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/stayrtr/stayrtr.go b/cmd/stayrtr/stayrtr.go index ce030f7..4092fec 100644 --- a/cmd/stayrtr/stayrtr.go +++ b/cmd/stayrtr/stayrtr.go @@ -31,9 +31,12 @@ import ( ) const ( + ENV_CACHE = "STAYRTR_CACHE" ENV_SSH_PASSWORD = "STAYRTR_SSH_PASSWORD" ENV_SSH_KEY = "STAYRTR_SSH_AUTHORIZEDKEYS" + DEFAULT_CACHE = "https://console.rpki-client.org/rpki.json" + METHOD_NONE = iota METHOD_PASSWORD METHOD_KEY @@ -80,7 +83,7 @@ var ( TimeCheck = flag.Bool("checktime", true, "Check if JSON file isn't stale (disable by passing -checktime=false)") - CacheBin = flag.String("cache", "https://console.rpki-client.org/rpki.json", "URL of the Validated RPKI data in JSON format") + CacheBin = flag.String("cache", DEFAULT_CACHE, fmt.Sprintf("URL of the Validated RPKI data in JSON format", ENV_CACHE)) Etag = flag.Bool("etag", true, "Control usage of Etag header (disable with -etag=false)") LastModified = flag.Bool("last.modified", true, "Control usage of Last-Modified header (disable with -last.modified=false)") @@ -756,6 +759,11 @@ func run() error { s.fetchConfig.EnableEtags = *Etag s.fetchConfig.EnableLastModified = *LastModified + cache := *CacheBin + if cache == DEFAULT_CACHE { + cache = os.Getenv(ENV_CACHE) + } + if enableHTTP { if *ExportPath != "" { http.HandleFunc(*ExportPath, s.exporter)