[Patch][GeoIP][1.0.0] GeoIP Organization / ISP support

Arnaud GRANAL serphen at gmail.com
Mon Apr 18 22:45:23 MSD 2011

On Mon, Apr 18, 2011 at 9:20 PM, Igor Sysoev <igor at sysoev.ru> wrote:
> On Mon, Apr 18, 2011 at 05:56:09PM +0300, Arnaud GRANAL wrote:
>> Igor Sysoev wrote:
>> >  There is already patch to support GeoIP ISP base:
>> >  http://kornel.neolabs.kz/files/nginx-0.9.7-geoip-isp.patch.bz2
>> >  What is the difference between ISP base and Organization base ?
>> Almost none, organization is more precise but API calls are the same.
>> As far I can see the code is very similar so there is no reason to use my patch.
> To get GeoIP_1st patch calls GeoIP_name_by_ipnum(),
> while your patch calls GeoIP_org_by_ipnum() to get organization.
> Do these capabilities exist in both bases ?

If you want to merge I suggest using GeoIP_name_by_ipnum() because
this can read AS database, ISP base, Organization base and Domain

GeoIP_org_by_ipnum() is the old function of GeoIP, this is the one
used by the official example:

>From GeoIP official API:

		else if (GEOIP_ORG_EDITION == i || GEOIP_ISP_EDITION == i) {
			org = GeoIP_org_by_ipnum(gi, ipnum);
			domain_name = GeoIP_name_by_ipnum(gi, ipnum);

However, GeoIP.h states that GeoIP_org_by_ipnum is deprecated, but
paradoxally there are still recommending it in code examples.

I didn't see official code using GeoIP_name_by_ipnum for ISP but it
seems to be ok.

 static char *
 ngx_http_geoip_city(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)

should add (for cleanup)

+    if (gcf->organization) {
+        GeoIP_delete(gcf->organization);
+    }


More information about the nginx-devel mailing list