# Python X2Go (Client) API Documentation (v0.6.1.4)

## x2go.forward module

Python Gevent based port forwarding server (openssh -L option) for the proxying of graphical X2Go elements.

class x2go.forward.X2GoFwServer(listener, remote_host, remote_port, ssh_transport, session_instance=None, session_name=None, subsystem=None, logger=None, loglevel=56)

  Bases: `StreamServer`

  `x2go.forward.X2GoFwServer` implements a gevent’s StreamServer based Paramiko/SSH port forwarding server.

  An `x2go.forward.X2GoFwServer` class object is used to tunnel graphical trafic through an external proxy command launched by a `X2GoProxy*` backend.

  close_channel()

    Close an open channel again.

  close_socket()

    Close the forwarding tunnel’s socket again.

  start()

    Start accepting the connections.

    If an address was provided in the constructor, then also create a socket, bind it and put it into the listening mode.

  stop()

    Stop the forwarding tunnel.

  x2go_forward_tunnel_handle(fw_socket, address)

    Handle for SSH/Paramiko forwarding tunnel.

    Parameters:

      - fw_socket (`obj`) – local end of the forwarding tunnel

      - address (`tuple`) – unused/ignored

x2go.forward.start_forward_tunnel(local_host='127.0.0.1', local_port=22022, remote_host='127.0.0.1', remote_port=22, ssh_transport=None, session_instance=None, session_name=None, subsystem=None, logger=None)

  Setup up a Paramiko/SSH port forwarding tunnel (like openssh -L option).

  The tunnel is used to transport X2Go graphics data through a proxy application like nxproxy.

  Parameters:

    - local_host (`int`) – local starting point of the forwarding tunnel (Default value = ‘127.0.0.1’)

    - local_port (`int`) – listen port of the local starting point (Default value = 22022)

    - remote_host (`str`) – from the endpoint of the tunnel, connect to host `<remote_host>`… (Default value = ‘127.0.0.1’)

    - remote_port (`int`) – on port `<remote_port>` (Default value = 22)

    - ssh_transport (`obj`) – the Paramiko/SSH transport (i.e. the X2Go session’s Paramiko/SSH transport object) (Default value = None)

    - session_instance (`obj`) – the `x2go.session.X2GoSession` instance that initiates this tunnel (Default value = None)

    - session_name (`str`) – the session name of the X2Go session this port forwarding server belongs to (Default value = None)

    - subsystem (`str`) – a custom string with a component name that tries to evoke a new tunnel setup (Default value = None)

    - logger (`obj`) – an X2GoLogger object (Default value = None)

  Returns:

    returns an `x2go.forward.X2GoFwServer` instance

  Return type:

    `obj`

x2go.forward.stop_forward_tunnel(fw_server)

  Tear down a given Paramiko/SSH port forwarding tunnel.

  Parameters:

    fw_server (`obj`) – an `x2go.forward.X2GoFwServer` instance as returned by the `start_forward_tunnel()` function