From 632a371aa243611819da731e729263aadb2546c3 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Fri, 21 Jul 2017 13:46:06 -0700 Subject: [PATCH] Add continent-based city databases. Fixes #121 --- .../java/org/logstash/filters/GeoIPFilter.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/org/logstash/filters/GeoIPFilter.java b/src/main/java/org/logstash/filters/GeoIPFilter.java index 1a54b76..9833b8f 100644 --- a/src/main/java/org/logstash/filters/GeoIPFilter.java +++ b/src/main/java/org/logstash/filters/GeoIPFilter.java @@ -49,6 +49,11 @@ public class GeoIPFilter { // The paid GeoIP2 databases private static final String CITY_DB_TYPE = "GeoIP2-City"; + private static final String CITY_AFRICA_DB_TYPE = "GeoIP2-City-Africa"; + private static final String CITY_ASIA_PACIFIC_DB_TYPE = "GeoIP2-City-Asia-Pacific"; + private static final String CITY_EUROPE_DB_TYPE = "GeoIP2-City-Europe"; + private static final String CITY_NORTH_AMERICA_DB_TYPE = "GeoIP2-City-North-America"; + private static final String CITY_SOUTH_AMERICA_DB_TYPE = "GeoIP2-City-South-America"; private static final String COUNTRY_DB_TYPE = "GeoIP2-Country"; private static final String ISP_DB_TYPE = "GeoIP2-ISP"; @@ -77,6 +82,11 @@ private Set createDesiredFields(List fields) { switch (databaseReader.getMetadata().getDatabaseType()) { case CITY_LITE_DB_TYPE: case CITY_DB_TYPE: + case CITY_AFRICA_DB_TYPE: + case CITY_ASIA_PACIFIC_DB_TYPE: + case CITY_EUROPE_DB_TYPE: + case CITY_NORTH_AMERICA_DB_TYPE: + case CITY_SOUTH_AMERICA_DB_TYPE: desiredFields = Fields.DEFAULT_CITY_FIELDS; break; case COUNTRY_LITE_DB_TYPE: @@ -122,6 +132,11 @@ public boolean handleEvent(RubyEvent rubyEvent) { switch (databaseReader.getMetadata().getDatabaseType()) { case CITY_LITE_DB_TYPE: case CITY_DB_TYPE: + case CITY_AFRICA_DB_TYPE: + case CITY_ASIA_PACIFIC_DB_TYPE: + case CITY_EUROPE_DB_TYPE: + case CITY_NORTH_AMERICA_DB_TYPE: + case CITY_SOUTH_AMERICA_DB_TYPE: geoData = retrieveCityGeoData(ipAddress); break; case COUNTRY_LITE_DB_TYPE: