Details
The ConnectionPool manages a pool of TLS connections to entry nodes. The main job of the ConnectionPool is to hand out TLS connections to requesting circuits and keep track of all the open connections. TLS connections to the same entry nodes are shared among circuits.
Bases: twisted.internet.ssl.ClientContextFactory
Bases: object
A pool of TLS connections to entry nodes.
Return a deferred which will fire (if connection attempt is successful) with a Connection Protocol made to relay.
There are three general cases to handle for incoming connection requests:
- We already have an open TLS connection to the requested relay. In this case, immediately callback the deferred with the open connection.
- We’re currently trying to connect to this relay. In this case, add the request to a pending request list for this relay. When the connection is made successfully, callback all pending request deferreds with the Connection, or errback all pending request deferreds on failure.
- We have no open or pending connections to this relay (i.e. this is the first connection request to this relay). In this case, create a new list of pending requests for this connection and add the current request. Create an SSL endpoint and add an appropriate callback and errback. If the request is successful, callback all pending requests with the open connection when it opens; errback all pending requests on failure.
Parameters: | relay (stem.descriptor.server_descriptor.RelayDescriptor) – relay to make a TLS connection to |
---|---|
Returns: | twisted.internet.defer.Deferred which, on success, will callback with an oppy.connection.connection.Connection Protocol object |
Remove the connection to relay with fingerprint from the connection pool.
Parameters: | fingerprint (str) – fingerprint of connection to remove |
---|
Return True if ConnectionPool thinks we should destroy the TLS connection to relay with fingerprint.
Called when the number of circuits on a connection drops to zero.
Note
For now, we always return True. Eventually, we may want to maintain a connection to any guards, even if there are no currently open circuits.
Parameters: | fingerprint (str) – fingerprint of connection to check |
---|---|
Returns: | bool True if we think this connection should be destroyed |