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 a TLSClient instance with the provided name and configuration.

Args:

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

Returns:

TLSClient: Instance of the created TLSClient.

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

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

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 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)

Creates a new instance.

Args:

*args: The variable arguments list. **wargs: The keyword arguments list.

Returns:

ControllersBase: The newly created instance.

Note:

Note

The instance will be automatically added to the list of controllers to be cleaned up later. It guarantees that all the controller instances are followed up and cleaned up when the associate method ‘controllers_cleanup(cls)’ is called.

Important

Do not override this method in subclasses to maintain this functionality.

classmethod controllers_cleanup()

Cleans up all controller instances.

It calls clean_up() for each controller in the list. If a cleanup fails, an error is raised, but the method continues processing the remaining controllers.

Returns:
bool: True indicating that all controllers were cleaned up successfully.

Otherwise, False is returned when an error occurs during the cleanup process.