Beispiel #1
0
                                                      'router_digest_sha256')
_parse_router_digest_line = _parse_forty_character_hex('router-digest',
                                                       '_digest')

# TODO: We need to be tolerant of negative uptimes to accommodate a past tor
# bug...
#
# Changes in version 0.1.2.7-alpha - 2007-02-06
#  - If our system clock jumps back in time, don't publish a negative
#    uptime in the descriptor. Also, don't let the global rate limiting
#    buckets go absurdly negative.
#
# After parsing all of the attributes we'll double check that negative
# uptimes only occurred prior to this fix.

_parse_uptime_line = _parse_int_line('uptime', 'uptime', allow_negative=True)


class ServerDescriptor(Descriptor):
    """
  Common parent for server descriptors.

  :var str nickname: **\\*** relay's nickname
  :var str fingerprint: identity key fingerprint
  :var datetime published: **\\*** time in UTC when this descriptor was made

  :var str address: **\\*** IPv4 address of the relay
  :var int or_port: **\\*** port used for relaying
  :var int socks_port: **\\*** port used as client (**deprecated**, always **None**)
  :var int dir_port: **\\*** port used for descriptor mirroring
Beispiel #2
0
                                                'dirreq-v2-share',
                                                'dir_v2_share')
_parse_dirreq_v3_share_line = functools.partial(_parse_dirreq_share_line,
                                                'dirreq-v3-share',
                                                'dir_v3_share')
_parse_cell_processed_cells_line = functools.partial(_parse_cell_line,
                                                     'cell-processed-cells',
                                                     'cell_processed_cells')
_parse_cell_queued_cells_line = functools.partial(_parse_cell_line,
                                                  'cell-queued-cells',
                                                  'cell_queued_cells')
_parse_cell_time_in_queue_line = functools.partial(_parse_cell_line,
                                                   'cell-time-in-queue',
                                                   'cell_time_in_queue')
_parse_cell_circuits_per_decline_line = _parse_int_line(
    'cell-circuits-per-decile',
    'cell_circuits_per_decile',
    allow_negative=False)
_parse_published_line = _parse_timestamp_line('published', 'published')
_parse_geoip_start_time_line = _parse_timestamp_line('geoip-start-time',
                                                     'geoip_start_time')
_parse_cell_stats_end_line = functools.partial(
    _parse_timestamp_and_interval_line, 'cell-stats-end', 'cell_stats_end',
    'cell_stats_interval')
_parse_entry_stats_end_line = functools.partial(
    _parse_timestamp_and_interval_line, 'entry-stats-end', 'entry_stats_end',
    'entry_stats_interval')
_parse_exit_stats_end_line = functools.partial(
    _parse_timestamp_and_interval_line, 'exit-stats-end', 'exit_stats_end',
    'exit_stats_interval')
_parse_bridge_stats_end_line = functools.partial(
    _parse_timestamp_and_interval_line, 'bridge-stats-end', 'bridge_stats_end',
    descriptor.introduction_points_encoded = block_contents
    descriptor.introduction_points_auth = [
    ]  # field was never implemented in tor (#15190)

    try:
        descriptor.introduction_points_content = _bytes_for_block(
            block_contents)
    except TypeError:
        raise ValueError(
            "'introduction-points' isn't base64 encoded content:\n%s" %
            block_contents)


_parse_v2_version_line = _parse_int_line('version',
                                         'version',
                                         allow_negative=False)
_parse_rendezvous_service_descriptor_line = _parse_simple_line(
    'rendezvous-service-descriptor', 'descriptor_id')
_parse_permanent_key_line = _parse_key_block('permanent-key', 'permanent_key',
                                             'RSA PUBLIC KEY')
_parse_secret_id_part_line = _parse_simple_line('secret-id-part',
                                                'secret_id_part')
_parse_publication_time_line = _parse_timestamp_line('publication-time',
                                                     'published')
_parse_v2_signature_line = _parse_key_block('signature', 'signature',
                                            'SIGNATURE')

_parse_v3_version_line = _parse_int_line('hs-descriptor',
                                         'version',
                                         allow_negative=False)