diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-11-09 23:03:12 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-11-09 23:03:12 +0100 |
commit | 8acd8591a8be49c1303560526d280c6810702a6e (patch) | |
tree | ac8e7fbee8605212881cc9b24f000ca9b93e65f7 | |
parent | fd5c1c4105bcea82e53710e53003ca0ddff7464c (diff) |
allow to set api via env var
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | main.go | 12 |
2 files changed, 10 insertions, 4 deletions
@@ -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> @@ -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) |