connection

Details

Connection objects represent TLS connections to Tor entry nodes. Connection objects have a few important jobs:

  • Do the initial handshake to authenticate the entry node and negotiate a Link Protocl version (currently oppy only supports Link Protocol Version 3)
  • Extract cells from incoming data streams and pass them to the appropriate circuit (based on circuit ID)
  • Write cells from circuits to entry nodes
  • Notify all associated circuits when the connection goes down
class connection.connection.Connection(relay)[source]

Bases: twisted.internet.protocol.Protocol

A TLS connection to an entry node.

writeCell(cell)[source]

Write a cell to this connections transport.

If this connection is not yet open, append to the cell_queue to be written when the connection opens up.

Parameters:cell (cell) – cell to write
dataReceived(data)[source]

We received data from the remote connection.

Extract cells from the data stream and send them along to be processed.

Parameters:data (str) – data received from remote end
connectionMade()[source]

Initial TLS connection made, immediately start the connection handshake.

addNewCircuit(circuit)[source]

Add new a new circuit to the circuit map for this connection.

Raise a ValueError if circuit.circuit_id already exists in self._circuit_map - that means something went very wrong.

Parameters:circuit (oppy.circuit.circuit.Circuit) – circuit to add to this connection’s circuit map
closeConnection()[source]

Close this connection and all associated circuits; notify the connection pool.

connectionLost(reason)[source]

Connection to relay has been lost; close this connection and all associated circuits; notify connection pool.

Parameters:reason (reason) – reason this connection was lost
circuitDestroyed(circuit_id)[source]

The circuit with circuit_id has been destroyed.

Remove this circuit from this connection’s circuit map if we know about it. If there are no remaining circuit’s using this connection, ask the connection pool if this connection should be closed and, if so, close this connection.

Parameters:circuit_id (int) – id of the circuit that was destroyed

Previous topic

connectionpool

Next topic

v3

This Page