stream

Details

Streams are the interface between local requests coming from OppySOCKSProtocol instances and circuits. Streams are responsible for:

  • Initiating a connection request (i.e. a RelayBeginCell) on behalf of a local application
  • Passing data from circuits to local applications and vice versa
  • Informing OppySOCKSProtocol instances (and thus, the client application) when a remote resource closes the stream
  • Informing the circuit when the local application closes the stream
  • Splitting up data to be written to the network into chunks that can fit into a RelayData cell
  • Doing some rudimentary flow-control
class stream.stream.Stream(request, socks)[source]

Bases: object

Represent a Tor Stream.

recvData(data)[source]

Put data received from the network on this stream’s read queue.

Called when the circuit attached to this stream passes data to this stream.

Parameters:data (str) – data passed in from circuit to write to this stream’s attached SOCKS protocol
writeData(data)[source]

Split data into chunks that can fit in a RelayData cell, and put each chunk on this stream’s write queue.

Called when the local application attached to this stream sends data to the network.

Parameters:data (str) – data passed in from this stream’s attached SOCKS protocol to write to this stream’s circuit
incrementPackageWindow()[source]

Increment this stream’s package window and, if the package window is now above zero and this stream was in a buffering state, begin listening for local data again.

Called by the attached circuit when it receives a sendme cell for this stream.

streamConnected()[source]

Begin listening for local data from the attached SOCKS protocol to write to this stream’s circuit.

Called when the attached circuit receives a RelayConnected cell for this stream’s RelayBegin request.

closeFromCircuit()[source]

Called when this stream is closed by the circuit.

This can be caused by receiving a RelayEnd cell, the circuit being torn down, or the connection going down. We do not need to send a RelayEnd cell ourselves if the circuit closed this stream.

Notify any associated SOCKS protocols and let circuit know this stream has closed.

closeFromSOCKS()[source]

Called when the attached SOCKS protocol object is done with this stream.

Request that circuit send a RelayEnd cell on our behalf and notify circuit we’re now closed.

Previous topic

stream

Next topic

util

This Page