[OpenSIPS-Devel] GeoIP with IPv6 support -- how shall I do it?

Rick van Rein rick at openfortress.nl
Tue Jul 31 14:48:11 CEST 2012


Hello,

I am adding IPv6 support to the mmgeoip module.  What I'd like to know is what
you guys think is the preferred approach:

 1. Keep the IPv6 routines separate, conformant to the GeoIP API but leading to
    cloned code;
 2. Share most code, and try databases in the order they are specified.

In case 1, we'd end up writing stuff like

	if (af == INET6) {
		mmg_lookupv6 ("$si");
	} else {
		mmg_lookup ("$si");
	}

and the routines for v4 and v6 handling would basically be duplicates with
minor modifications.

In case 2, we'd end up writing the usual stuff, like

	mmg_lookup ("$si");

and it would automatically try in the order of specification, possibly
just a single database, but more likely two of them:

	modparam ("mmgeoip", "mmgeoip_city_db_path", "/path/to/GeoLiteCity.dat")
	modparam ("mmgeoip", "mmgeoip_city_dbv6_path", "/path/to/GeoLiteCityv6.dat")

I could easily generalise this mechanism to an array of databases, and gain a
lot of flexibility (including local overrides),

	modparam ("mmgeoip", "mmgeoip_city_db_path", "/path/to/GeoLiteCity_local.dat")
	modparam ("mmgeoip", "mmgeoip_city_db_path", "/path/to/GeoLiteCity.dat")
	modparam ("mmgeoip", "mmgeoip_city_dbv6_path", "/path/to/GeoLiteCityv6.dat")

I would suggest approach 2, also because that is completely backwards compatible.


Opinions?

Cheers,
 -Rick



More information about the Devel mailing list