php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59124 IPv6
Submitted: 2010-03-17 09:10 UTC Modified: 2016-08-19 00:32 UTC
Votes:22
Avg. Score:4.6 ± 0.6
Reproduced:22 of 22 (100.0%)
Same Version:6 (27.3%)
Same OS:7 (31.8%)
From: dave@php.net Assigned: ohill (profile)
Status: Closed Package: geoip (PECL)
PHP Version: 5.2.12 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dave@php.net
New email:
PHP Version: OS:

 

 [2010-03-17 09:10 UTC] dave@php.net
Description:
------------
The current PHP extension does not seem to support the IPv6 country database (at http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz), and I had need of it, so I wrote a quick function as shown here:

http://davephp.net/geoip.ipv6.patch.txt

It would probably be better to incorporate this into most functions, and also add checks to only include these functions if the version of libGeoIP supported IPv6 stuff, but this is a good start!


Patches

geoip-1.1.0-ipv6-php7.patch (last revision 2015-09-23 17:31 UTC by as@php.net)
geoip-1.1.0-ipv6.patch (last revision 2014-05-27 02:27 UTC by yiftachswr at gmail dot com)
geoip-1.0.8-further-ipv6-fix.patch (last revision 2012-11-13 11:27 UTC by php at gnodde dot org)
geoip-include-ipv6.patch (last revision 2012-06-15 11:37 UTC by dominic dot benson at thirdlight dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-24 16:54 UTC] ohill@php.net
I will take a look shortly.

For now it seems Maxmind is only doing IPv6 with Country database, even if the C API has more functions.

Need to wrap your code in C API version detection not to break things. I'm pretty sure it needs >=1.4.5
 [2011-06-08 00:56 UTC] hessu at hes dot iki dot fi
Even country level support would be really good to have.

I just put the AAAA records up on my service (in support of 
the World IPv6 Day, http://www.worldipv6day.org/, which 
Google, Akamai and Facebook and some other small players are 
taking part in) and noticed that the default measurement units 
according to origin country do not seem to work for IPv6 
users.
 [2012-06-15 11:44 UTC] dominic dot benson at thirdlight dot com
Added a patch to enable the IPv6 versions by default when a sufficient geoip library is available.
Extend so that explicit IPv4 only methods are available as _v4 (per _v6), and so that the non-suffixed methods will try both databases if possible and necessary.
This has the effect that the standard functions (e.g. geoip_country_name_by_name) will be IP version transparent, which is overwhelmingly the more likely use case.
The _v4 allows usage in the edge cases that explicit restriction is required.

This does mean that these functions are not just wrappers for the underlying C API methods with the same name, but it represents an, IMHO, significant improvement in functionality without requiring user code to handle a wider variety of possible interfaces - like checking if _v6 functions exist.
 [2012-11-13 11:29 UTC] php at gnodde dot org
I've added IPv6 capabilities to the geoip_record_by_name() method, since Maxmind offers IPv6 city databases. The patch is based on and includes the previous patch attached to this ticket.
 [2012-11-13 14:02 UTC] arnaud dot abelard at univ-nantes dot fr
This last patch won't compile with geoip 1.0.8 and libgeoip 1.4.7 on debian Squeeze:

/bin/sh /root/geoip/geoip-1.0.8/libtool --mode=compile cc  -I. -I/root/geoip/geoip-1.0.8 -DPHP_ATOM_INC -I/root/geoip/geoip-1.0.8/include -I/root/geoip/geoip-1.0.8/main -I/root/geoip/geoip-1.0.8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/geoip/geoip-1.0.8/geoip.c -o geoip.lo 
libtool: compile:  cc -I. -I/root/geoip/geoip-1.0.8 -DPHP_ATOM_INC -I/root/geoip/geoip-1.0.8/include -I/root/geoip/geoip-1.0.8/main -I/root/geoip/geoip-1.0.8 -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/geoip/geoip-1.0.8/geoip.c  -fPIC -DPIC -o .libs/geoip.o
/root/geoip/geoip-1.0.8/geoip.c: In function 'zm_startup_geoip':
/root/geoip/geoip-1.0.8/geoip.c:133: error: 'GEOIP_CITY_EDITION_REV0_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c:133: error: (Each undeclared identifier is reported only once
/root/geoip/geoip-1.0.8/geoip.c:133: error: for each function it appears in.)
/root/geoip/geoip-1.0.8/geoip.c:140: error: 'GEOIP_CITY_EDITION_REV1_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c: In function 'zif_geoip_record_by_name':
/root/geoip/geoip-1.0.8/geoip.c:479: error: 'GEOIP_CITY_EDITION_REV1_V6' undeclared (first use in this function)
/root/geoip/geoip-1.0.8/geoip.c:481: error: 'GEOIP_CITY_EDITION_REV0_V6' undeclared (first use in this function)
 [2012-11-13 14:42 UTC] arnaud dot abelard at univ-nantes dot fr
Required libgeoip version is >= 1.4.8
 [2012-12-06 20:49 UTC] phpdev at ehrhardt dot nl
To compile it with MS VC9 the declaration of ipv4_db_available and ipv6_db_available have to be moved to the top of the block, likt this:

PHP_FUNCTION(geoip_record_by_name)
{
	GeoIP * gi;
	char * hostname = NULL;
	int arglen;
	int ipv4_db_available;
	int ipv6_db_available;
	GeoIPRecord * gir = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hostname, &arglen) == FAILURE) {
		return;
	}

	ipv4_db_available = 1;
#if LIBGEOIP_VERSION >= 1004005
	ipv6_db_available = 1;
#endif
....
 [2014-01-16 01:34 UTC] mzvarik at gmail dot com
Adding the IPv6 support would be really great =)
 [2014-01-27 23:34 UTC] neufeind@php.net
Would be great if you could please consider the patch. For example Piwik uses the pecl-library. And a (small but) increasing number of visitors come via IPv6 these days here.
 [2014-05-10 10:51 UTC] yiftachswr at gmail dot com
Please please, I see that this is now once agai an active project with a new 1.10 beta released, can we please have IPv6 support.
 [2014-11-03 00:37 UTC] matt at piwik dot org
Thanks for the very useful work on GeoIP PECL! :)

I guess thousands of Piwik users geo locate their visitors using the extension since it's part of the core feature, refs user guide: http://piwik.org/docs/geo-locate/

it would be so nice to have IPv6 support in the PECL extension like in the PHP library and the apache server module. We will then add support to Piwik in  https://github.com/piwik/piwik/issues/3581
 [2015-09-23 17:31 UTC] as@php.net
The following patch has been added/updated:

Patch Name: geoip-1.1.0-ipv6-php7.patch
Revision:   1443029505
URL:        https://bugs.php.net/patch-display.php?bug=59124&patch=geoip-1.1.0-ipv6-php7.patch&revision=1443029505
 [2015-09-23 17:37 UTC] as@php.net
Added geoip-1.1.0-ipv6-php7.patch.

This patch adds full IPv6 support, reduces code duplication, and replaces some macros in favor of functions. It also makes the extension fully PHP7 compatible.

There is a corresponding PR for the HHVM extension here:

https://github.com/vipsoft/hhvm-ext-geoip/pull/26
 [2016-07-17 13:52 UTC] burrellramone at gmail dot com
Hi,

I am very new to the idea of applying patches. Could someone please explain how I would go about applying this patch? I have downloaded the latest tarball as of May 1st 2016.
 [2016-07-17 14:08 UTC] burrellramone at gmail dot com
I figured it out after doing some reading. The patch file has everything needed to do the patch. Just have to run the patch command in the right directory and all is well.
 [2016-08-19 00:32 UTC] ohill@php.net
-Status: Assigned +Status: Closed
 [2016-08-19 00:32 UTC] ohill@php.net
Available in 1.1.1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC