[英]How can I change my tor process' endpoint in stem?
I'm using the stem
to control a tor node created with stem.process.launch_tor_with_config
. 我正在使用stem
来控制用stem.process.launch_tor_with_config
创建的tor节点。 I've also created a stem.control.Controller
that is operating on the aforementioned process' control port. 我还创建了一个在前面提到的进程控制端口上运行的stem.control.Controller
。
How can I change the exit node? 如何更改退出节点? I looked at stem.controller.Controller.new_circuit
, but this appears to change the intermediate nodes, preserving the endpoint. 我查看了stem.controller.Controller.new_circuit
,但这似乎改变了中间节点,保留了端点。
Does anybody know how this could be done? 有谁知道如何做到这一点?
Thanks! 谢谢!
Edit: 编辑:
So I think I may be misunderstanding something fundamental, but I can't seem to wrap my head around it. 所以我认为我可能误解了一些基本的东西,但我似乎无法绕过它。 I tried calling Controller.get_circuits()
and found a list of CircuitEvent
objects. 我尝试调用Controller.get_circuits()
并找到了CircuitEvent
对象的列表。 Does this mean that a single process can handle multiple circuits? 这是否意味着单个进程可以处理多个电路? If so, how do I select one for use? 如果是这样,我该如何选择使用?
Note that I'm directing HTTP requests to through Privoxy, which in turn is forwarding it to the tor process' SOCKS port. 请注意,我正在通过Privoxy引导HTTP请求,而Privoxy又将其转发到tor进程的SOCKS端口。
Edit 2: 编辑2:
I found something that works, but I don't know how it works, which worries me. 我发现了一些有效的东西,但我不知道它是如何工作的,这让我很担心。 I'll gladly award an answer to anyone who can either: 我很乐意为任何能够:
Here's what I've done: 这就是我所做的:
for circuit in controller.get_circuits():
controller.close_circuit(circuit.id)
There it is. 它就是。 The external IP changed, so I know I've done something but hell if I know exactly what. 外部知识产权发生了变化,所以我知道我已经做了一些事情,但如果我知道究竟是什么的话。
You have a couple options to use a specific exit... 您有几个选项可以使用特定的退出...
https://stem.torproject.org/tutorials/to_russia_with_love.html https://stem.torproject.org/tutorials/to_russia_with_love.html
https://stem.torproject.org/api/control.html#stem.control.Controller.extend_circuit https://stem.torproject.org/api/control.html#stem.control.Controller.extend_circuit
If the question you're trying to ask is really 'how do I get a new IP address' then that's a question we're more reluctant to answer. 如果您要问的问题是“我如何获得新的IP地址”,那么这是一个我们更不愿意回答的问题。 Partly because it's primarily for ban evasion or SEO, and partly because repeated circuit creation puts a high load on the Tor network. 部分是因为它主要用于禁止逃避或搜索引擎优化,部分原因是重复的电路创建给Tor网络带来了很大的负担。
As for why your IP seems to change when you call close_circuit(), that's because Tor then needs to recreate a new circuit on your behalf for the following request. 至于为什么在调用close_circuit()时你的IP似乎发生了变化,那是因为Tor需要代表你为以下请求重新创建一个新电路。 There is no guarantee that the IP will be new, and doing so involves a fair bit of traffic to telescope your connection through three fresh hops. 无法保证IP是新的,这样做需要相当多的流量来通过三个新的跳跃来连接你的连接。
I'm not often on StackOverflow so if you have further questions about scripting against Tor then I would suggest the tor-dev@ email list... 我不经常在StackOverflow上,所以如果你有关于Tor的脚本的进一步问题,那么我会建议tor-dev @ email列表......
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev/ https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev/
Cheers! 干杯! -Damian (stem's author) -Damian(干的作者)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.