[Twisted-Python] tor hidden service endpoint parser returns a deferred
dstainton415 at gmail.com
Fri May 2 07:59:05 MDT 2014
Today I wrote an endpoint parser for Meejah's txtorcon Tor Hidden
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:
And here's some example code that uses it:
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:
usewithtor pip install twisted
git clone https://github.com/david415/txtorcon.git
# defaults to my endpoint_parser_plugin branch
usewithtor python setup.py install
cd examples # CWD is now /home/human/projects/txtorcon/examples
# and then run the example code that uses this endpoint parser
More information about the Twisted-Python