简体   繁体   中英

Determine IP address used by cURL in PHP

If i'm using PHP cURL with a Socks5 to connect to a site, is it possible to retrieve the IP sent by cURL ? for example like that :

$socks = "XXX.XXX.XXX.XXX:12345";
curl_setopt($curl, CURLOPT_PROXY, $socks);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($curl, CURLOPT_URL, "http://www.google.com");

XXX.XXX.XXX.XXX:12345 can be a tunnel to another IP YYYY.YYYY.YYYY.YYY, so i need to ask if it is possible to retrieve the IP that will send request to google.com.

It isn't possible.

The request will be made by the SOCKS proxy, and the contract between you and the proxy does not include the option of retrieving information about the network interfaces the proxy uses to forward requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM