cjheath / geoip

The Ruby gem for querying Maxmind.com's GeoIP database, which returns the geographic location of a server given its IP address
http://geoip.rubyforge.org/
GNU Lesser General Public License v2.1
714 stars 90 forks source link

Doesn't work with recent version of db #51

Closed morgoth closed 9 years ago

morgoth commented 9 years ago

I'm using GeoLiteCountry database from debian package https://packages.debian.org/jessie/geoip-database - currently in version of 1.6.2-4 which depends on geoip-database in version 20150317-1

When I lookup for a country I'm getting 0 as country code.

g = GeoIP.new('tmp/GeoIP.dat')
g.country("91.193.208.126").to_hash
=> {:request=>"91.193.208.126", :ip=>"91.193.208.126", :country_code=>0, :country_code2=>"--", :country_code3=>"--", :country_name=>"N/A", :continent_code=>"--"}

As there is some binary search going on, I don't know how to debug it https://github.com/cjheath/geoip/blob/master/lib/geoip.rb#L873-L887

cjheath commented 9 years ago

Apologies. Recent rework had mis-assigned this type of database to an IPv6 section.

morgoth commented 9 years ago

Thanks for the quick fix.