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

meejah meejah at meejah.ca
Wed May 21 04:10:24 UTC 2014

Micah Lee <micah at micahflee.com> writes:

> When you run onionshare.py, it modifies /etc/tor/torrc and reloads the
> Tor config, and when it's done it restores the original torrc and
> reloads again.

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.

Even better, with some work that David Stainton has been pushing forward
in txtorcon [1] for use with Tahoe-LAFS, very soon making "whatever
stuff" happen so you can cause a new hidden service to appear will be
one line (serverFromString is a pluggable Twisted endpoint API):

   d = serverFromString("onion:80").listen(...)

or, if you already have keys:

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

The "stuff" will depend, but will be a newly launched tor worst-case or
a suitable local tor best-case. I realize this doesn't help you right
away ;) but there are APIs to make this pretty straightforward with
txtorcon right now; see these lines for an example:


In the above save() will write to a file if you want, or to a
currently-connecting running Tor. txtorcon concentrates on configuring
running Tor instances; there may be better torrc-manipulation things in
Stem but I don't know off the top of my head.

(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).

[1] -- gruesome details of his latest branch here, and there are some
       relevant ones in my repository as well:


More information about the tor-dev mailing list