rddr.proxies package

Submodules

rddr.proxies.incoming_proxy module

class rddr.proxies.incoming_proxy.RddrIncomingProxy(mp_manager, config)

Bases: rddr.proxies.proxy.RddrProxy

Implements an incoming proxy for RDDR. Replicates incoming requests to N applications and diffs their responses before forwarding their response.

Parameters

config (dict) – Dictionary of user config provided to RDDR at the command line

async _new_client(reader, writer)

Sets up two tunnels between the external client and all N application variants. One for each traffic direction.

Parameters
  • reader (StreamReader) – StreamReader instance

  • writer (StreamWriter) – StreamWriter instance

_setup_proxy(proxy_config)

Derived classes will call this function and pass it the config relevant to this proxy from the main config file. Will automatically instantiate the correct class derived from rddr.protocols.protocol.RddrProtocol based on the config.

Parameters

proxy_config (dict) – Section of the global config file relevant to this proxy

init_server()

Start an asyncio server for this proxy. Passes the _new_client member method as the new client callback.

rddr.proxies.outgoing_proxy module

class rddr.proxies.outgoing_proxy.RddrOutgoingProxy(mp_manager, config, dest)

Bases: rddr.proxies.proxy.RddrProxy

Implements an outgoing proxy for RDDR. Merges outgoing requests from N applications to some other microservice and replicates the response back.

Parameters
  • config (dict) – Dictionary of user config provided to RDDR at the command line

  • dest (str) – Destination address where incoming requests will be forwarded. String format: “<HOST>:<PORT>”

async _new_client(clients_r, clients_w)

Sets up two tunnels between the backend service and all N application variants. One for each traffic direction.

Parameters
  • clients_r (List[StreamReader]) – StreamReader instances

  • clients_w (List[StreamWriter]) – StreamWriter instances

_setup_proxy(proxy_config)

Derived classes will call this function and pass it the config relevant to this proxy from the main config file. Will automatically instantiate the correct class derived from rddr.protocols.protocol.RddrProtocol based on the config.

Parameters

proxy_config (dict) – Section of the global config file relevant to this proxy

init_server()

Start an asyncio server for this proxy. Passes the _new_client member method as the new client callback.

rddr.proxies.proxy module

class rddr.proxies.proxy.RddrProxy(mp_manager, config)

Bases: abc.ABC

This is an abstract class, a parent to the incoming and outgoing proxies used by RDDR.

Proxies are built on the asyncio library in Python 3.8. This framework was found to be faster and cleaner than the prior state machine-based implementations.

Parameters

config (dict) – Dictionary of user config provided to RDDR at the command line

async _new_client(reader, writer)

Callback function when a new client connects. Arguments are a StreamReader and StreamWriter instance associated with this connection. Complies with the interface documented by the asyncio library for the client_connected_cb passed to the asyncio.create_server function.

Subclasses should override this function and make use of the _tunnel helper coroutine to configure the necessary tunnels.

Parameters
  • reader (StreamReader) – StreamReader instance

  • writer (StreamWriter) – StreamWriter instance

_setup_proxy(proxy_config)

Derived classes will call this function and pass it the config relevant to this proxy from the main config file. Will automatically instantiate the correct class derived from rddr.protocols.protocol.RddrProtocol based on the config.

Parameters

proxy_config (dict) – Section of the global config file relevant to this proxy

async _tunnel(readers, writers)

Generic tunnel useful to incoming and outgoing proxy subclasses. No need to be overridden. The tunnel will read from arbitrarily many StreamReader instances in the readers list and diff their traffic using the diff module associated with this proxy. If the traffic is not divergent, it will be written to all StreamWriter instances in the writers list.

Parameters
  • readers (List[StreamReader]) – List of StreamReaders to read and diff.

  • writers (List[StreamWriter]) – List of StreamWriters who will be forwarded data sent by readers.

Module contents