TorCtl: Python Tor Control

TorCtl is a python Tor Controller Protocol library with extensions to support path building with various constraints on node and path selection, as well as statistics gathering. It is fully pydoced, and if I do say so myself is pretty damn spiffy, and supports interaction with Tor path selection at several different layers of abstraction.

The lowest level of interaction is to use the TorCtl.TorCtl module. Typically this is done by importing TorCtl.TorCtl and creating a TorCtl.Connection and extending from TorCtl.EventHandler. This class receives Tor controller events packaged into python classes from a TorCtl.Connection.

The next level up is to use the TorCtl.PathSupport module. This is done by importing TorCtl.PathSupport and instantiating or extending from PathSupport.PathBuilder, which itself extends from TorCtl.EventHandler. This class handles circuit construction and stream attachment subject to policies defined by PathSupport.NodeRestrictor and PathSupport.PathRestrictor implentations, which govern node selection and path selection constraints respectively, and have several concrete implementations provided already.

If you are interested in gathering statistics, you can instead instantiate or extend from StatsSupport.StatsHandler, which is another event handler implementation with hooks to record statistics on circuit creation, stream bandwidth, and circuit failure information.