maxmind/geoip-api-java

getCountry(ipv4Address) returns UNKNOWN_COUNTRY with IPv6 database

bfg opened this issue · 6 comments

bfg commented

getCountry() which should accept ipv4 address, returns doesn't with ipv6 database (GeoIPv6.dat). Prepending "::ffff:" to ipv4 address and calling getCountryV6 also returns UNKNOWN_COUNTRY.

This is not the case with C-api, used by geoiplookup6(1). So i need to create two lookup service objects, check ip address syntax and select lookup service object - this is inconvenient.

  • getCountry works only with the GeoIP.dat database and is IPv4 only.
  • getCountryV6 should handle all valid IPv6 addresses including ::24.24.24.24 and ::ffff:24.24.24.24
    it works also with 24.24.24.24.

Does the branch bz/fix-ffff-xyzw fix your problem if you use getCountryV6 and GeoIPv6.dat?

Am 28.08.2013 um 14:11 schrieb Brane F. Gračnar notifications@github.com:

getCountry() which should accept ipv4 address, returns doesn't with ipv6 database (GeoIPv6.dat). Prepending "::ffff:" to ipv4 address and calling getCountryV6 also returns UNKNOWN_COUNTRY.

This is not the case with C-api, used by geoiplookup6(1). So i need to create two lookup service objects, check ip address syntax and select lookup service object - this is inconvenient.


Reply to this email directly or view it on GitHub.

bfg commented

Yep, branch bz/fix-ffff-xyzw fixes ::ffff:<ipv4_addr> lookups with GeoIPv6.dat database files.

Thanks alot.

The following code works as expected:

https://gist.github.com/bfg/6377619

Thanks for reporting this issue. 👍 The fixed code has been merged into master.

bfg commented

It would be great to release new version, what do you think?

I agree. I'll enter a ticket in our internal issue tracker.

I did a release of 1.2.11 to Maven. Thanks for the reminder.