Seems mod_geoip2 was worth the effort

Started by Gregg, August 28, 2009, 09:54:52 PM

Previous topic - Next topic

mario

I guess it got better! This is pretty close. Just the next town :)

Quote
Hello visitor from Buxtehude, Niedersachsen, Germany
IP Address: 91.97.163.111
Hostname: host-091-097-163-111.ewe-ip-backbone.de
Saturday, Apr 16, 2011 3:30 PM CEST

Gregg

Getting there I guess. Maxmind is a US company, their real concern is the US and not the rest of the world. I'm sure they have to have contacts at ISPs to know how the ip blocks are assigned by them, so I am sure countries that are considered hostile to the US there is going to be a pretty poor return from  the DB.

It's interesting to note they do state a % of accuracy on the DBs. You'll notice even on the free one, the accuracy inside the US is pretty high, where outside the US it get's poor.  I'm sure it an accumulative average across all countries so because of the challenge noted above, it takes a hit on the % point. It's going to be interesting to see how they deal with IPv6 in the future.


Gregg


Sob

No, I didn't notice it. And unfortunately is doesn't seem that I will be able to find time to play with it in near future. But on very quick look it seems that this might be enough:
diff -Naur mod_geoip2_1.2.5-ipv6-2a/mod_geoip.c mod_geoip2_1.2.5-ipv6-3/mod_geoip.c
--- mod_geoip2_1.2.5-ipv6-2a/mod_geoip.c 2010-11-24 02:35:01.726736800 +0100
+++ mod_geoip2_1.2.5-ipv6-3/mod_geoip.c 2012-03-19 02:44:47.935774500 +0100
@@ -500,7 +500,15 @@
break;
case GEOIP_CITY_EDITION_REV0:
case GEOIP_CITY_EDITION_REV1:
+ if(is_v6) break;
gir = GeoIP_record_by_addr(cfg->gips[i], ipaddr);
+ goto geoip_city_id;
+ case GEOIP_CITY_EDITION_REV0_V6:
+ case GEOIP_CITY_EDITION_REV1_V6:
+ if(!is_v6) break;
+ gir = GeoIP_record_by_addr_v6(cfg->gips[i], ipaddr);
+
+ geoip_city_id:
if (gir != NULL) {
        if ( gir->country_code != NULL ) {
  region_name = GeoIP_region_name_by_code(gir->country_code, gir->region);

It's completely untested, I just changed the file and didn't even try to compile it.

Sob

On second look, there is also mod_geoip2 1.2.7 and it seems to support everything. ;D

Gregg

#20
Yes, it seems to, tho I have not heard from anyone I have given it to with IPv6 yet. It requires the newer API 1.4.8 which I did get to build on Windows. I am waiting word on the IPv6 part and if it's working (even somewhat) will be putting it up here.

I have since done a r2 of it, due to how I dealt with the ssize_t in the API the first time is incorrect, even I have seen some odd returns with it, I redid it all and compiled again and so far I am not seeing someone I know to be in Australia showing as coming from AU, Iraq, Hungary and many others.

Gregg

1.2.8 source has been released. Haven't had the time to study it in depth yet. One thing I did see, it will ignore local IPs finally. This is a good thing since the module will crash at times when it happens to look up a local IP.