Stem Docs

Controller Responses

Controller Responses

Parses replies from the control socket.

Module Overview:

convert - translates a ControlMessage into a particular response subclass

ControlMessage - Message that's read from the control socket.
  |- SingleLineResponse - Simple tor response only including a single line of information.
  |
  |- from_str - provides a ControlMessage for the given string
  |- is_ok - response had a 250 status
  |- content - provides the parsed message content
  +- raw_content - unparsed socket data

ControlLine - String subclass with methods for parsing controller responses.
  |- remainder - provides the unparsed content
  |- is_empty - checks if the remaining content is empty
  |- is_next_quoted - checks if the next entry is a quoted value
  |- is_next_mapping - checks if the next entry is a KEY=VALUE mapping
  |- peek_key - provides the key of the next entry
  |- pop - removes and returns the next entry
  +- pop_mapping - removes and returns the next entry as a KEY=VALUE mapping

Responses

class stem.response.add_onion.AddOnionResponse(parsed_content, raw_content, arrived_at=None)[source]

ADD_ONION response.

Variables:
  • service_id (str) – hidden service address without the ‘.onion’ suffix

  • private_key (str) – base64 encoded hidden service private key

  • private_key_type (str) – crypto used to generate the hidden service private key (such as RSA1024)

  • client_auth (dict) – newly generated client credentials the service accepts

class stem.response.authchallenge.AuthChallengeResponse(parsed_content, raw_content, arrived_at=None)[source]

AUTHCHALLENGE query response.

Variables:
  • server_hash (str) – server hash provided by tor

  • server_nonce (str) – server nonce provided by tor

class stem.response.getconf.GetConfResponse(parsed_content, raw_content, arrived_at=None)[source]

Reply for a GETCONF query.

Note that configuration parameters won’t match what we queried for if it’s one of the special mapping options (ex. ‘HiddenServiceOptions’).

Variables:

entries (dict) – mapping between the config parameter (str) and their values (list of str)

class stem.response.getinfo.GetInfoResponse(parsed_content, raw_content, arrived_at=None)[source]

Reply for a GETINFO query.

Variables:

entries (dict) – mapping between the queried options and their bytes values

class stem.response.mapaddress.MapAddressResponse(parsed_content, raw_content, arrived_at=None)[source]

Reply for a MAPADDRESS query. Doesn’t raise an exception unless no addresses were mapped successfully.

Variables:

entries (dict) – mapping between the original and replacement addresses

Raises:
  • stem.OperationFailed if Tor was unable to satisfy the request

  • stem.InvalidRequest if the addresses provided were invalid

class stem.response.protocolinfo.ProtocolInfoResponse(parsed_content, raw_content, arrived_at=None)[source]

Version one PROTOCOLINFO query response.

The protocol_version is the only mandatory data for a valid PROTOCOLINFO response, so all other values are None if undefined or empty if a collection.

Variables:
  • protocol_version (int) – protocol version of the response

  • tor_version (stem.version.Version) – version of the tor process

  • auth_methods (tuple) – stem.connection.AuthMethod types that tor will accept

  • unknown_auth_methods (tuple) – strings of unrecognized auth methods

  • cookie_path (str) – path of tor’s authentication cookie

Events