x2go.rforward module¶
X2Go reverse SSH/Paramiko tunneling provides X2Go sound, X2Go printing and X2Go sshfs for folder sharing and mounting remote devices in X2Go terminal server sessions.
- class x2go.rforward.X2GoRevFwChannelThread(channel, remote=None, **kwargs)[source]¶
Bases:
Thread
Starts a thread for each incoming Paramiko/SSH data channel trough the reverse forwarding tunnel.
- class x2go.rforward.X2GoRevFwTunnel(server_port, remote_host, remote_port, ssh_transport, session_instance=None, logger=None, loglevel=56)[source]¶
Bases:
Thread
x2go.rforward.X2GoRevFwTunnel
class objects are used to reversely tunnel X2Go audio, X2Go printing and X2Go folder sharing / device mounting through Paramiko/SSH.- cancel_port_forward(address, port)[source]¶
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 addressport (
int
) – remote port
- notify()[source]¶
Notify an
x2go.rforward.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
x2go.session.X2GoSession
’s transport TCP handler.The sent notification will trigger a
thread.Condition()
waiting for notification inX2GoRevFwTunnel.run()
.
- pause()[source]¶
Prevent acceptance of new incoming connections through the Paramiko/SSH reverse forwarding tunnel. Also, any active connection on this
x2go.rforward.X2GoRevFwTunnel
instance will be closed immediately, if this method is called.
- resume()[source]¶
Resume operation of the Paramiko/SSH reverse forwarding tunnel and continue accepting new incoming connections.
- run()[source]¶
This method gets run once an
x2go.rforward.X2GoRevFwTunnel
has been started with itsstart()
method. Usex2go.rforward.X2GoRevFwTunnel
.stop_thread() to stop the reverse forwarding tunnel again. You can also temporarily lock the tunnel down withX2GoRevFwTunnel.pause()
andX2GoRevFwTunnel.resume()
).X2GoRevFwTunnel.run()
waits for notifications of an appropriate incoming Paramiko/SSH channel (issued byX2GoRevFwTunnel.notify()
). Appropriate in this context means, that its start point on the X2Go server matches the class’s propertyserver_port
.Once a new incoming channel gets announced by the
notify()
method, a newx2go.rforward.X2GoRevFwChannelThread
instance will be initialized. As a data stream handler, the functionx2go_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 theX2GoRevFwTunnel.stop_thread()
method.
- stop_thread()[source]¶
Stops this
x2go.rforward.X2GoRevFwTunnel
thread completely.
- x2go.rforward.x2go_rev_forward_channel_handler(chan=None, addr='', port=0, parent_thread=None, logger=None)[source]¶
Handle the data stream of a requested channel that got set up by a
x2go.rforward.X2GoRevFwTunnel
(Paramiko/SSH reverse forwarding tunnel).The channel (and the corresponding connections) close either …
… if the connecting application closes the connection and thus, drops the channel, or
… if the
x2go.rforward.X2GoRevFwTunnel
parent thread gets paused. The call ofX2GoRevFwTunnel.pause()
on the instance can be used to shut down all incoming tunneled SSH connections associated to thisx2go.rforward.X2GoRevFwTunnel
instance from within a Python X2Go application.
- Parameters:
chan (
class
) – channel (Default value = None)addr (
str
) – bind address (Default value = ‘’)port (
int
) – bind port (Default value = 0)parent_thread (
x2go.rforward.X2GoRevFwTunnel
instance) – the callingx2go.rforward.X2GoRevFwTunnel
instance (Default value = None)logger (
x2go.log.X2GoLogger
instance) – you can pass anx2go.log.X2GoLogger
object to thex2go.rforward.X2GoRevFwTunnel
constructor (Default value = None)
- x2go.rforward.x2go_transport_tcp_handler(chan, origin, server)[source]¶
An X2Go customized TCP handler for the Paramiko/SSH
Transport()
class.Incoming channels will be put into Paramiko’s default accept queue. This corresponds to the default behaviour of Paramiko’s
Transport
class.However, additionally this handler function checks the server port of the incoming channel and detects if there are Paramiko/SSH reverse forwarding tunnels waiting for the incoming channels. The Paramiko/SSH reverse forwarding tunnels are initiated by an
x2go.session.X2GoSession
instance (currently supported: reverse tunneling auf audio data, reverse tunneling of SSH requests).If the server port of an incoming Paramiko/SSH channel matches the configured port of an
x2go.rforward.X2GoRevFwTunnel
instance, this instance gets notified of the incoming channel and a newx2go.rforward.X2GoRevFwChannelThread
is started. Thisx2go.rforward.X2GoRevFwChannelThread
then takes care of the new channel’s incoming data stream.- Parameters:
chan (
paramiko.Channel
object) – a Paramiko channel objectorigin (
tuple
) – host/port tuple where a connection originates fromserver (
tuple
) – host/port tuple where to connect to