Connector¶
These helper classes are either used directly or indirectly to help with connecting to the
control port. They simply provide a connect() method returning a full-duplex
link as a tuple of StreamReader and StreamWriter.
You can easily create your own and then provide it to the Controller, for instance
this can be handy to pass through a socks proxy or establish a TLS connection.
Base connector¶
This is a base abstract class for all connectors, derive your own connector from this class!
- class aiostem.connector.ControlConnector[source]¶
Bases:
ABCBase class for all connector types used by the controller.
These are simply helper classes providing a pair of reader and writer needed to perform actions on the target control port.
- abstractmethod async connect() tuple[StreamReader, StreamWriter][source]¶
Open an asynchronous connection to the target control port.
- Returns:
tuple[StreamReader,StreamWriter] – A tuple forming a full-duplex asyncio stream.
TCP connector¶
- aiostem.connector.DEFAULT_CONTROL_HOST: str = '127.0.0.1'¶
Default host value when connecting to a TCP controller.
- aiostem.connector.DEFAULT_CONTROL_PORT: int = 9051¶
Default port value when connecting to a TCP controller.
- class aiostem.connector.ControlConnectorPort[source]¶
Bases:
ControlConnectorTor connector using a local or report TCP port.
- __init__(host: str = '127.0.0.1', port: int = 9051) None[source]¶
Create a controller connector using a TCP host and port.
Hint
Use
Controller.from_port()for an automated use of this class.
- async connect() tuple[StreamReader, StreamWriter][source]¶
Open an asynchronous connection to the target’s TCP port.
- Returns:
tuple[StreamReader,StreamWriter] – A tuple forming a full-duplex asyncio stream.
Unix socket connector¶
- aiostem.connector.DEFAULT_CONTROL_PATH: str = '/var/run/tor/control'¶
Default path when connecting to a controller through an UNIX socket.
- class aiostem.connector.ControlConnectorPath[source]¶
Bases:
ControlConnectorTor connector using a local unix socket.
- __init__(path: str = '/var/run/tor/control') None[source]¶
Create a controller connector using a local unix socket.
Hint
Use
Controller.from_path()for an automated use of this class.- Parameters:
path (
str, default:'/var/run/tor/control') – Path to the unix socket on the local file system.
- async connect() tuple[StreamReader, StreamWriter][source]¶
Open an asynchronous connection to the target unix socket.
- Returns:
tuple[StreamReader,StreamWriter] – A tuple forming a full-duplex asyncio stream.