# Connections

class GvmConnection

  Python protocol for GvmConnection classes.

  __init__(*args, **kwargs)
  connect()

    Establish a connection to a remote server

  disconnect()

    Send data to the connected remote server

    Parameters:

      data – Data to be send to the server. Either utf-8 encoded string or bytes.

  finish_send()

    Indicate to the remote server you are done with sending data

  read()

    Read data from the remote server

    Returns:

      data as bytes

    Return type:

      bytes

  send(data)

    Send data to the connected remote server

    Parameters:

      data (bytes) – Data to be send to the server as bytes.

class SSHConnection

  SSH Class to connect, read and write from GVM via SSH

  __init__(*, timeout=60, hostname='127.0.0.1', port=22, username='gmp', password='', known_hosts_file=None, auto_accept_host=None, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, input=<built-in function input>, exit=<built-in function exit>)

    Create a new SSH connection instance.

    Parameters:

      - timeout (int | float | None) – Timeout in seconds for the connection.

      - hostname (str | None) – DNS name or IP address of the remote server. Default is 127.0.0.1.

      - port (int | None) – Port of the remote SSH server. Default is port 22.

      - username (str | None) – Username to use for SSH login. Default is “gmp”.

      - password (str | None) – Password to use for SSH login. Default is “”.

  connect()

    Connect to the SSH server and authenticate to it

  disconnect()

    Disconnect and close the connection to the remote server

class TLSConnection

  TLS class to connect, read and write from a remote GVM daemon via TLS secured socket.

  __init__(*, certfile=None, cafile=None, keyfile=None, hostname='127.0.0.1', port=9390, password=None, timeout=60)

    Create a new TLSConnection instance.

    Parameters:

      - timeout (int | float | None) – Timeout in seconds for the connection.

      - hostname (str | None) – DNS name or IP address of the remote TLS server.

      - port (int | None) – Port for the TLS connection. Default is 9390.

      - certfile (str | None) – Path to PEM encoded certificate file. See python certificates for details.

      - cafile (str | None) –

        Path to PEM encoded CA file. See python certificates for details.

      - keyfile (str | None) –

        Path to PEM encoded private key. See python certificates for details.

      - password (str | None) – Password for the private key. If the password argument is not specified and a password is required it will be interactively prompt the user for a password.

  connect()

    Establish a connection to a remote server

  disconnect()

    Close the SSL layer then disconnect from the remote server

class UnixSocketConnection

  UNIX-Socket class to connect, read, write from a daemon via direct communicating UNIX-Socket

  __init__(*, path='/run/gvmd/gvmd.sock', timeout=60)

    Create a new UnixSocketConnection instance.

    Parameters:

      - path (str | PathLike[str] | None) – Path to the socket. Default is “/run/gvmd/gvmd.sock”.

      - timeout (int | float | None) – Timeout in seconds for the connection. Default is 60 seconds.

  connect()

    Connect to the UNIX socket

class DebugConnection

  Wrapper around a connection for debugging purposes

  Allows to debug the connection flow including send and read data. Internally it uses the python logging framework to create debug messages. Please take a look at the logging tutorial for further details.

  Example:

      import logging

      logging.basicConfig(level=logging.DEBUG)

      socket_connection = UnixSocketConnection(path="/var/run/gvm.sock")
      connection = DebugConnection(socket_connection)
      gmp = GMP(connection=connection)

  __init__(connection)

    Create a new DebugConnection instance.

    Parameters:

      connection (GvmConnection) – GvmConnection to observe