Module Expr Str Import alias ImportFrom alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ClassDef bases NameLoad body Assign NameStore Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Dict Assign AttributeStore NameLoad attr Dict decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str ImportFrom alias Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr If CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index AttributeLoad NameLoad attr orelse If CompareIn AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index AttributeLoad NameLoad attr attr NameLoad orelse TryExcept body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index AttributeLoad NameLoad attr ListLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr If CompareNotIn NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Assign NameStore Call NameLoad NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad For NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore BoolOpOr NameLoad AttributeLoad AttributeLoad NameLoad attr attr TryExcept body For NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Delete SubscriptDel AttributeLoad NameLoad attr Index NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad AttributeLoad NameLoad attr attr TryExcept body Delete SubscriptDel AttributeLoad NameLoad attr Index AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Call AttributeLoad Str attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return NameLoad decorator_list decorator_list
N/A N/A 
.. topic:: 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.

 N/A logging twisted.internet defer endpoints twisted.internet.ssl ClientContextFactory OpenSSL SSL oppy.connection.connection Connection oppy.connection.connectionbuildtask ConnectionBuildTask oppy.connection.definitions V3_CIPHER_STRING TLSClientContextFactory N/A ClientContextFactory N/A N/A isClient 1 N/A method N/A SSL TLSv1_METHOD N/A _contextFactory N/A SSL Context getContext N/A N/A self N/A N/A N/A context N/A N/A self _contextFactory N/A self method N/A N/A N/A context set_cipher_list V3_CIPHER_STRING N/A context N/A N/A ConnectionManager N/A object N/A N/A A pool of TLS connections to entry nodes. __init__ N/A N/A self N/A N/A N/A N/A N/A logging debug Connection manager created. N/A N/A self _connection_dict N/A N/A N/A self _pending_request_dict N/A N/A getConnection N/A N/A self micro_status_entry N/A N/A N/A 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:

            1. We already have an open TLS connection to the requested relay.
               In this case, immediately callback the deferred with the
               open connection.
            2. 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.
            3. 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.

        :param stem.descriptor.server_descriptor.RelayDescriptor relay:
            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

        XXX raises:
         twisted.internet reactor N/A m micro_status_entry N/A d N/A N/A defer Deferred N/A N/A N/A m fingerprint N/A self _connection_dict N/A N/A N/A N/A d callback N/A N/A self _connection_dict N/A N/A m fingerprint N/A N/A N/A N/A m fingerprint N/A self _pending_request_dict N/A N/A N/A N/A N/A N/A self _pending_request_dict N/A N/A m fingerprint append d N/A N/A N/A N/A f N/A N/A endpoints connectProtocol N/A N/A endpoints SSL4ClientEndpoint reactor N/A m address N/A m or_port N/A TLSClientContextFactory N/A ConnectionBuildTask self m N/A N/A N/A f addErrback N/A self _initialConnectionFailed N/A m fingerprint N/A N/A N/A self _pending_request_dict N/A N/A m fingerprint N/A d N/A N/A N/A Exception N/A e N/A N/A N/A N/A self _initialConnectionFailed e N/A m fingerprint N/A d N/A _initialConnectionFailed N/A N/A self reason fingerprint N/A N/A N/A N/A N/A self connectionTaskFailed None reason fingerprint N/A connectionTaskSucceeded N/A N/A self connection_task N/A N/A N/A For every pending request for this connection, callback the request
        deferred with this open connection, then remove this connection
        from the pending map and add to the connection map.

        Called when the TLS connection to the IP of relay with
        *fingerprint* opens successfully.

        :param oppy.connection.connection.Connection result: the successfully
            opened connection
        :param str fingerprint: fingerprint of relay we have connected to
         N/A fprint N/A N/A connection_task micro_status_entry fingerprint N/A N/A fprint N/A self _pending_request_dict N/A N/A msg N/A N/A ConnectionManager notified that a connection to {} was made successfully, but ConnectionManager has no reference to this connection. Dropping. format fprint N/A N/A N/A logging debug msg N/A N/A connection N/A Connection self connection_task N/A N/A N/A self _connection_dict N/A fprint connection N/A N/A connection transport N/A connection_task transport N/A N/A connection_task transport None N/A N/A N/A connection transport wrappedProtocol connection N/A request N/A N/A self _pending_request_dict N/A fprint N/A N/A N/A N/A request callback connection N/A N/A N/A self _pending_request_dict N/A fprint N/A connectionTaskFailed N/A N/A self connection_task reason fprint N/A None N/A N/A For every pending request for this connection, errback the request
        deferred. Remove this connection from the pending map.

        Called when the TLS connection to the IP of relay with
        *fingerprint* fails.

        :param reason reason: reason this connection failed
        :param str fingerprint: fingerprint of the relay this connection
            failed to
         N/A fprint N/A fprint N/A N/A connection_task micro_status_entry fingerprint N/A N/A N/A request N/A N/A self _pending_request_dict N/A fprint N/A N/A N/A N/A request errback reason N/A N/A N/A self _pending_request_dict N/A fprint N/A N/A N/A KeyError N/A N/A msg N/A N/A ConnectionManager notified that a connection to {} failed, but ConnectionManager has no reference to this connection. Dropping. format fprint N/A N/A N/A logging debug msg N/A removeConnection N/A N/A self connection N/A N/A N/A Remove the connection to relay with *fingerprint* from the
        connection pool.

        :param str fingerprint: fingerprint of connection to remove
         N/A fprint N/A N/A connection micro_status_entry fingerprint N/A N/A N/A N/A N/A self _connection_dict N/A N/A N/A connection micro_status_entry fingerprint N/A msg N/A N/A ConnectionManager removed a connection to {} format fprint N/A N/A N/A logging debug msg N/A N/A N/A KeyError N/A N/A msg N/A N/A ConnectionManager received a request to remove connection to {}, but CircuitManager has no reference to that connection. format fprint N/A N/A N/A logging debug msg N/A shouldDestroyConnection N/A N/A self connection N/A N/A N/A 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.

        :param str fingerprint: fingerprint of connection to check
        :returns: **bool** **True** if we think this connection should be
            destroyed
         N/A True N/A N/A