rddr.protocols package¶
Submodules¶
rddr.protocols.protocol module¶
-
class
rddr.protocols.protocol.RddrProtocol¶ Bases:
abc.ABCAbstract class to be used as a base for concrete protocols.
-
abstract
create_server(host, port)¶ Coroutine. Creates a server socket.
- Parameters
host (
str) – Hostname/IP to bind server toport (
int) – Port to bind server to
- Return type
None
-
get_stream_addr(stream)¶ Given an asyncio stream (either StreamReader or StreamWriter) returns a string representing the host and port of the party on the other end of the streams. Format: “<host>:<port>” May return None if address cannot be retrieved.
- Parameters
stream (
Union[StreamReader,StreamWriter]) – StreamReader or StreamWriter used to communicate with remote party- Return type
Optional[str]
-
abstract async
open_connection(host, port)¶ Abstract coroutine. Opens a connection to host:port. Returns (StreamReader, StreamWriter)
- Parameters
host (
str) – Host to connect toport (
int) – Port to connect to
- Return type
Tuple[StreamReader,StreamWriter]
-
abstract
rddr.protocols.protocol_factory module¶
-
rddr.protocols.protocol_factory.rddr_protocol_factory(protocol)¶ Given a protocol specified as a string, create and return an instance of the appropriate subclass of
RddrProtocol. Raises ValueError on unsupported protocol input.- Parameters
protocol (
str) – Supported protocols: tcp, ssh, ssl
rddr.protocols.protocol_ssh module¶
-
class
rddr.protocols.protocol_ssh.RddrProtocolSsh¶ Bases:
rddr.protocols.protocol.RddrProtocol-
create_server(host, port)¶ Not yet implemented.
- Parameters
host (
str) –port (
int) –
- Return type
None
-
async
open_connection(host, port)¶ Not yet implemented.
- Parameters
host (
str) –port (
int) –
- Return type
Tuple[StreamReader,StreamWriter]
-
rddr.protocols.protocol_ssl module¶
-
class
rddr.protocols.protocol_ssl.RddrProtocolSsl(cert='certs/clientcert.pem', key='certs/clientkey.pem')¶ Bases:
rddr.protocols.protocol.RddrProtocolSupport for SSL on top of TCP
- Parameters
cert (
str) – Path to the certificate filekey (
str) – Path to the key file
-
create_server(host, port)¶ Coroutine. Creates a server socket with SSL context.
- Parameters
host (
str) – Hostname/IP to bind server toport (
int) – Port to bind server to
- Return type
None
-
async
open_connection(host, port)¶ Creates a new socket and wraps it in an encrypted session for forwarding data. Returns (StreamReader, StreamWriter).
- Parameters
host (
str) – Host to connect toport (
int) – Port to connect to
- Return type
Tuple[StreamReader,StreamWriter]
-
class
rddr.protocols.protocol_ssl.RddrSSLContext(protocol=<_SSLMethod.PROTOCOL_TLS: 2>)¶ Bases:
ssl.SSLContext
rddr.protocols.protocol_tcp module¶
-
class
rddr.protocols.protocol_tcp.RddrProtocolTcp¶ Bases:
rddr.protocols.protocol.RddrProtocolSupport for unencrypted TCP.
-
create_server(host, port)¶ Coroutine. Creates a server socket.
- Parameters
host (
str) – Hostname/IP to bind server toport (
int) – Port to bind server to
- Return type
None
-
async
open_connection(host, port)¶ Creates a new unencrypted socket for forwarding data. Returns (StreamReader, StreamWriter).
- Parameters
host (
str) – Host to connect toport (
int) – Port to connect to
- Return type
Tuple[StreamReader,StreamWriter]
-