diff --git a/VERSION b/VERSION index 34a8f74..eab246c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.3.1 \ No newline at end of file +7.3.2 diff --git a/build.gradle b/build.gradle index cf960d3..2941574 100644 --- a/build.gradle +++ b/build.gradle @@ -41,8 +41,8 @@ group "org.logstash.filters" version "${new File("VERSION").text.trim()}" String junitVersion = '5.11.2' // at least 5.11 is needed to use @FieldSource with @ParameterizedTest -String maxmindGeoip2Version = '2.17.0' -String maxmindDbVersion = '2.1.0' +String maxmindGeoip2Version = '4.2.0' +String maxmindDbVersion = '3.1.1' String log4jVersion = '2.17.1' String jrubyCompleteVersion = '9.1.13.0' String mockitoVersion = '4.11.0' diff --git a/logstash-filter-geoip.gemspec b/logstash-filter-geoip.gemspec index d1f9840..20e35ba 100644 --- a/logstash-filter-geoip.gemspec +++ b/logstash-filter-geoip.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.require_paths = ["lib", "vendor/jar-dependencies"] # Files - s.files = Dir['lib/**/*','spec/**/*','vendor/**/*', 'vendor/jar-dependencies/**/*.jar', '*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT', 'maxmind-db-NOTICE.txt', 'docs/**/*'] + s.files = Dir['lib/**/*','spec/**/*','vendor/**/*', 'vendor/jar-dependencies/**/*.jar', '*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT', 'maxmind-db-NOTICE.txt', 'docs/**/*', 'VERSION'] # Tests s.test_files = s.files.grep(%r{^(test|spec|features)/}) diff --git a/src/main/java/org/logstash/filters/geoip/Database.java b/src/main/java/org/logstash/filters/geoip/Database.java index fc79219..26c69ee 100644 --- a/src/main/java/org/logstash/filters/geoip/Database.java +++ b/src/main/java/org/logstash/filters/geoip/Database.java @@ -22,7 +22,8 @@ enum Database { Field.TIMEZONE, Field.LOCATION, Field.LATITUDE, - Field.LONGITUDE + Field.LONGITUDE, + Field.NETWORK ) ), COUNTRY( @@ -31,7 +32,8 @@ enum Database { Field.IP, Field.COUNTRY_CODE2, Field.COUNTRY_NAME, - Field.CONTINENT_NAME + Field.CONTINENT_NAME, + Field.NETWORK ) ), DOMAIN( @@ -55,7 +57,8 @@ enum Database { Field.AUTONOMOUS_SYSTEM_NUMBER, Field.AUTONOMOUS_SYSTEM_ORGANIZATION, Field.ISP, - Field.ORGANIZATION + Field.ORGANIZATION, + Field.NETWORK ) ), ANONYMOUS_IP( @@ -66,7 +69,8 @@ enum Database { Field.ANONYMOUS_VPN, Field.ANONYMOUS, Field.PUBLIC_PROXY, - Field.RESIDENTIAL_PROXY + Field.RESIDENTIAL_PROXY, + Field.NETWORK ) ), ENTERPRISE( @@ -122,4 +126,4 @@ public static Database fromDatabaseType(final String type) { // database type. return Database.UNKNOWN; } -} \ No newline at end of file +} diff --git a/src/main/java/org/logstash/filters/geoip/GeoIPFilter.java b/src/main/java/org/logstash/filters/geoip/GeoIPFilter.java index 81d245a..d916649 100644 --- a/src/main/java/org/logstash/filters/geoip/GeoIPFilter.java +++ b/src/main/java/org/logstash/filters/geoip/GeoIPFilter.java @@ -246,6 +246,7 @@ private Map retrieveCityGeoData(InetAddress ipAddress) throws GeoI Postal postal = response.getPostal(); Subdivision subdivision = response.getMostSpecificSubdivision(); Map geoData = new EnumMap<>(Field.class); + Network network = response.getTraits().getNetwork(); // if location is empty, there is no point populating geo data // and most likely all other fields are empty as well @@ -344,6 +345,11 @@ private Map retrieveCityGeoData(InetAddress ipAddress) throws GeoI geoData.put(Field.LONGITUDE, lon); } break; + case NETWORK: + if (network != null) { + geoData.put(Field.NETWORK, network.toString()); + } + break; } } @@ -397,6 +403,7 @@ private Map retrieveIspGeoData(InetAddress ipAddress) throws GeoI } catch (NullPointerException e) { throw new GeoIp2InvalidCustomFieldException(e); } + Network network = response.getNetwork(); Map geoData = new EnumMap<>(Field.class); for (Field desiredField : this.desiredFields) { @@ -405,7 +412,7 @@ private Map retrieveIspGeoData(InetAddress ipAddress) throws GeoI geoData.put(Field.IP, ipAddress.getHostAddress()); break; case AUTONOMOUS_SYSTEM_NUMBER: - Integer asn = response.getAutonomousSystemNumber(); + Long asn = response.getAutonomousSystemNumber(); if (asn != null) { geoData.put(desiredField, asn); } @@ -428,6 +435,11 @@ private Map retrieveIspGeoData(InetAddress ipAddress) throws GeoI geoData.put(Field.ORGANIZATION, org); } break; + case NETWORK: + if (network != null) { + geoData.put(Field.NETWORK, network.toString()); + } + break; } } @@ -450,7 +462,7 @@ private Map retrieveAsnGeoData(InetAddress ipAddress) throws GeoI geoData.put(Field.IP, ipAddress.getHostAddress()); break; case AUTONOMOUS_SYSTEM_NUMBER: - Integer asn = response.getAutonomousSystemNumber(); + Long asn = response.getAutonomousSystemNumber(); if (asn != null) { geoData.put(Field.AUTONOMOUS_SYSTEM_NUMBER, asn); } @@ -507,7 +519,7 @@ private Map retrieveEnterpriseGeoData(InetAddress ipAddress) thro Continent continent = response.getContinent(); Subdivision subdivision = response.getMostSpecificSubdivision(); - Integer asn = response.getTraits().getAutonomousSystemNumber(); + Long asn = response.getTraits().getAutonomousSystemNumber(); String organizationName = response.getTraits().getAutonomousSystemOrganization(); Network network = response.getTraits().getNetwork(); @@ -620,6 +632,7 @@ private Map retrieveAnonymousIpGeoData(final InetAddress ipAddres boolean isAnonymous = response.isAnonymous(); boolean isPublicProxy = response.isPublicProxy(); boolean isResidentialProxy = response.isResidentialProxy(); + Network network = response.getNetwork(); for (Field desiredField : this.desiredFields) { switch (desiredField) { @@ -644,6 +657,11 @@ private Map retrieveAnonymousIpGeoData(final InetAddress ipAddres case RESIDENTIAL_PROXY: geoData.put(desiredField, isResidentialProxy); break; + case NETWORK: + if (network != null) { + geoData.put(Field.NETWORK, network.toString()); + } + break; } } return geoData;