[tor-dev] How to distribute Tor with other software

David Stainton dstainton415 at gmail.com
Wed May 21 10:24:09 UTC 2014

> You could use one of the controller libraries (stem if you want
> synchronous, txtorcon if async/Twisted) to do this; they don't have to
> modify the torrc directly, just manipulate configuration via GETCONF and
> SETCONF. For Tails, this probably won't work unless you're root until
> #11291 is fixed + merged.

I'm not saying that this would be appropriate for your python app...
but there are definitely ways for Twisted to interoperate with blocking APIs.
Laurens Van Houtven gave a pretty good talk about this at PyCon 2014:

>    d = serverFromString("onion:80:hiddenServiceDir=/foo/bar").listen(...)

This Twisted endpoints plugin system allows us to keep our Twisted
apps endpoint agnostic...
but requires that the appropriate Twisted endpoint parser is installed.

Tahoe-LAFS in particular gets a big win from this native Tor
integration because Foolscap (the wire protocol library used)
gets to be endpoint agnostic while Tahoe-LAFS can take care of some
Tor specific features.

> (For the other way, David has a pull-request into txsocksx so that
> things like "clientFromString('tor:blarg.onion')" will work via SOCKS to
> 9050 or 9150).

In my latest branch I wrote a DeferredDispatcher class
( which will be replaced by core Twisted api once twisted trac ticket
#6365 is resolved: https://twistedmatrix.com/trac/ticket/6365 ).
which can be used to coordinate multiple Tor client and server Twisted
endpoints with a single Tor process (per python process).
Work in progress in this branch here:


Here's an example program that uses Tor client and server endpoints.
It sets up a simple webserver listening to the hidden service endpoint,
retrieves the new onion and then uses the Tor client endpoint to connect
and query the webserver.


Eventually (soon maybe?) I'm going to write extensive documentation
and example code for assisting
Python developers to write apps with native Tor integration and
Tor-friendly features. The native Tor integration for
Tahoe-LAFS will serve as an excellent example case.



More information about the tor-dev mailing list