summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-11-09 23:03:12 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-11-09 23:03:12 +0100
commit8acd8591a8be49c1303560526d280c6810702a6e (patch)
treeac8e7fbee8605212881cc9b24f000ca9b93e65f7
parentfd5c1c4105bcea82e53710e53003ca0ddff7464c (diff)
allow to set api via env var
-rw-r--r--README.rst2
-rw-r--r--main.go12
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 <tld>
- 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>
path to the GeoLite2-City database (default is "/var/lib/GeoIP/GeoLite2-City.mmdb")
-port <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)