How to use the sshtunnel.getservice function in sshtunnel

To help you get started, we’ve selected a few sshtunnel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stephank / libvirtweb / rfbproxy.py View on Github external
# Should we tunnel over SSH?
   if 'sshhost' in info:
      sshtunnel.ammendfromconfig(info)

      def sshconnect(service):
         protocol = factory.buildProtocol(None)
         transport = sshtunnel.RFBSSHChannel(protocol)
         request = forwarding.packOpen_direct_tcpip(
               (info['vnchost'], info['vncport']),    # The remote endpoint
               ('localhost', 0))                      # The local endpoint
         log.msg("Opening VNC connection to %s:%d over SSH tunnel" % (info['vnchost'], info['vncport']))
         service.openChannel(transport, request)
         return service

      sshtunnel.getservice(reactor, info).addCallbacks(sshconnect, genericfailure)

   # We shouldn't tunnel, set up a regular connection
   else:
      log.msg("Attempting VNC connection to %s:%d" % (info['vnchost'], info['vncport']))
      reactor.connectTCP(info['vnchost'], info['vncport'], factory)

   return d