[Twisted-Python] Tunneling using conch (with application.service)

Sean Hollingsworth smhollingsworth at gmail.com
Thu Aug 6 09:47:43 MDT 2009


I’ve got an app written that runs as a service using
twisted.application.service that I need to tunnel through SSH. Right now, I
use a script that makes use of Paramiko (and runs separate from my app) to
set up a tunnel. That more or less works, but I’ve had some problems with
the tunnel just going away and would like to integrate the tunneling into
the app, using conch. I’ve found an example of tunneling via conch, at
http://twistedmatrix.com/pipermail/twisted-python/2009-February/019196.html,
that I think I can use as a base to add the code to my app.

Right now my app is basically:

class DataPuller(service.Service):
    ...Code for my app...
    ... The app pulls data from a database and I can only connect to the
server via SSH...

application = service.Application(‘Data_puller’)
dpService = DataPuller()
dpService.setServiceParent(application)

My main problems are that I’m not sure whether or not the example linked to
above is a good one for tunneling with conch and, if it is, how do I merge
the example tunneling code with my app code. From the example, where the
code is:

 class Connection(connection.SSHConnection):
        .
        .
        .
        def serviceStarted(self):

Do I instantiate my DataPuller class there, in serviceStarted (and not
subclass from service.Service)? If so, how do I wrap the tunneling code so
that I can make it a service? If not, do I need put the tunneling code
inside my DataPuller class? What would that look like?

Any help will be greatly appreciated.

Sean M Hollingsworth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20090806/9f8cfb99/attachment.html>


More information about the Twisted-Python mailing list