ツールを作成していて、Tor ネットワークを使用したいと考えています。
私は PHP とその cURL 拡張の両方に精通していますが、Tor をプロキシとして使用することはできないようです。サーバーから応答がありません。
$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->ch, CURLOPT_PROXY, $proxy_ip);
curl_setopt($this->ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($this->ch, CURLOPT_NOSIGNAL, true);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_TIMEOUT, 1);
curl_setopt($this->ch, CURLOPT_URL, $url);
curl_setopt($this->ch, CURLOPT_USERAGENT, $this->useragents[array_rand($this->useragents, 1)]);
$result = curl_exec($this->ch);
$httpcode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
if($httpcode >= 200 && $httpcode < 300) {
return $result;
}
return $httpcode; // Always returns 0
何が問題なのか、私にはまったくわかりません。私の cURL 設定は間違っていますか?
すべての外部リレーが機能するわけではありませんが、ローカル リレーは機能します。
OS: OSX、ただし Windows でもテスト済み
PHP: 5.3.5
cURL: 7.21.3