diff --git a/README.md b/README.md index ef4db01..7685a7a 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ The metrics is off by default, you can turn it via the CLI argument `-enable_pro It listens to port `2112` and entry point is `/metrics` by default. The port and entry point can be changed via CLI arguments. -The endlessh-go server stores the geohash of attackers as a label on `endlessh_client_open_count`, which is also off by default. You can turn it on via the CLI argument `-geoip_supplier`. The endlessh-go uses service from either [ip-api](https://ip-api.com/) or [freegeoip](https://freegeoip.live/), which may enforce a query rate and limit commercial use. Visit their website for their terms and policies. +The endlessh-go server stores the geohash of attackers as a label on `endlessh_client_open_count`, which is also off by default. You can turn it on via the CLI argument `-geoip_supplier`. The endlessh-go uses service from [ip-api](https://ip-api.com/), which may enforce a query rate and limit commercial use. Visit their website for their terms and policies. You could also use an offline GeoIP database from [MaxMind](https://www.maxmind.com) by setting `-geoip_supplier` to *max-mind-db* and `-max_mind_db` to the path of the database file. diff --git a/geoip.go b/geoip.go index 1c16642..43b1d14 100644 --- a/geoip.go +++ b/geoip.go @@ -53,45 +53,6 @@ func composeCountry(country string) string { return country } -type freegeoip struct { - Ip string `json:"ip"` - CountryCode string `json:"country_code"` - CountryName string `json:"country_name"` - RegionCode string `json:"region_code"` - RegionName string `json:"region_name"` - City string `json:"city"` - Zipcode string `json:"zipcode"` - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` - MetroCode int `json:"metro_code"` - AreaCode int `json:"area_code"` -} - -func geohashAndLocationFromFreegeoip(address string) (string, string, string, error) { - var geo freegeoip - response, err := http.Get("https://freegeoip.live/json/" + address) - if err != nil { - return "s000", "Unknown", "Unknown", err - } - defer response.Body.Close() - - body, err := ioutil.ReadAll(response.Body) - if err != nil { - return "s000", "Unknown", "Unknown", err - } - - err = json.Unmarshal(body, &geo) - if err != nil { - return "s000", "Unknown", "Unknown", err - } - - gh := geohash.EncodeAuto(geo.Latitude, geo.Longitude) - country := composeCountry(geo.CountryName) - location := composeLocation(geo.CountryName, geo.RegionName, geo.City) - - return gh, country, location, nil -} - type ipapi struct { Status string `json:"status"` Message string `json:"message"` @@ -160,8 +121,6 @@ func geohashAndLocation(address string, geoipSupplier string) (string, string, s return "s000", "Geohash off", "Geohash off", nil case "ip-api": return geohashAndLocationFromIpapi(address) - case "freegeoip": - return geohashAndLocationFromFreegeoip(address) case "max-mind-db": return geohashAndLocationFromMaxMindDb(address) default: diff --git a/main.go b/main.go index 5b1dc90..9cd1627 100644 --- a/main.go +++ b/main.go @@ -115,7 +115,7 @@ func main() { prometheusHost := flag.String("prometheus_host", "0.0.0.0", "The address for prometheus") prometheusPort := flag.String("prometheus_port", "2112", "The port for prometheus") prometheusEntry := flag.String("prometheus_entry", "metrics", "Entry point for prometheus") - geoipSupplier := flag.String("geoip_supplier", "off", "Supplier to obtain Geohash of IPs. Possible values are \"off\", \"ip-api\", \"freegeoip\", \"max-mind-db\"") + geoipSupplier := flag.String("geoip_supplier", "off", "Supplier to obtain Geohash of IPs. Possible values are \"off\", \"ip-api\", \"max-mind-db\"") maxMindDbFileName = flag.String("max_mind_db", "", "Path to the MaxMind DB file.") flag.Usage = func() {