[tor-dev] use tor controller to detect circuit/path change

Damian Johnson atagar at torproject.org
Tue Oct 30 19:31:36 UTC 2012


> Hi, I'm new to Tor controller,
>
> Tor client usually open 3 circuits, one for current use and the other 2 for
> standby.
>
> Tor will change the current circuit/path in use from time to time, depending
> on the network load dynamics
>
> I'm wondering whether it is possible to use Tor controller to detect when
> the circuit/path in use is changed
> and obtain the list of IP addresses of those relay nodes.

Hi esolve. I'm pretty sure that you'll simply want to write a script
that listens for CIRC events...
https://gitweb.torproject.org/torspec.git/blob/HEAD:/control-spec.txt#l1232

The main controller libraries at present are...

- txtorcon (https://txtorcon.readthedocs.org/en/latest/) - controller
library for twisted apps
- stem (https://stem.readthedocs.org/en/latest/index.html) - general
controller library that'll replace TorCtl
- torctl (https://gitweb.torproject.org/pytorctl.git/) - the original
and most stable controller library

If you want an example for using stem then I'd be happy to write you
one later. Ravi and I are currently working to improve its event
handling support so it's presently a bit rough for your use case, but
still perfectly doable.

Cheers! -Damian


More information about the tor-dev mailing list