[tor-bugs] #9380 [BridgeDB]: BridgeDB should use Stem for parsing descriptors (was: BridgeDB should use stem for parsing descriptors according to torspec)

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Aug 28 01:46:16 UTC 2014


#9380: BridgeDB should use Stem for parsing descriptors
-------------------------+-------------------------------------------------
     Reporter:  sysrqb   |      Owner:  isis
         Type:           |     Status:  needs_review
  enhancement            |  Milestone:
     Priority:  normal   |    Version:
    Component:           |   Keywords:  stem,bridgedb-0.2.x,bridgedb-
  BridgeDB               |  parsers
   Resolution:           |  Parent ID:
Actual Points:           |
       Points:           |
-------------------------+-------------------------------------------------

Comment (by isis):

 Replying to [comment:26 atagar]:
 > > About the portlist for IPv6 addresses in one of these lines... I'm
 actually not sure what the spec says.
 >
 > I'm not quite sure what this is in reference to, but the a-line can be
 IPv4 or IPv6 addresses. Stem's or_addresses attribute is a
 [https://stem.torproject.org/api/descriptor/router_status_entry.html#stem.descriptor.router_status_entry.RouterStatusEntryV3
 three value tuple telling you which it is].

 '''tl;dr''': The `"a"`/`"or-address"` lines, ''in implementation'', only
 happen once each per router, and only ever contain IPv6 addresses, despite
 what `dir-spec.txt` says.


 The spec
 [https://gitweb.torproject.org/torspec.git/blob/d4cb76a81f26dcc41a2c2041b12977dfdf62c3f8
 :/dir-spec.txt#l1166 says]:

 {{{
      "a" SP address ":" port NL

         [Any number]

         The "or-address" element as specified in section 2.1.1.
 }}}

 [https://gitweb.torproject.org/torspec.git/blob/d4cb76a81f26dcc41a2c2041b12977dfdf62c3f8
 :/dir-spec.txt#l587 and]:

 {{{
    "or-address" SP ADDRESS ":" PORT NL

        [Any number]

        ADDRESS = IP6ADDR | IP4ADDR
        IPV6ADDR = an ipv6 address, surrounded by square brackets.
        IPV4ADDR = an ipv4 address, represented as a dotted quad.
        PORT = a number between 1 and 65535 inclusive.
        An alternative for the address and ORPort of the "router" line, but
 with
        two added capabilities:

          * or-address can be either an IPv4 or IPv6 address
          * or-address allows for multiple ORPorts and addresses

        A descriptor SHOULD NOT include an or-address line that does
 nothing but
        duplicate the address:port pair from its "router" line.

        The ordering of or-address lines and their PORT entries matter
 because
        Tor MAY accept a limited number of addresses or ports. As of Tor
 0.2.3.x
        only the first address and the first port are used.
 }}}

  - In terms of how many `"a"`/`"or-address"` lines there may be, the spec
 is only correct if you pay ''super close attention to the last sentence''
 (this is actually the first time I've noticed it :) ).

  - In terms of whether IPv4 and/or IPv6 addresses are acceptable, ''the
 spec is currently wrong'',  according to the functions
 `router_rebuild_descriptor()`
 [https://gitweb.torproject.org/tor.git/blob/9f9b19ed7b06d8313a9bcbd6647fa097ec0a059d:/src/or/router.c#l1811
 [source]] and `router_dump_router_to_string()`
 [https://gitweb.torproject.org/tor.git/blob/9f9b19ed7b06d8313a9bcbd6647fa097ec0a059d:/src/or/router.c#l2330
 [source]] in `src/or/router.c` in tor's source code.

 Unless we're aiming to build parsers for some other, spec-compliant¹,
 imaginary OR implementation? Which is totally worth doing, and if that's
 what Stem ''is'' doing, then that's great! But if that is the case, then
 BridgeDB would likely have to modify Stem's parsing, because it certainly
 wouldn't be very good if someone were to write an alternate OR
 implementation which started submitting the fully-spec-compliant "`[Any
 number]`" of addresses to BridgeDB and spamming the databases.

 -----
 ¹ I'm ignoring Orchid because last I checked (two months ago), it wasn't
 what I'd call "spec-compliant".

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/9380#comment:27>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list