php - How to change tor ip each curl_init() -
in order resolve project, installed tor , privoxy on virtual station (debian). found how use curl , tor proxy, can't change ip adress @ each curl_init().
here code:
#!/usr/bin/env php <?php function get_url($url) { // ensure php curl library installed if(function_exists('curl_init')) { $timestart=microtime(true); $ip = '127.0.0.1'; $port = '9050'; $auth = 'rebootip'; $command = 'signal newnym'; $fp = fsockopen($ip,$port,$error_number,$err_string,10); if(!$fp) { echo "error: $error_number : $err_string"; return false; } else { fwrite($fp,"authenticate \"".$auth."\"\n"); $received = fread($fp,512); fwrite($fp,$command."\n"); $received = fread($fp,512); } fclose($fp); $ch = curl_init(); curl_setopt($ch,curlopt_followlocation,true); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_proxy, "127.0.0.1:9050"); curl_setopt($ch, curlopt_proxytype, 7); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_verbose, 0); $response = curl_exec($ch); $error = curl_error($ch); print_r($response."\n"); print_r($error."\n"); } else // php curl library not installed { echo 'please install php curl library'; } } echo get_url('http://ipinfo.io/'); is this-i need change configuration of "tor" , "privoxy" in order change ip address ?
thanks in advance :)
to different exit node ip address, setup multiple tor clients listening on port 9050, 9051, ... etc. on curl_init, change proxy port available tor client.
once have exhausted current list of tor clients, can restart them exit node. can send simple telnet commands directly tor client change exit node.
Comments
Post a Comment