relay

class cell.relay.RelayCell(header, rheader=None, rpayload='')[source]

Bases: oppy.cell.fixedlen.FixedLenCell

A container class for representing relay cells.

Note

All Relay cells are fixed-length (length determined by Link Protocol version in use).

rheader = None
rpayload = None
getBytes(trimmed=False)[source]

Construct and return the byte string represented by this cell.

Parameters:trimmed (bool) – If True, return the non-padded payload. Otherwise pad the payload with null bytes to the fixed-size length in use according to the Link Protocol version.
Returns:str byte string represented by this cell
relayHeaderRange()[source]

Return a two-tuple indicating the (start,end) indices of this cell’s relay header.

Returns:tuple, int (start, end) indices of this cell’s relay header
relayPayloadRange()[source]

Return a two-tuple indicating the (start,end) indices of this cell’s relay header.

Returns:tuple, int (start, end) indices of this cell’s relay payload
class RelayHeader(cmd, recognized, stream_id, digest, rpayload_len)[source]

Bases: object

A simple container for relay header information.

FORMAT = '!B2sH4sH'
cmd = None
recognized = None
stream_id = None
digest = None
rpayload_len = None
getBytes()[source]

Construct and return the byte string represented by this cell.

Returns:str byte string represented by this cell.
class cell.relay.RelayBeginDirCell(header)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

class cell.relay.RelayBeginCell(header, rheader=None, addr=None, flags=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 6.2

static make(circ_id, stream_id, request, flags=None, link_version=3)[source]

Build and return a RelayBegin cell, filling in default values when possible.

Automatically create a default FixedLenCell.Header and RelayCell.RelayHeader.

Parameters:
  • circ_id (int) – Circuit ID to use in this cell
  • stream_id (int) – Stream ID to use in this cell
  • request (oppy.util.ExitRequest) – destination this cell will request a connection to
  • int flags (list,) – flags to use for this connection
  • link_version (int) – Link Protocol version in use on this connection
Returns:

RelayBeginCell

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – If True, do not pad this cell’s payload.
Returns:str raw byte string represented by this cell
class cell.relay.RelayConnectedCell(header, rheader=None, addr_type=None, addr=None, ttl=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 6.2

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – if True, do not pad payload bytes
Returns:str raw bytes this cell represents
class cell.relay.RelayDataCell(header, rheader=None, rpayload='')[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 6.2

static make(circ_id, stream_id, rpayload, link_version=3)[source]

Construct and return a RelayData cell, using default values where possible.

Create a FixedLenCell.Header and a RelayCell.RelayHeader.

Parameters:
  • circ_id (int) – Circuit ID to use in this cell
  • stream_id (int) – Stream ID to use in this cell
  • rpayload (str) – data to use as the relay payload
  • link_version (int) – Link Protocol version in use
class cell.relay.RelayDropCell(header, rheader=None, rpayload='')[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 6.2

class cell.relay.RelayEndCell(header, rheader=None, reason=None, reason_data=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 6.3

static make(circ_id, stream_id, reason=6, reason_data='', link_version=3)[source]

Construct and return a RelayEnd cell, using default values where possible.

Create a FixedLenCell.Header and a RelayCell.RelayHeader.

Parameters:
  • circ_id (int) – Circuit ID to use in this cell
  • stream_id (int) – Stream ID to use in this cell
  • reason (int) – Single byte that describes the reason this stream was closed
  • reason_data (str) – with REASON_EXITPOLICY, this optional field may be filled in
Returns:

RelayEndCell

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – if True, do not pad payload bytes
Returns:str raw byte string this cell represents
class cell.relay.RelayExtend2Cell(header, rheader=None, nspec=None, lspecs=None, htype=None, hlen=None, hdata=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 5.1.2

static make(circ_id, stream_id=0, nspec=None, lspecs=None, htype=2, hlen=84, hdata='', link_version=3, early=True)[source]

Construct and return a RelayExtend2Cell, using default values where possible.

Create a FixedLenCell.Header and a RelayCell.RelayHeader for use in this cell.

Note

oppy currently only supports the NTor handshake and will reject unrecognized htype’s and hlen’s.

Parameters:
  • circ_id (int) – Circuit ID to use in this cell
  • stream_id (int) – Stream ID to use in this cell (should be zero)
  • nspec (int) – the number of Link Specifiers in this cell
  • oppy.cell.util.LinkSpecifier lspecs (list,) – list of Link Specifiers to include in this cell
  • htype (int) – Type of handshake in use
  • hlen (int) – length of the handshake data field
  • hdata (str) – handshake data (onion skin)
  • link_version (int) – Link Protocol version in use
  • early (bool) – if True, use a RELAY_EARLY cmd instead of RELAY cmd
Returns:

RelayExtend2Cell

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – if True, do not pad payload bytes
Returns:str raw byte string this cell represents
class cell.relay.RelayExtended2Cell(header, rheader=None, hlen=None, hdata=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 5.1, 5.1.2

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – if True, do not pad payload bytes
Returns:str raw byte string this cell represents
class cell.relay.RelayExtendedCell(header)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

class cell.relay.RelayExtendCell(header)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

class cell.relay.RelayResolvedCell(header)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

class cell.relay.RelayResolveCell(header)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

class cell.relay.RelaySendMeCell(header, rheader=None, rpayload='')[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 7.3, 7.4

static make(circ_id, stream_id=0, link_version=3)[source]

Construct and return a RelaySendMeCell, using default values where possible.

Create a FixedLenCell.Header and a RelayCell.RelayHeader for use in this cell.

Parameters:
  • circ_id (int) – Circuit ID to use in this cell
  • stream_id (int) – Stream ID to use in this cell. A Stream ID of zero indicates a ‘circuit-level’ SendMe cell, and a non-zero Stream ID indicates a ‘stream-level’ SendMe cell.
  • link_version (int) – Link Protocol version in use
Returns:

RelaySendMeCell

class cell.relay.RelayTruncatedCell(header, rheader=None, reason=None)[source]

Bases: cell.relay.RelayCell

Note

tor-spec, Section 5.4

getBytes(trimmed=False)[source]

Build and return the raw byte string this cell represents.

Parameters:trimmed (bool) – if True, do not pad payload bytes
Returns:str raw bytes this cell represents
class cell.relay.RelayTruncateCell(header, rheader=None, reason=None)[source]

Bases: cell.relay.RelayCell

Note

Not Implemented

Previous topic

fixedlen

Next topic

varlen

This Page