From 8acd8591a8be49c1303560526d280c6810702a6e Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 9 Nov 2021 23:03:12 +0100 Subject: allow to set api via env var --- README.rst | 2 +- main.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index f5b2896..e7e81ea 100644 --- a/README.rst +++ b/README.rst @@ -27,7 +27,7 @@ You can use ``geoipupdate`` to download MaxMind's City database:: Usage ----------------------- -api - domain for the api. Default: black.riseup.net + domain for the api. Default: black.riseup.net. It can be also set via MENSHEN_API env var. -geodb path to the GeoLite2-City database (default is "/var/lib/GeoIP/GeoLite2-City.mmdb") -port diff --git a/main.go b/main.go index 0c21c7c..a0da1da 100644 --- a/main.go +++ b/main.go @@ -243,10 +243,16 @@ func main() { } var configuredAPI string - if *api == "" { - configuredAPI = apiForRiseup + envAPI := os.Getenv("MENSHEN_API") + if envAPI != "" { + log.Println("MENSHEN_API = " + envAPI) + configuredAPI = "https://" + envAPI } else { - configuredAPI = "https://" + *api + if *api == "" { + configuredAPI = apiForRiseup + } else { + configuredAPI = "https://" + *api + } } db, err := geoip2.Open(*dbpath) -- cgit v1.2.3