通过Tor控制协议更改Tor代理 [英] Change tor proxy by tor control protocol

查看:221
本文介绍了通过Tor控制协议更改Tor代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过Tor控制协议在PHP中自动更改Tor代理设置,但我不知道执行此操作的适当命令。我尝试过的

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

GETCONF HTTPProxyPort

但tor回答了:

510 Unrecognized command

什么是控制tor前面使用的代理的关键字?
谢谢

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

推荐答案

重新生成tor路线的正确命令是 SIGNAL NEWNYM 。下面是一些简单的示例代码:

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 );
?>

看看控制规范的3.7节

代理地址和端口保持不变,并且永远不变。这是改变的路线。如果要通过控制进行身份验证并获取代理地址和端口,请发出 GETCONF

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.

但是, HTTPProxyAddr 不是有效的配置变量, HTTPProxy 是有效的配置变量。在此处 https://www.torproject.org可以找到所有配置变量的列表。 /docs/tor-manual.html.en 。当请求了错误的配置变量时,某些版本的Tor确实抛出了510。

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.

这篇关于通过Tor控制协议更改Tor代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆