コード例 #1
0
ファイル: events.py プロジェクト: Foxboron/stem
    def _parse(self):
        if self.id and not tor_tools.is_valid_circuit_id(self.id):
            raise stem.ProtocolError(
                "Circuit IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.id, self))
        elif self.inbound_queue and not tor_tools.is_valid_circuit_id(
                self.inbound_queue):
            raise stem.ProtocolError(
                "Queue IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.inbound_queue, self))
        elif self.inbound_connection and not tor_tools.is_valid_connection_id(
                self.inbound_connection):
            raise stem.ProtocolError(
                "Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.inbound_connection, self))
        elif self.outbound_queue and not tor_tools.is_valid_circuit_id(
                self.outbound_queue):
            raise stem.ProtocolError(
                "Queue IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.outbound_queue, self))
        elif self.outbound_connection and not tor_tools.is_valid_connection_id(
                self.outbound_connection):
            raise stem.ProtocolError(
                "Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.outbound_connection, self))

        self.inbound_added = _parse_cell_type_mapping(self.inbound_added)
        self.inbound_removed = _parse_cell_type_mapping(self.inbound_removed)
        self.inbound_time = _parse_cell_type_mapping(self.inbound_time)
        self.outbound_added = _parse_cell_type_mapping(self.outbound_added)
        self.outbound_removed = _parse_cell_type_mapping(self.outbound_removed)
        self.outbound_time = _parse_cell_type_mapping(self.outbound_time)
コード例 #2
0
ファイル: events.py プロジェクト: patrickod/stem
  def _parse(self):
    self.endpoint_fingerprint = None
    self.endpoint_nickname = None
    self.endpoint_address = None
    self.endpoint_port = None

    try:
      self.endpoint_fingerprint, self.endpoint_nickname = \
        stem.control._parse_circ_entry(self.endpoint)
    except stem.ProtocolError:
      if ':' not in self.endpoint:
        raise stem.ProtocolError("ORCONN endpoint is neither a relay nor 'address:port': %s" % self)

      address, port = self.endpoint.rsplit(':', 1)

      if not connection.is_valid_port(port):
        raise stem.ProtocolError("ORCONN's endpoint location's port is invalid: %s" % self)

      self.endpoint_address = address
      self.endpoint_port = int(port)

    if self.circ_count is not None:
      if not self.circ_count.isdigit():
        raise stem.ProtocolError('ORCONN event got a non-numeric circuit count (%s): %s' % (self.circ_count, self))

      self.circ_count = int(self.circ_count)

    if self.id and not tor_tools.is_valid_connection_id(self.id):
      raise stem.ProtocolError("Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.id, self))

    self._log_if_unrecognized('status', stem.ORStatus)
    self._log_if_unrecognized('reason', stem.ORClosureReason)
コード例 #3
0
ファイル: events.py プロジェクト: patrickod/stem
  def _parse(self):
    if self.id and not tor_tools.is_valid_circuit_id(self.id):
      raise stem.ProtocolError("Circuit IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.id, self))
    elif self.inbound_queue and not tor_tools.is_valid_circuit_id(self.inbound_queue):
      raise stem.ProtocolError("Queue IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.inbound_queue, self))
    elif self.inbound_connection and not tor_tools.is_valid_connection_id(self.inbound_connection):
      raise stem.ProtocolError("Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.inbound_connection, self))
    elif self.outbound_queue and not tor_tools.is_valid_circuit_id(self.outbound_queue):
      raise stem.ProtocolError("Queue IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.outbound_queue, self))
    elif self.outbound_connection and not tor_tools.is_valid_connection_id(self.outbound_connection):
      raise stem.ProtocolError("Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.outbound_connection, self))

    self.inbound_added = _parse_cell_type_mapping(self.inbound_added)
    self.inbound_removed = _parse_cell_type_mapping(self.inbound_removed)
    self.inbound_time = _parse_cell_type_mapping(self.inbound_time)
    self.outbound_added = _parse_cell_type_mapping(self.outbound_added)
    self.outbound_removed = _parse_cell_type_mapping(self.outbound_removed)
    self.outbound_time = _parse_cell_type_mapping(self.outbound_time)
コード例 #4
0
ファイル: events.py プロジェクト: patrickod/stem
  def _parse(self):
    if self.id and not tor_tools.is_valid_connection_id(self.id):
      raise stem.ProtocolError("Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.id, self))
    elif not self.read.isdigit():
      raise stem.ProtocolError("A TB_EMPTY's READ value should be a positive numeric value, received: %s" % self)
    elif not self.written.isdigit():
      raise stem.ProtocolError("A TB_EMPTY's WRITTEN value should be a positive numeric value, received: %s" % self)
    elif not self.last_refill.isdigit():
      raise stem.ProtocolError("A TB_EMPTY's LAST value should be a positive numeric value, received: %s" % self)

    self.read = int(self.read)
    self.written = int(self.written)
    self.last_refill = int(self.last_refill)

    self._log_if_unrecognized('bucket', stem.TokenBucket)
コード例 #5
0
ファイル: events.py プロジェクト: patrickod/stem
  def _parse(self):
    if not self.id:
      raise stem.ProtocolError('CONN_BW event is missing its id')
    elif not self.conn_type:
      raise stem.ProtocolError('CONN_BW event is missing its connection type')
    elif not self.read:
      raise stem.ProtocolError('CONN_BW event is missing its read value')
    elif not self.written:
      raise stem.ProtocolError('CONN_BW event is missing its written value')
    elif not self.read.isdigit() or not self.written.isdigit():
      raise stem.ProtocolError("A CONN_BW event's bytes sent and received should be a positive numeric value, received: %s" % self)
    elif not tor_tools.is_valid_connection_id(self.id):
      raise stem.ProtocolError("Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s" % (self.id, self))

    self.read = int_type(self.read)
    self.written = int_type(self.written)

    self._log_if_unrecognized('conn_type', stem.ConnectionType)
コード例 #6
0
ファイル: events.py プロジェクト: Foxboron/stem
    def _parse(self):
        self.endpoint_fingerprint = None
        self.endpoint_nickname = None
        self.endpoint_address = None
        self.endpoint_port = None

        try:
            self.endpoint_fingerprint, self.endpoint_nickname = \
              stem.control._parse_circ_entry(self.endpoint)
        except stem.ProtocolError:
            if ':' not in self.endpoint:
                raise stem.ProtocolError(
                    "ORCONN endpoint is neither a relay nor 'address:port': %s"
                    % self)

            address, port = self.endpoint.split(':', 1)

            if not connection.is_valid_port(port):
                raise stem.ProtocolError(
                    "ORCONN's endpoint location's port is invalid: %s" % self)

            self.endpoint_address = address
            self.endpoint_port = int(port)

        if self.circ_count is not None:
            if not self.circ_count.isdigit():
                raise stem.ProtocolError(
                    'ORCONN event got a non-numeric circuit count (%s): %s' %
                    (self.circ_count, self))

            self.circ_count = int(self.circ_count)

        if self.id and not tor_tools.is_valid_connection_id(self.id):
            raise stem.ProtocolError(
                "Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.id, self))

        self._log_if_unrecognized('status', stem.ORStatus)
        self._log_if_unrecognized('reason', stem.ORClosureReason)
コード例 #7
0
ファイル: events.py プロジェクト: Foxboron/stem
    def _parse(self):
        if self.id and not tor_tools.is_valid_connection_id(self.id):
            raise stem.ProtocolError(
                "Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.id, self))
        elif not self.read.isdigit():
            raise stem.ProtocolError(
                "A TB_EMPTY's READ value should be a positive numeric value, received: %s"
                % self)
        elif not self.written.isdigit():
            raise stem.ProtocolError(
                "A TB_EMPTY's WRITTEN value should be a positive numeric value, received: %s"
                % self)
        elif not self.last_refill.isdigit():
            raise stem.ProtocolError(
                "A TB_EMPTY's LAST value should be a positive numeric value, received: %s"
                % self)

        self.read = int(self.read)
        self.written = int(self.written)
        self.last_refill = int(self.last_refill)

        self._log_if_unrecognized('bucket', stem.TokenBucket)
コード例 #8
0
ファイル: events.py プロジェクト: Foxboron/stem
    def _parse(self):
        if not self.id:
            raise stem.ProtocolError('CONN_BW event is missing its id')
        elif not self.type:
            raise stem.ProtocolError('CONN_BW event is missing its type')
        elif not self.read:
            raise stem.ProtocolError('CONN_BW event is missing its read value')
        elif not self.written:
            raise stem.ProtocolError(
                'CONN_BW event is missing its written value')
        elif not self.read.isdigit() or not self.written.isdigit():
            raise stem.ProtocolError(
                "A CONN_BW event's bytes sent and received should be a positive numeric value, received: %s"
                % self)
        elif not tor_tools.is_valid_connection_id(self.id):
            raise stem.ProtocolError(
                "Connection IDs must be one to sixteen alphanumeric characters, got '%s': %s"
                % (self.id, self))

        self.read = int_type(self.read)
        self.written = int_type(self.written)

        self._log_if_unrecognized('type', stem.ConnectionType)