Package x2go :: Module rforward :: Class X2GoRevFwTunnel

[frames] | no frames]

# Class X2GoRevFwTunnel

source code

            object --+
                     |
    threading._Verbose --+
                         |
          threading.Thread --+
                             |
                            X2GoRevFwTunnel

Known Subclasses:
  - sftpserver.X2GoRevFwTunnelToSFTP

X2GoRevFwTunnel class objects are used to reversely tunnel X2Go audio, X2Go printing and X2Go folder sharing / device mounting through Paramiko/SSH.

Instance Methods

__del__(self) Class destructor. | source code

__init__(self, server_port, remote_host, remote_port, ssh_transport, session_instance=None, logger=None, loglevel=56) Setup a reverse tunnel through Paramiko/SSH. | source code

cancel_port_forward(self, address, port) Cancel a port forwarding request. | source code

notify(self) Notify an X2GoRevFwTunnel instance of an incoming Paramiko/SSH channel. | source code

pause(self) Prevent acceptance of new incoming connections through the Paramiko/SSH reverse forwarding tunnel. | source code

resume(self) Resume operation of the Paramiko/SSH reverse forwarding tunnel and continue accepting new incoming connections. | source code

run(self) This method gets run once an X2GoRevFwTunnel has been started with its start() method. | source code

stop_thread(self) Stops this X2GoRevFwTunnel thread completely. | source code

Inherited from `threading.Thread`: `__repr__`, `getName`, `isAlive`, `isDaemon`, `is_alive`, `join`, `setDaemon`, `setName`, `start` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `threading.Thread`: `daemon`, `ident`, `name` Inherited from `object`: `__class__`

Method Details

### __init__(self, server_port, remote_host, remote_port, ssh_transport, session_instance=None, logger=None, loglevel=56)
(Constructor)

source code

Setup a reverse tunnel through Paramiko/SSH.

After the reverse tunnel has been setup up with X2GoRevFwTunnel.start() it waits for notification from X2GoRevFwTunnel.notify() to accept incoming channels. This notification (X2GoRevFwTunnel.notify() gets called from within the transport's TCP handler function x2go_transport_tcp_handler of the X2GoSession instance.

Parameters:
  - `server_port` (int) - the TCP/IP port on the X2Go server (starting point of the tunnel), normally some number above 30000
  - `remote_host` (str) - the target address for reversely tunneled traffic. With X2Go this should always be set to the localhost (IPv4) address.
  - `remote_port` (int) - the TCP/IP port on the X2Go client (end point of the tunnel), normally an application's standard port (22 for SSH, 4713 for pulse audio, etc.)
  - `ssh_transport` (`paramiko.Transport` instance) - the X2GoSession's Paramiko/SSH transport instance
  - `logger` (X2GoLogger instance) - you can pass an X2GoLogger object to the X2GoRevFwTunnel constructor
  - `loglevel` (int) - if no X2GoLogger object has been supplied a new one will be constructed with the given loglevel
Overrides: object.__init__

### cancel_port_forward(self, address, port)

source code

Cancel a port forwarding request. This cancellation request is sent to the server and on the server the port forwarding should be unregistered.

Parameters:
  - `address` (`str`) - remote server address
  - `port` (`int`) - remote port

### notify(self)

source code

Notify an X2GoRevFwTunnel instance of an incoming Paramiko/SSH channel.

If an incoming reverse tunnel channel appropriate for this instance has been detected, this method gets called from the X2GoSession's transport TCP handler.

The sent notification will trigger a `thread.Condition()` waiting for notification in X2GoRevFwTunnel.run().

### pause(self)

source code

Prevent acceptance of new incoming connections through the Paramiko/SSH reverse forwarding tunnel. Also, any active connection on this X2GoRevFwTunnel instance will be closed immediately, if this method is called.

### run(self)

source code

This method gets run once an X2GoRevFwTunnel has been started with its start() method. Use X2GoRevFwTunnel.stop_thread() to stop the reverse forwarding tunnel again. You can also temporarily lock the tunnel down with X2GoRevFwTunnel.pause() and X2GoRevFwTunnel.resume()).

X2GoRevFwTunnel.run() waits for notifications of an appropriate incoming Paramiko/SSH channel (issued by X2GoRevFwTunnel.notify()). Appropriate in this context means, that its start point on the X2Go server matches the class's property `server_port`.

Once a new incoming channel gets announced by the notify() method, a new X2GoRevFwChannelThread instance will be initialized. As a data stream handler, the function x2go_rev_forward_channel_handler() will be used.

The channel will last till the connection gets dropped on the X2Go server side or until the tunnel gets paused by an X2GoRevFwTunnel.pause() call or stopped via the X2GoRevFwTunnel.stop_thread() method.

Overrides: threading.Thread.run