[OpenSIPS-Devel] GeoIP with IPv6 support -- how shall I do it?
Bogdan-Andrei Iancu
bogdan at opensips.org
Thu Sep 20 10:55:40 CEST 2012
Hi Rick,
I will go for option 2 - have a single script function which internally
will figure out if it is a v4 or v6 IP (in the param) -> depending on
that, it will use the appropriate DB file to query.
Probably the code can be a bit reworked to avoid duplicity (move common
parts into functions or so)
Regards,
Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com
On 07/31/2012 04:48 PM, Rick van Rein wrote:
> 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
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>
More information about the Devel
mailing list