tor hidden service endpoint parser returns a deferred

David Stainton dstainton415 at gmail.com
Fri May 2 13:59:05 UTC 2014


Greetings,

Today I wrote an endpoint parser for Meejah's txtorcon Tor Hidden
Service endpoint.

Now that we have foolscap ported to twisted endpoints (branch needs
review but I should probably rebase first) we'd like to be able to
simply specify an "onion" endpoint descriptor in Tahoe-LAFS
configuration... that way foolscap receives the descriptor and uses
serverFromString to generate the endpoint object.

This will work fine for the txsocksx tor client endpoint parser I
wrote... However the txtorcon Tor Hidden Service endpoint setup
requires a deferred to fire once the tor process is started... This
means that the endpoint parser needs to return a deferred. But this
breaks the interface!... meaning that foolscap or any other api using
this onion endpoint parser will have to special case the situation
where serverFromString returns a deferred.

Terrible! Or do you think this is not so terrible?
I am curious to know your thoughts and if any of you have alternate
solutions... since I am obviously doing it wrong.

Here's my txtorcon onion endpoint parser:
https://github.com/david415/txtorcon/blob/endpoint_parser_plugin/examples/hiddenservice_endpoint_parser.py

And here's some example code that uses it:
https://github.com/david415/txtorcon/blob/endpoint_parser_plugin/examples/launch_tor_endpoint.py

By the way (just in case you don't know)... you can test this parser
by placing it in the twisted/plugins directory... here's how I do it:

cd projects/virtualenv-1.11.1/
./virtualenv.py ~/virtenv-endpoints-test
. ~/virtenv-endpoints-test/bin/activate
usewithtor pip install twisted
cd ~/projects
git clone https://github.com/david415/txtorcon.git
# defaults to my endpoint_parser_plugin branch
cd txtorcon
usewithtor python setup.py install
cd examples # CWD is now /home/human/projects/txtorcon/examples
cp hiddenservice_endpoint_parser.py
/home/human/virtenv-endpoints-test/lib/python2.7/site-packages/twisted/plugins
# and then run the example code that uses this endpoint parser
python launch_tor_endpoint.py



Cheers,

David



More information about the tahoe-dev mailing list