Req #66020 [NEW]: Can curl_getinfo() return IP address?

From: Date: Sat, 02 Nov 2013 12:44:34 +0000
Subject: Req #66020 [NEW]: Can curl_getinfo() return IP address?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182556@lists.php.net to get a copy of this message
From:             php dot bugs dot ws at jondh dot me dot uk
Operating system: OS X
PHP version:      Irrelevant
Package:          cURL related
Bug Type:         Feature/Change Request
Bug description:Can curl_getinfo() return IP address?

Description:
------------
When using the cURL library, some domain names resolve to many IP
addresses, but there's no way (as far as I can tell), in these cases, to
see which IP was actually used. I think this would be useful.

I've discussed this with the author of Guzzle, and he seems to be in
agreement that cURL presently offers no way to do this (see
http://stackoverflow.com/a/19599373/472495).

Illustration script attached.

Test script:
---------------
<?php
$host = "www.google.com";

$ips = gethostbynamel($host);
if (count($ips) > 1) {
	echo sprintf("Host %s resolves to these IPs: %s\n", $host, implode(',
', $ips));
} else {
	die(sprintf("Host %s does not resolve to many IPs, so is not a good
example\n", $host));
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$html = curl_exec($ch);
$ok = (bool) $html;
echo $ok ? "Call OK\n" : "Call failed\n";

// Show that there's no way to determine which IP was accessed
echo "Info:\n" . print_r(curl_getinfo($ch), true);

curl_close($ch);


Expected result:
----------------
This is a feature request, so if possible I'd like to see a new key
returned by curl_getinfo, "ip_address", which would be populated with
the address used by cURL for the connection. This would correspond to a
new constant CURLINFO_IP_ADDRESS.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=66020&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=66020&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=66020&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=66020&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=66020&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=66020&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=66020&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=66020&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=66020&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=66020&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=66020&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=66020&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=66020&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=66020&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66020&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=66020&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=66020&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=66020&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66020&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=66020&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=66020&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#182556) next »