remove freegeoip.live as a provider
This commit is contained in:
parent
7c55c713a0
commit
d9202cfca6
3 changed files with 2 additions and 43 deletions
|
|
@ -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.
|
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.
|
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.
|
||||||
|
|
||||||
|
|
|
||||||
41
geoip.go
41
geoip.go
|
|
@ -53,45 +53,6 @@ func composeCountry(country string) string {
|
||||||
return country
|
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 {
|
type ipapi struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
|
@ -160,8 +121,6 @@ func geohashAndLocation(address string, geoipSupplier string) (string, string, s
|
||||||
return "s000", "Geohash off", "Geohash off", nil
|
return "s000", "Geohash off", "Geohash off", nil
|
||||||
case "ip-api":
|
case "ip-api":
|
||||||
return geohashAndLocationFromIpapi(address)
|
return geohashAndLocationFromIpapi(address)
|
||||||
case "freegeoip":
|
|
||||||
return geohashAndLocationFromFreegeoip(address)
|
|
||||||
case "max-mind-db":
|
case "max-mind-db":
|
||||||
return geohashAndLocationFromMaxMindDb(address)
|
return geohashAndLocationFromMaxMindDb(address)
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -115,7 +115,7 @@ func main() {
|
||||||
prometheusHost := flag.String("prometheus_host", "0.0.0.0", "The address for prometheus")
|
prometheusHost := flag.String("prometheus_host", "0.0.0.0", "The address for prometheus")
|
||||||
prometheusPort := flag.String("prometheus_port", "2112", "The port for prometheus")
|
prometheusPort := flag.String("prometheus_port", "2112", "The port for prometheus")
|
||||||
prometheusEntry := flag.String("prometheus_entry", "metrics", "Entry point 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.")
|
maxMindDbFileName = flag.String("max_mind_db", "", "Path to the MaxMind DB file.")
|
||||||
|
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue