I'm using the stem
to control a tor node created with stem.process.launch_tor_with_config
. I've also created a stem.control.Controller
that is operating on the aforementioned process' control port.
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.
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. 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.
Edit 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:
- Explain why my approach works
- Show be a better approach and explain how that works
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.