TLSController

class mtf.network_port.tls_dtls_controller.TLSController

TLSController is responsible for creating and managing secure TLS client and server instances.

It provides methods to create, retrieve, and manage TLSClient and TLSServer instances using specified configurations and optional callbacks.

Attributes:

_secure_clients (dict): A dictionary to store TLSClient instances keyed by their names. _secure_servers (dict): A dictionary to store TLSServer instances keyed by their names.

classmethod create_secure_client(name: str, config: TLSConfigurator) TLSClient

Creates or updates a TLSClient instance with the provided name and configuration.

If a client with the same name exists but with a different configuration, the old client will be removed and a new one will be created.

Args:

name (str): Name of the client. config (TLSConfigurator): Configuration for the client.

Returns:

TLSClient: Instance of the created or updated TLSClient.

classmethod create_secure_server(name: str, config: TLSConfigurator, callback=None) TLSServer

Creates or updates a TLSServer instance with the provided name, configuration, and callback.

If a server with the same name exists but with a different configuration, the old server will be removed and a new one will be created.

Args:

name (str): Name of the server. config (TLSConfigurator): Configuration for the server. callback (function, optional): Callback function for the server.

Returns:

TLSServer: Instance of the created or updated TLSServer.

classmethod get_secure_client(name: str) TLSClient

Retrieves a TLSClient instance by name.

Args:

name (str): Name of the client.

Returns:

TLSClient: TLSClient instance associated with the provided name, if exists.

classmethod get_secure_server(name: str) TLSServer

Retrieves a TLSServer instance by name.

Args:

name (str): Name of the server.

Returns:

TLSServer: TLSServer instance associated with the provided name, if exists.

clean_up() bool

Simple cleanup method to clear all registered clients and servers.

Returns:

True if the cleanup was done successfully.

static __new__(cls, *args, **kwargs)

Initialize a new instance of the ControllerBase.

The instance will be automatically added to the list of controllers.

classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.