mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/9534] Adding support for IPv6 addresses in user_ipwhois().
whois.arin.net does currently not refer to other servers (using ReferralServer) when queried for an IPv6 address. whois.sixxs.net however works in this case. This also adds '.' to the hostname to make sure we're querying the dns root. PHPBB3-9534
This commit is contained in:
parent
e46745ed34
commit
ed44235d26
1 changed files with 21 additions and 8 deletions
|
@ -1235,16 +1235,29 @@ function user_unban($mode, $ban)
|
||||||
*/
|
*/
|
||||||
function user_ipwhois($ip)
|
function user_ipwhois($ip)
|
||||||
{
|
{
|
||||||
$ipwhois = '';
|
if (empty($ip))
|
||||||
|
|
||||||
// Check IP
|
|
||||||
// Only supporting IPv4 at the moment...
|
|
||||||
if (empty($ip) || !preg_match(get_preg_expression('ipv4'), $ip))
|
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($fsk = @fsockopen('whois.arin.net', 43)))
|
if (preg_match(get_preg_expression('ipv4'), $ip))
|
||||||
|
{
|
||||||
|
// IPv4 address
|
||||||
|
$whois_host = 'whois.arin.net.';
|
||||||
|
}
|
||||||
|
else if (preg_match(get_preg_expression('ipv6'), $ip))
|
||||||
|
{
|
||||||
|
// IPv6 address
|
||||||
|
$whois_host = 'whois.sixxs.net.';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$ipwhois = '';
|
||||||
|
|
||||||
|
if (($fsk = @fsockopen($whois_host, 43)))
|
||||||
{
|
{
|
||||||
// CRLF as per RFC3912
|
// CRLF as per RFC3912
|
||||||
fputs($fsk, "$ip\r\n");
|
fputs($fsk, "$ip\r\n");
|
||||||
|
@ -1257,7 +1270,7 @@ function user_ipwhois($ip)
|
||||||
|
|
||||||
$match = array();
|
$match = array();
|
||||||
|
|
||||||
// Test for referrals from ARIN to other whois databases, roll on rwhois
|
// Test for referrals from $whois_host to other whois databases, roll on rwhois
|
||||||
if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
|
if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match))
|
||||||
{
|
{
|
||||||
if (strpos($match[1], ':') !== false)
|
if (strpos($match[1], ':') !== false)
|
||||||
|
@ -1285,7 +1298,7 @@ function user_ipwhois($ip)
|
||||||
@fclose($fsk);
|
@fclose($fsk);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the result from ARIN if we don't get any result here
|
// Use the result from $whois_host if we don't get any result here
|
||||||
$ipwhois = (empty($buffer)) ? $ipwhois : $buffer;
|
$ipwhois = (empty($buffer)) ? $ipwhois : $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue