Change tor proxy by tor control protocol

怎甘沉沦 提交于 2019-12-12 01:10:12

问题


I want to change automaticaly tor proxy settings in PHP through tor control protocol, but I don't know the appropriate command to do that. I tried :

GETCONF HTTPProxyAddr

or

GETCONF HTTPProxyPort

but tor answered :

510 Unrecognized command

What are the keywords to control the proxy used in front of tor? Thanks


回答1:


The correct command to regenerate a tor route is SIGNAL NEWNYM. Here's some quick sample code:

<?php
    $sock = fsockopen( 'unix://control' );
    fwrite( $sock, "AUTHENTICATE\n" );
    echo fread( $sock, 128 );
    fwrite( $sock, "SIGNAL NEWNYM\n" );
    echo fread( $sock, 128 );
?>

Look at Section 3.7 of the Control Specification.

Note that the proxy address and port stay the same and never change. It's the route that is changed. If you want to authenticate and grab the proxy address and port via control issue a GETCONF.

However, HTTPProxyAddr is not a valid configuration variable, HTTPProxy is. A list of all configuration variables can be found here https://www.torproject.org/docs/tor-manual.html.en. Some versions of Tor did throw a 510 when an incorrect configuration variable was requested.



来源:https://stackoverflow.com/questions/20456437/change-tor-proxy-by-tor-control-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!