diff options
-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) |