Hi,
The rcf howto pushed me into mailing you guys to measure reaction.
For a project i am working on i struggle a lot with the fact that $_SERVER['REMOTE_ADDRESS'] return policy is to prefer IPv6 over IPv4, and that gethostbyname prefers IPv4. It seems that the gethostbyname
function as used in php is deprecated, and that getnameinfo should be used.
I think that in an age where we are finally getting the support of the big boys to start using IPv6 that php should be there and ready for them.
I have never contributed to php core before, but i'm more than happy to take the lead on this one.
Please let me know what you guys think, and thank you for your time.
Kind regards,
Sam Hermans
I agree, PHP should have world-class support for v6. What is your proposal exactly?
Am 27.03.2013 um 13:39 schrieb Sam Hermans sam@mujo.be:
Hi,
The rcf howto pushed me into mailing you guys to measure reaction.
For a project i am working on i struggle a lot with the fact that $_SERVER['REMOTE_ADDRESS'] return policy is to prefer IPv6 over IPv4, and that gethostbyname prefers IPv4. It seems that the gethostbyname
function as used in php is deprecated, and that getnameinfo should be used.I think that in an age where we are finally getting the support of the big boys to start using IPv6 that php should be there and ready for them.
I have never contributed to php core before, but i'm more than happy to take the lead on this one.
Please let me know what you guys think, and thank you for your time.
Kind regards,
Sam Hermans
Not sure,
I tried something locally and this is what i came up with (and what i think expected behaviour could be)
<?php
echo "IPv6 preferred host (no A record, but CNAME to A):\n";
var_dump(gethostbyname("ipv6.google.com"));
echo "\nIPv4 preferred host with AAAA records: \n";
var_dump(gethostbyname("www.google.com"));
echo "\nIPv6 preferred host (no A record, but CNAME to A)\n";
var_dump(gethostbyname2("ipv6.google.com"));
echo "\nIPv4 preferred host with AAAA records:\n";
var_dump(gethostbyname2("www.google.com"));
echo "\nIPv4 preferred host with AAAA records and extra argument:\n";
var_dump(gethostbyname2("www.google.com",TRUE));
root@lucid32:/vagrant/php-5.4.13# ./sapi/cli/php run.php
IPv6 preferred host (no A record, but CNAME to A):
string(15) "ipv6.google.com"
IPv4 preferred host with AAAA records:
string(14) "173.194.66.103"
IPv6 preferred host (no A record, but CNAME to A)
string(22) "2a00:1450:400c:c05::68"
IPv4 preferred host with AAAA records:
string(14) "173.194.66.104"
IPv4 preferred host with AAAA records and extra argument:
string(22) "2a00:1450:400c:c03::68"
I agree, PHP should have world-class support for v6. What is your proposal exactly?
Am 27.03.2013 um 13:39 schrieb Sam Hermans sam@mujo.be:
Hi,
The rcf howto pushed me into mailing you guys to measure reaction.
For a project i am working on i struggle a lot with the fact that $_SERVER['REMOTE_ADDRESS'] return policy is to prefer IPv6 over IPv4, and that gethostbyname prefers IPv4. It seems that the gethostbyname
function as used in php is deprecated, and that getnameinfo should be used.I think that in an age where we are finally getting the support of the big boys to start using IPv6 that php should be there and ready for them.
I have never contributed to php core before, but i'm more than happy to take the lead on this one.
Please let me know what you guys think, and thank you for your time.
Kind regards,
Sam Hermans
Hi,
The rcf howto pushed me into mailing you guys to measure reaction.
For a project i am working on i struggle a lot with the fact that
$_SERVER['REMOTE_ADDRESS'] return policy is to prefer IPv6 over IPv4, and
that gethostbyname prefers IPv4. It seems that the gethostbyname
function as used in php is deprecated, and that getnameinfo should be
used.I think that in an age where we are finally getting the support of the
big boys to start using IPv6 that php should be there and ready for them.I have never contributed to php core before, but i'm more than happy to
take the lead on this one.Please let me know what you guys think, and thank you for your time.
Kind regards,
Sam Hermans--
you mean REMOTE_ADDR? what SAPI are you using?
AFAIK REMOTE_ADDR (as most other $_SERVER variables) is coming from the
webserver itself:
http://lxr.php.net/xref/PHP_5_5/sapi/apache/mod_php5.c#254
http://lxr.php.net/search?q=REMOTE_ADDR&defs=&refs=&path=&hist=&project=PHP_5_5
I suppose it will contain whatever address your server received the request
(be that an ipv4 or ipv6 address).
on the other hand gethostbyname by definition returns an IPV4 address for
the given host.
this is the intended and documented behavior.
there is an open feature request (with a patch) for changing that behavior
to return IPv6 address:
https://bugs.php.net/bug.php?id=49493&edit=1
personally I think that we should introduce this feature without breaking
any BC, so a new function or a new optional argument should be added.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu