Opened 4 years ago

Last modified 18 months ago

#17224 new enhancement

Refactor common parts of parse_dir_authority_line and parse_dir_fallback_line

Reported by: teor Owned by:
Priority: Low Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: easy, tor-client, refactor, technical-debt, 034-triage-20180328, 034-removed-20180328
Cc: Actual Points:
Parent ID: #24818 Points: 0.5
Reviewer: Sponsor:

Description

There's a lot of common code in parse_dir_authority_line and parse_dir_fallback_line that could be refactored into a shared function.

What needs to be done is:

  • identify common code
  • create a common loop that parses the key=value pairs it understands, deletes them, and leaves the rest alone
  • put that loop in its own function that takes pointers (or pointer pointers?), returns values in those that are included, and returns NULL in those that aren't.
  • check this loop's output from both functions to ensure they each get what they need, then do the specific bits on the remaining arguments
  • call a common function to parse the IPv4:Port at the start of the line, then delete it
  • call a common function to parse the hex digest, which should be the only remaining thing

Child Tickets

Change History (12)

comment:1 Changed 4 years ago by nickm

See also #8351 if you want a crazy backend that might help with this kind of stuff. :)

comment:2 Changed 4 years ago by nickm

Points: small/medium
Severity: Normal

comment:3 Changed 3 years ago by teor

Milestone: Tor: 0.2.???Tor: 0.3.???

Milestone renamed

comment:4 Changed 3 years ago by nickm

Keywords: tor-03-unspecified-201612 added
Milestone: Tor: 0.3.???Tor: unspecified

Finally admitting that 0.3.??? was a euphemism for Tor: unspecified all along.

comment:5 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:6 Changed 2 years ago by nickm

Keywords: tor-client refactor technical-debt added

comment:7 Changed 21 months ago by teor

Keywords: lorax removed
Milestone: Tor: unspecifiedTor: 0.3.3.x-final
Parent ID: #24818
Points: small/medium0.5

#24818 is a good opportunity to do this.

We should also update the man page to document the existing constraints:

  • fallback fields can appear in any order
  • authority flags can appear in any order, but the rest of the fields must appear in that order
  • bridge authorities require a nickname, otherwise you end up with an authority called "bridge"

comment:8 Changed 21 months ago by teor

Oh, and we should update the dir-list-spec to note how these changes may affect the format of future fallback and authority lists.

comment:9 Changed 20 months ago by teor

Milestone: Tor: 0.3.3.x-finalTor: 0.3.4.x-final

We have time to do these, let's do them well in 0.3.4

comment:10 Changed 18 months ago by nickm

Keywords: 034-triage-20180328 added

comment:11 Changed 18 months ago by nickm

Keywords: 034-removed-20180328 added

Per our triage process, these tickets are pending removal from 0.3.4.

comment:12 Changed 18 months ago by nickm

Milestone: Tor: 0.3.4.x-finalTor: unspecified

These tickets, tagged with 034-removed-*, are no longer in-scope for 0.3.4. We can reconsider any of them, if time permits.

Note: See TracTickets for help on using tickets.