Skip to content

Commit 77b55b7

Browse files
yaauiejoegallo
andauthored
geoip: implement GeoIpDatabase methods added in ES 8.14 (#139)
Catches up with Elasticsearch 8.14+ support for user-provided databases: - `Anonymous-IP` elastic/elasticsearch#107287 - `Enterprise` elastic/elasticsearch#107377 When compiled against Elasticsearch < 8.14, these methods neither exist in the interface nor are reachable by the GeoIP processor. Co-authored-by: Joe Gallo <[email protected]>
1 parent 9aa0db9 commit 77b55b7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/co/elastic/logstash/filters/elasticintegration/geoip/GeoIpDatabaseAdapter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.db.NodeCache;
1212
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.DatabaseReader;
1313
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.AbstractResponse;
14+
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.AnonymousIpResponse;
1415
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.AsnResponse;
1516
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.CityResponse;
1617
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.CountryResponse;
18+
import org.elasticsearch.ingest.geoip.shaded.com.maxmind.geoip2.model.EnterpriseResponse;
1719

1820
import java.io.Closeable;
1921
import java.io.File;
@@ -52,6 +54,16 @@ public AsnResponse getAsn(InetAddress inetAddress) {
5254
return getResponse(inetAddress, this.databaseReader::tryAsn);
5355
}
5456

57+
/* @Override // neither available nor reachable until Elasticsearch 8.14 */
58+
public AnonymousIpResponse getAnonymousIp(InetAddress ipAddress) {
59+
return getResponse(ipAddress, this.databaseReader::tryAnonymousIp);
60+
}
61+
62+
/* @Override // neither available nor reachable until Elasticsearch 8.14 */
63+
public EnterpriseResponse getEnterprise(InetAddress ipAddress) {
64+
return getResponse(ipAddress, this.databaseReader::tryEnterprise);
65+
}
66+
5567
private <T extends AbstractResponse> T getResponse(final InetAddress inetAddress, MaxmindTryLookup<T> resolver) {
5668
try {
5769
return resolver.lookup(inetAddress).orElse(null);

0 commit comments

Comments
 (0)