Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Envirnoment variabel for the --cache flag (STAYRTR_CACHE) #130

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (if blank, will use envvar %v"", 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)")
Expand Down Expand Up @@ -756,6 +759,10 @@ func run() error {
s.fetchConfig.EnableEtags = *Etag
s.fetchConfig.EnableLastModified = *LastModified

if *CacheBin == DEFAULT_CACHE && os.Getenv(ENV_CACHE) != "" {
*CacheBin = os.Getenv(ENV_CACHE)
}

if enableHTTP {
if *ExportPath != "" {
http.HandleFunc(*ExportPath, s.exporter)
Expand Down