3 Tor directory protocol, version 2
5 0. Scope and preliminaries
7 This directory protocol is used by Tor version 0.1.1.x and 0.1.2.x. See
8 dir-spec-v1.txt for information on earlier versions, and dir-spec.txt
9 for information on later versions.
11 0.1. Goals and motivation
13 There were several problems with the way Tor handles directory information
14 in version 0.1.0.x and earlier. Here are the problems we try to fix with
15 this new design, already implemented in 0.1.1.x:
16 1. Directories were very large and use up a lot of bandwidth: clients
17 downloaded descriptors for all router several times an hour.
18 2. Every directory authority was a trust bottleneck: if a single
19 directory authority lied, it could make clients believe for a time an
20 arbitrarily distorted view of the Tor network.
21 3. Our current "verified server" system is kind of nonsensical.
23 4. Getting more directory authorities would add more points of failure
24 and worsen possible partitioning attacks.
26 There are two problems that remain unaddressed by this design.
27 5. Requiring every client to know about every router won't scale.
28 6. Requiring every directory cache to know every router won't scale.
30 We attempt to fix 1-4 here, and to build a solution that will work when we
31 figure out an answer for 5. We haven't thought at all about what to do
36 There is a small set (say, around 10) of semi-trusted directory
37 authorities. A default list of authorities is shipped with the Tor
38 software. Users can change this list, but are encouraged not to do so, in
39 order to avoid partitioning attacks.
41 Routers periodically upload signed "descriptors" to the directory
42 authorities describing their keys, capabilities, and other information.
43 Routers may act as directory mirrors (also called "caches"), to reduce
44 load on the directory authorities. They announce this in their
47 Each directory authority periodically generates and signs a compact
48 "network status" document that lists that authority's view of the current
49 descriptors and status for known routers, but which does not include the
50 descriptors themselves.
52 Directory mirrors download, cache, and re-serve network-status documents
55 Clients, directory mirrors, and directory authorities all use
56 network-status documents to find out when their list of routers is
57 out-of-date. If it is, they download any missing router descriptors.
58 Clients download missing descriptors from mirrors; mirrors and authorities
59 download from authorities. Descriptors are downloaded by the hash of the
60 descriptor, not by the server's identity key: this prevents servers from
61 attacking clients by giving them descriptors nobody else uses.
63 All directory information is uploaded and downloaded with HTTP.
65 Coordination among directory authorities is done client-side: clients
66 compute a vote-like algorithm among the network-status documents they
67 have, and base their decisions on the result.
69 1.1. What's different from 0.1.0.x?
71 Clients used to download a signed concatenated set of router descriptors
72 (called a "directory") from directory mirrors, regardless of which
73 descriptors had changed.
75 Between downloading directories, clients would download "network-status"
76 documents that would list which servers were supposed to running.
78 Clients would always believe the most recently published network-status
79 document they were served.
81 Routers used to upload fresh descriptors all the time, whether their keys
82 and other information had changed or not.
84 1.2. Document meta-format
86 Router descriptors, directories, and running-routers documents all obey the
87 following lightweight extensible information format.
89 The highest level object is a Document, which consists of one or more
90 Items. Every Item begins with a KeywordLine, followed by one or more
91 Objects. A KeywordLine begins with a Keyword, optionally followed by
92 whitespace and more non-newline characters, and ends with a newline. A
93 Keyword is a sequence of one or more characters in the set [A-Za-z0-9-].
94 An Object is a block of encoded data in pseudo-Open-PGP-style
99 Document ::= (Item | NL)+
100 Item ::= KeywordLine Object*
101 KeywordLine ::= Keyword NL | Keyword WS ArgumentsChar+ NL
102 Keyword = KeywordChar+
103 KeywordChar ::= 'A' ... 'Z' | 'a' ... 'z' | '0' ... '9' | '-'
104 ArgumentChar ::= any printing ASCII character except NL.
106 Object ::= BeginLine Base-64-encoded-data EndLine
107 BeginLine ::= "-----BEGIN " Keyword "-----" NL
108 EndLine ::= "-----END " Keyword "-----" NL
110 The BeginLine and EndLine of an Object must use the same keyword.
112 When interpreting a Document, software MUST ignore any KeywordLine that
113 starts with a keyword it doesn't recognize; future implementations MUST NOT
114 require current clients to understand any KeywordLine not currently
117 The "opt" keyword was used until Tor 0.1.2.5-alpha for non-critical future
118 extensions. All implementations MUST ignore any item of the form "opt
119 keyword ....." when they would not recognize "keyword ....."; and MUST
120 treat "opt keyword ....." as synonymous with "keyword ......" when keyword
123 Implementations before 0.1.2.5-alpha rejected any document with a
124 KeywordLine that started with a keyword that they didn't recognize.
125 Implementations MUST prefix items not recognized by older versions of Tor
126 with an "opt" until those versions of Tor are obsolete.
128 Other implementations that want to extend Tor's directory format MAY
129 introduce their own items. The keywords for extension items SHOULD start
130 with the characters "x-" or "X-", to guarantee that they will not conflict
131 with keywords used by future versions of Tor.
135 ORs SHOULD generate a new router descriptor whenever any of the
136 following events have occurred:
138 - A period of time (18 hrs by default) has passed since the last
139 time a descriptor was generated.
141 - A descriptor field other than bandwidth or uptime has changed.
143 - Bandwidth has changed by more than +/- 50% from the last time a
144 descriptor was generated, and at least a given interval of time
145 (20 mins by default) has passed since then.
147 - Its uptime has been reset (by restarting).
149 After generating a descriptor, ORs upload it to every directory
150 authority they know, by posting it to the URL
152 http://<hostname:port>/tor/
154 2.1. Router descriptor format
156 Every router descriptor MUST start with a "router" Item; MUST end with a
157 "router-signature" Item and an extra NL; and MUST contain exactly one
158 instance of each of the following Items: "published" "onion-key"
159 "signing-key" "bandwidth".
161 A router descriptor MAY have zero or one of each of the following Items,
162 but MUST NOT have more than one: "contact", "uptime", "fingerprint",
163 "hibernating", "read-history", "write-history", "eventdns", "platform",
166 Additionally, a router descriptor MAY contain any number of "accept",
167 "reject", and "opt" Items. Other than "router" and "router-signature",
168 the items may appear in any order.
170 The items' formats are as follows:
171 "router" nickname address ORPort SocksPort DirPort
173 Indicates the beginning of a router descriptor. "address" must be an
174 IPv4 address in dotted-quad format. The last three numbers indicate
175 the TCP ports at which this OR exposes functionality. ORPort is a port
176 at which this OR accepts TLS connections for the main OR protocol;
177 SocksPort is deprecated and should always be 0; and DirPort is the
178 port at which this OR accepts directory-related HTTP connections. If
179 any port is not supported, the value 0 is given instead of a port
182 "bandwidth" bandwidth-avg bandwidth-burst bandwidth-observed
184 Estimated bandwidth for this router, in bytes per second. The
185 "average" bandwidth is the volume per second that the OR is willing to
186 sustain over long periods; the "burst" bandwidth is the volume that
187 the OR is willing to sustain in very short intervals. The "observed"
188 value is an estimate of the capacity this server can handle. The
189 server remembers the max bandwidth sustained output over any ten
190 second period in the past day, and another sustained input. The
191 "observed" value is the lesser of these two numbers.
195 A human-readable string describing the system on which this OR is
196 running. This MAY include the operating system, and SHOULD include
197 the name and version of the software implementing the Tor protocol.
199 "published" YYYY-MM-DD HH:MM:SS
201 The time, in GMT, when this descriptor was generated.
205 A fingerprint (a HASH_LEN-byte of asn1 encoded public key, encoded in
206 hex, with a single space after every 4 characters) for this router's
207 identity key. A descriptor is considered invalid (and MUST be
208 rejected) if the fingerprint line does not match the public key.
210 [We didn't start parsing this line until Tor 0.1.0.6-rc; it should
211 be marked with "opt" until earlier versions of Tor are obsolete.]
215 If the value is 1, then the Tor server was hibernating when the
216 descriptor was published, and shouldn't be used to build circuits.
218 [We didn't start parsing this line until Tor 0.1.0.6-rc; it should be
219 marked with "opt" until earlier versions of Tor are obsolete.]
223 The number of seconds that this OR process has been running.
225 "onion-key" NL a public key in PEM format
227 This key is used to encrypt EXTEND cells for this OR. The key MUST be
228 accepted for at least 1 week after any new key is published in a
229 subsequent descriptor.
231 "signing-key" NL a public key in PEM format
233 The OR's long-term identity key.
238 These lines describe the rules that an OR follows when
239 deciding whether to allow a new stream to a given address. The
240 'exitpattern' syntax is described below. The rules are considered in
241 order; if no rule matches, the address will be accepted. For clarity,
242 the last such entry SHOULD be accept *:* or reject *:*.
244 "router-signature" NL Signature NL
246 The "SIGNATURE" object contains a signature of the PKCS1-padded
247 hash of the entire router descriptor, taken from the beginning of the
248 "router" line, through the newline after the "router-signature" line.
249 The router descriptor is invalid unless the signature is performed
250 with the router's identity key.
254 Describes a way to contact the server's administrator, preferably
255 including an email address and a PGP key fingerprint.
259 'Names' is a space-separated list of server nicknames or
260 hexdigests. If two ORs list one another in their "family" entries,
261 then OPs should treat them as a single OR for the purpose of path
264 For example, if node A's descriptor contains "family B", and node B's
265 descriptor contains "family A", then node A and node B should never
266 be used on the same circuit.
268 "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
269 "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
271 Declare how much bandwidth the OR has used recently. Usage is divided
272 into intervals of NSEC seconds. The YYYY-MM-DD HH:MM:SS field
273 defines the end of the most recent interval. The numbers are the
274 number of bytes used in the most recent intervals, ordered from
277 [We didn't start parsing these lines until Tor 0.1.0.6-rc; they should
278 be marked with "opt" until earlier versions of Tor are obsolete.]
282 Declare whether this version of Tor is using the newer enhanced
283 dns logic. Versions of Tor without eventdns SHOULD NOT be used for
284 reverse hostname lookups.
286 [All versions of Tor before 0.1.2.2-alpha should be assumed to have
287 this option set to 0 if it is not present. All Tor versions at
288 0.1.2.2-alpha or later should be assumed to have this option set to
289 1 if it is not present. Until 0.1.2.1-alpha-dev, this option was
290 not generated, even when eventdns was in use. Versions of Tor
291 before 0.1.2.1-alpha-dev did not parse this option, so it should be
292 marked "opt". With 0.2.0.1-alpha, the old 'dnsworker' logic has
293 been removed, rendering this option of historical interest only.]
295 2.2. Nonterminals in router descriptors
297 nickname ::= between 1 and 19 alphanumeric characters, case-insensitive.
298 hexdigest ::= a '$', followed by 20 hexadecimal characters.
299 [Represents a server by the digest of its identity key.]
301 exitpattern ::= addrspec ":" portspec
302 portspec ::= "*" | port | port "-" port
303 port ::= an integer between 1 and 65535, inclusive.
304 [Some implementations incorrectly generate ports with value 0.
305 Implementations SHOULD accept this, and SHOULD NOT generate it.]
307 addrspec ::= "*" | ip4spec | ip6spec
308 ipv4spec ::= ip4 | ip4 "/" num_ip4_bits | ip4 "/" ip4mask
309 ip4 ::= an IPv4 address in dotted-quad format
310 ip4mask ::= an IPv4 mask in dotted-quad format
311 num_ip4_bits ::= an integer between 0 and 32
312 ip6spec ::= ip6 | ip6 "/" num_ip6_bits
313 ip6 ::= an IPv6 address, surrounded by square brackets.
314 num_ip6_bits ::= an integer between 0 and 128
318 Ports are required; if they are not included in the router
319 line, they must appear in the "ports" lines.
321 3. Network status format
323 Directory authorities generate, sign, and compress network-status
324 documents. Directory servers SHOULD generate a fresh network-status
325 document when the contents of such a document would be different from the
326 last one generated, and some time (at least one second, possibly longer)
327 has passed since the last one was generated.
329 The network status document contains a preamble, a set of router status
330 entries, and a signature, in that order.
332 We use the same meta-format as used for directories and router descriptors
333 in "tor-spec.txt". Implementations MAY insert blank lines
334 for clarity between sections; these blank lines are ignored.
335 Implementations MUST NOT depend on blank lines in any particular location.
337 As used here, "whitespace" is a sequence of 1 or more tab or space
340 The preamble contains:
342 "network-status-version" -- A document format version. For this
343 specification, the version is "2".
344 "dir-source" -- The authority's hostname, current IP address, and
345 directory port, all separated by whitespace.
346 "fingerprint" -- A base16-encoded hash of the signing key's
347 fingerprint, with no additional spaces added.
348 "contact" -- An arbitrary string describing how to contact the
349 directory server's administrator. Administrators should include at
350 least an email address and a PGP fingerprint.
351 "dir-signing-key" -- The directory server's public signing key.
352 "client-versions" -- A comma-separated list of recommended client
354 "server-versions" -- A comma-separated list of recommended server
356 "published" -- The publication time for this network-status object.
357 "dir-options" -- A set of flags, in any order, separated by whitespace:
358 "Names" if this directory authority performs name bindings.
359 "Versions" if this directory authority recommends software versions.
360 "BadExits" if the directory authority flags nodes that it believes
361 are performing incorrectly as exit nodes.
362 "BadDirectories" if the directory authority flags nodes that it
363 believes are performing incorrectly as directory caches.
365 The dir-options entry is optional. The "-versions" entries are required if
366 the "Versions" flag is present. The other entries are required and must
367 appear exactly once. The "network-status-version" entry must appear first;
368 the others may appear in any order. Implementations MUST ignore
369 additional arguments to the items above, and MUST ignore unrecognized
372 For each router, the router entry contains: (This format is designed for
375 "r" -- followed by the following elements, in order, separated by
378 - A hash of its identity key, encoded in base64, with trailing =
380 - A hash of its most recent descriptor, encoded in base64, with
381 trailing = signs removed. (The hash is calculated as for
382 computing the signature of a descriptor.)
383 - The publication time of its most recent descriptor, in the form
384 YYYY-MM-DD HH:MM:SS, in GMT.
387 - A directory port (or "0" for none")
388 "s" -- A series of whitespace-separated status flags, in any order:
389 "Authority" if the router is a directory authority.
390 "BadExit" if the router is believed to be useless as an exit node
391 (because its ISP censors it, because it is behind a restrictive
392 proxy, or for some similar reason).
393 "BadDirectory" if the router is believed to be useless as a
394 directory cache (because its directory port isn't working,
395 its bandwidth is always throttled, or for some similar
397 "Exit" if the router is useful for building general-purpose exit
399 "Fast" if the router is suitable for high-bandwidth circuits.
400 "Guard" if the router is suitable for use as an entry guard.
401 "Named" if the router's identity-nickname mapping is canonical,
402 and this authority binds names.
403 "Stable" if the router is suitable for long-lived circuits.
404 "Running" if the router is currently usable.
405 "Valid" if the router has been 'validated'.
406 "V2Dir" if the router implements this protocol.
407 "v" -- The version of the Tor protocol that this server is running. If
408 the value begins with "Tor" SP, the rest of the string is a Tor
409 version number, and the protocol is "The Tor protocol as supported
410 by the given version of Tor." Otherwise, if the value begins with
411 some other string, Tor has upgraded to a more sophisticated
412 protocol versioning system, and the protocol is "a version of the
413 Tor protocol more recent than any we recognize."
415 The "r" entry for each router must appear first and is required. The
416 "s" entry is optional (see Section 3.1 below for how the flags are
417 decided). Unrecognized flags on the "s" line and extra elements
418 on the "r" line must be ignored. The "v" line is optional; it was not
419 supported until 0.1.2.5-alpha, and it must be preceded with an "opt"
420 until all earlier versions of Tor are obsolete.
422 The signature section contains:
424 "directory-signature" nickname-of-dirserver NL Signature
426 Signature is a signature of this network-status document
427 (the document up until the signature, including the line
428 "directory-signature <nick>\n"), using the directory authority's
431 We compress the network status list with zlib before transmitting it.
433 3.1. Establishing server status
435 (This section describes how directory authorities choose which status
436 flags to apply to routers, as of Tor 0.1.1.18-rc. Later directory
437 authorities MAY do things differently, so long as clients keep working
438 well. Clients MUST NOT depend on the exact behaviors in this section.)
440 In the below definitions, a router is considered "active" if it is
441 running, valid, and not hibernating.
443 "Valid" -- a router is 'Valid' if it is running a version of Tor not
444 known to be broken, and the directory authority has not blacklisted
447 "Named" -- Directory authority administrators may decide to support name
448 binding. If they do, then they must maintain a file of
449 nickname-to-identity-key mappings, and try to keep this file consistent
450 with other directory authorities. If they don't, they act as clients, and
451 report bindings made by other directory authorities (name X is bound to
452 identity Y if at least one binding directory lists it, and no directory
453 binds X to some other Y'.) A router is called 'Named' if the router
454 believes the given name should be bound to the given key.
456 "Running" -- A router is 'Running' if the authority managed to connect to
457 it successfully within the last 30 minutes.
459 "Stable" -- A router is 'Stable' if it is active, and either its
460 uptime is at least the median uptime for known active routers, or
461 its uptime is at least 30 days. Routers are never called stable if
462 they are running a version of Tor known to drop circuits stupidly.
463 (0.1.1.10-alpha through 0.1.1.16-rc are stupid this way.)
465 "Fast" -- A router is 'Fast' if it is active, and its bandwidth is
466 in the top 7/8ths for known active routers.
468 "Guard" -- A router is a possible 'Guard' if it is 'Stable' and its
469 bandwidth is above median for known active routers. If the total
470 bandwidth of active non-BadExit Exit servers is less than one third
471 of the total bandwidth of all active servers, no Exit is listed as
474 "Authority" -- A router is called an 'Authority' if the authority
475 generating the network-status document believes it is an authority.
477 "V2Dir" -- A router supports the v2 directory protocol if it has an open
478 directory port, and it is running a version of the directory protocol that
479 supports the functionality clients need. (Currently, this is
480 0.1.1.9-alpha or later.)
482 Directory server administrators may label some servers or IPs as
483 blacklisted, and elect not to include them in their network-status lists.
485 Authorities SHOULD 'disable' any servers in excess of 3 on any single IP.
486 When there are more than 3 to choose from, authorities should first prefer
487 authorities to non-authorities, then prefer Running to non-Running, and
488 then prefer high-bandwidth to low-bandwidth. To 'disable' a server, the
489 authority *should* advertise it without the Running or Valid flag.
491 Thus, the network-status list includes all non-blacklisted,
492 non-expired, non-superseded descriptors.
494 4. Directory server operation
496 All directory authorities and directory mirrors ("directory servers")
497 implement this section, except as noted.
499 4.1. Accepting uploads (authorities only)
501 When a router posts a signed descriptor to a directory authority, the
502 authority first checks whether it is well-formed and correctly
503 self-signed. If it is, the authority next verifies that the nickname
504 in question is not already assigned to a router with a different
506 Finally, the authority MAY check that the router is not blacklisted
507 because of its key, IP, or another reason.
509 If the descriptor passes these tests, and the authority does not already
510 have a descriptor for a router with this public key, it accepts the
511 descriptor and remembers it.
513 If the authority _does_ have a descriptor with the same public key, the
514 newly uploaded descriptor is remembered if its publication time is more
515 recent than the most recent old descriptor for that router, and either:
516 - There are non-cosmetic differences between the old descriptor and the
518 - Enough time has passed between the descriptors' publication times.
519 (Currently, 12 hours.)
521 Differences between router descriptors are "non-cosmetic" if they would be
522 sufficient to force an upload as described in section 2 above.
524 Note that the "cosmetic difference" test only applies to uploaded
525 descriptors, not to descriptors that the authority downloads from other
528 4.2. Downloading network-status documents (authorities and caches)
530 All directory servers (authorities and mirrors) try to keep a fresh
531 set of network-status documents from every authority. To do so,
532 every 5 minutes, each authority asks every other authority for its
533 most recent network-status document. Every 15 minutes, each mirror
534 picks a random authority and asks it for the most recent network-status
535 documents for all the authorities the authority knows about (including
536 the chosen authority itself).
538 Directory servers and mirrors remember and serve the most recent
539 network-status document they have from each authority. Other
540 network-status documents don't need to be stored. If the most recent
541 network-status document is over 10 days old, it is discarded anyway.
542 Mirrors SHOULD store and serve network-status documents from authorities
543 they don't recognize, but SHOULD NOT use such documents for any other
544 purpose. Mirrors SHOULD discard network-status documents older than 48
547 4.3. Downloading and storing router descriptors (authorities and caches)
549 Periodically (currently, every 10 seconds), directory servers check
550 whether there are any specific descriptors (as identified by descriptor
551 hash in a network-status document) that they do not have and that they
552 are not currently trying to download.
554 If so, the directory server launches requests to the authorities for these
555 descriptors, such that each authority is only asked for descriptors listed
556 in its most recent network-status. When more than one authority lists the
557 descriptor, we choose which to ask at random.
559 If one of these downloads fails, we do not try to download that descriptor
560 from the authority that failed to serve it again unless we receive a newer
561 network-status from that authority that lists the same descriptor.
563 Directory servers must potentially cache multiple descriptors for each
564 router. Servers must not discard any descriptor listed by any current
565 network-status document from any authority. If there is enough space to
566 store additional descriptors, servers SHOULD try to hold those which
567 clients are likely to download the most. (Currently, this is judged
568 based on the interval for which each descriptor seemed newest.)
570 Authorities SHOULD NOT download descriptors for routers that they would
571 immediately reject for reasons listed in 3.1.
575 "Fingerprints" in these URLs are base-16-encoded SHA1 hashes.
577 The authoritative network-status published by a host should be available at:
578 http://<hostname>/tor/status/authority.z
580 The network-status published by a host with fingerprint
581 <F> should be available at:
582 http://<hostname>/tor/status/fp/<F>.z
584 The network-status documents published by hosts with fingerprints
585 <F1>,<F2>,<F3> should be available at:
586 http://<hostname>/tor/status/fp/<F1>+<F2>+<F3>.z
588 The most recent network-status documents from all known authorities,
589 concatenated, should be available at:
590 http://<hostname>/tor/status/all.z
592 The most recent descriptor for a server whose identity key has a
593 fingerprint of <F> should be available at:
594 http://<hostname>/tor/server/fp/<F>.z
596 The most recent descriptors for servers with identity fingerprints
597 <F1>,<F2>,<F3> should be available at:
598 http://<hostname>/tor/server/fp/<F1>+<F2>+<F3>.z
600 (NOTE: Implementations SHOULD NOT download descriptors by identity key
601 fingerprint. This allows a corrupted server (in collusion with a cache) to
602 provide a unique descriptor to a client, and thereby partition that client
603 from the rest of the network.)
605 The server descriptor with (descriptor) digest <D> (in hex) should be
607 http://<hostname>/tor/server/d/<D>.z
609 The most recent descriptors with digests <D1>,<D2>,<D3> should be
611 http://<hostname>/tor/server/d/<D1>+<D2>+<D3>.z
613 The most recent descriptor for this server should be at:
614 http://<hostname>/tor/server/authority.z
615 [Nothing in the Tor protocol uses this resource yet, but it is useful
616 for debugging purposes. Also, the official Tor implementations
617 (starting at 0.1.1.x) use this resource to test whether a server's
618 own DirPort is reachable.]
620 A concatenated set of the most recent descriptors for all known servers
621 should be available at:
622 http://<hostname>/tor/server/all.z
624 For debugging, directories SHOULD expose non-compressed objects at URLs like
625 the above, but without the final ".z".
626 Clients MUST handle compressed concatenated information in two forms:
627 - A concatenated list of zlib-compressed objects.
628 - A zlib-compressed concatenated list of objects.
629 Directory servers MAY generate either format: the former requires less
630 CPU, but the latter requires less bandwidth.
632 Clients SHOULD use upper case letters (A-F) when base16-encoding
633 fingerprints. Servers MUST accept both upper and lower case fingerprints
636 5. Client operation: downloading information
638 Every Tor that is not a directory server (that is, those that do
639 not have a DirPort set) implements this section.
641 5.1. Downloading network-status documents
643 Each client maintains an ordered list of directory authorities.
644 Insofar as possible, clients SHOULD all use the same ordered list.
646 For each network-status document a client has, it keeps track of its
647 publication time *and* the time when the client retrieved it. Clients
648 consider a network-status document "live" if it was published within the
651 Clients try to have a live network-status document hours from *every*
652 authority, and try to periodically get new network-status documents from
653 each authority in rotation as follows:
655 If a client is missing a live network-status document for any
656 authority, it tries to fetch it from a directory cache. On failure,
657 the client waits briefly, then tries that network-status document
658 again from another cache. The client does not build circuits until it
659 has live network-status documents from more than half the authorities
660 it trusts, and it has descriptors for more than 1/4 of the routers
661 that it believes are running.
663 If the most recently _retrieved_ network-status document is over 30
664 minutes old, the client attempts to download a network-status document.
665 When choosing which documents to download, clients treat their list of
666 directory authorities as a circular ring, and begin with the authority
667 appearing immediately after the authority for their most recently
668 retrieved network-status document. If this attempt fails (either it
669 fails to download at all, or the one it gets is not as good as the
670 one it has), the client retries at other caches several times, before
671 moving on to the next network-status document in sequence.
673 Clients discard all network-status documents over 24 hours old.
675 If enough mirrors (currently 4) claim not to have a given network status,
676 we stop trying to download that authority's network-status, until we
677 download a new network-status that makes us believe that the authority in
678 question is running. Clients should wait a little longer after each
681 Clients SHOULD try to batch as many network-status requests as possible
684 (Note: clients can and should pick caches based on the network-status
685 information they have: once they have first fetched network-status info
686 from an authority, they should not need to go to the authority directly
689 5.2. Downloading and storing router descriptors
691 Clients try to have the best descriptor for each router. A descriptor is
693 * It is the most recently published descriptor listed for that router
694 by at least two network-status documents.
696 * No descriptor for that router is listed by two or more
697 network-status documents, and it is the most recently published
698 descriptor listed by any network-status document.
700 Periodically (currently every 10 seconds) clients check whether there are
701 any "downloadable" descriptors. A descriptor is downloadable if:
702 - It is the "best" descriptor for some router.
703 - The descriptor was published at least 10 minutes in the past.
704 (This prevents clients from trying to fetch descriptors that the
705 mirrors have probably not yet retrieved and cached.)
706 - The client does not currently have it.
707 - The client is not currently trying to download it.
708 - The client would not discard it immediately upon receiving it.
709 - The client thinks it is running and valid (see 6.1 below).
711 If at least 16 known routers have downloadable descriptors, or if
712 enough time (currently 10 minutes) has passed since the last time the
713 client tried to download descriptors, it launches requests for all
714 downloadable descriptors, as described in 5.3 below.
716 When a descriptor download fails, the client notes it, and does not
717 consider the descriptor downloadable again until a certain amount of time
718 has passed. (Currently 0 seconds for the first failure, 60 seconds for the
719 second, 5 minutes for the third, 10 minutes for the fourth, and 1 day
720 thereafter.) Periodically (currently once an hour) clients reset the
723 No descriptors are downloaded until the client has downloaded more than
724 half of the network-status documents.
726 Clients retain the most recent descriptor they have downloaded for each
727 router so long as it is not too old (currently, 48 hours), OR so long as
728 it is recommended by at least one networkstatus AND no "better"
729 descriptor has been downloaded. [Versions of Tor before 0.1.2.3-alpha
730 would discard descriptors simply for being published too far in the past.]
731 [The code seems to discard descriptors in all cases after they're 5
734 5.3. Managing downloads
736 When a client has no live network-status documents, it downloads
737 network-status documents from a randomly chosen authority. In all other
738 cases, the client downloads from mirrors randomly chosen from among those
739 believed to be V2 directory servers. (This information comes from the
740 network-status documents; see 6 below.)
742 When downloading multiple router descriptors, the client chooses multiple
744 - At least 3 different mirrors are used, except when this would result
745 in more than one request for under 4 descriptors.
746 - No more than 128 descriptors are requested from a single mirror.
747 - Otherwise, as few mirrors as possible are used.
748 After choosing mirrors, the client divides the descriptors among them
751 After receiving any response client MUST discard any network-status
752 documents and descriptors that it did not request.
754 6. Using directory information
756 Everyone besides directory authorities uses the approaches in this section
757 to decide which servers to use and what their keys are likely to be.
758 (Directory authorities just believe their own opinions, as in 3.1 above.)
760 6.1. Choosing routers for circuits.
762 Tor implementations only pay attention to "live" network-status documents.
763 A network status is "live" if it is the most recently downloaded network
764 status document for a given directory server, and the server is a
765 directory server trusted by the client, and the network-status document is
766 no more than 1 day old.
768 For time-sensitive information, Tor implementations focus on "recent"
769 network-status documents. A network status is "recent" if it is live, and
770 if it was published in the last 60 minutes. If there are fewer
771 than 3 such documents, the most recently published 3 are "recent." If
772 there are fewer than 3 in all, all are "recent.")
774 Circuits SHOULD NOT be built until the client has enough directory
775 information: network-statuses (or failed attempts to download
776 network-statuses) for all authorities, network-statuses for at more than
777 half of the authorites, and descriptors for at least 1/4 of the servers
778 believed to be running.
780 A server is "listed" if it is included by more than half of the live
781 network status documents. Clients SHOULD NOT use unlisted servers.
783 Clients believe the flags "Valid", "Exit", "Fast", "Guard", "Stable", and
784 "V2Dir" about a given router when they are asserted by more than half of
785 the live network-status documents. Clients believe the flag "Running" if
786 it is listed by more than half of the recent network-status documents.
788 These flags are used as follows:
790 - Clients SHOULD NOT use non-'Valid' or non-'Running' routers unless
793 - Clients SHOULD NOT use non-'Fast' routers for any purpose other than
794 very-low-bandwidth circuits (such as introduction circuits).
796 - Clients SHOULD NOT use non-'Stable' routers for circuits that are
797 likely to need to be open for a very long time (such as those used for
798 IRC or SSH connections).
800 - Clients SHOULD NOT choose non-'Guard' nodes when picking entry guard
803 - Clients SHOULD NOT download directory information from non-'V2Dir'
808 In order to provide human-memorable names for individual server
809 identities, some directory servers bind names to IDs. Clients handle
812 When a client encounters a name it has not mapped before:
814 If all the live "Naming" network-status documents the client has
815 claim that the name binds to some identity ID, and the client has at
816 least three live network-status documents, the client maps the name to
819 When a user tries to refer to a router with a name that does not have a
820 mapping under the above rules, the implementation SHOULD warn the user.
821 After giving the warning, the implementation MAY use a router that at
822 least one Naming authority maps the name to, so long as no other naming
823 authority maps that name to a different router. If no Naming authority
824 maps the name to a router, the implementation MAY use any router that
827 Not every router needs a nickname. When a router doesn't configure a
828 nickname, it publishes with the default nickname "Unnamed". Authorities
829 SHOULD NOT ever mark a router with this nickname as Named; client software
830 SHOULD NOT ever use a router in response to a user request for a router
833 6.3. Software versions
835 An implementation of Tor SHOULD warn when it has fetched (or has
836 attempted to fetch and failed four consecutive times) a network-status
837 for each authority, and it is running a software version
838 not listed on more than half of the live "Versioning" network-status
841 6.4. Warning about a router's status.
843 If a router tries to publish its descriptor to a Naming authority
844 that has its nickname mapped to another key, the router SHOULD
845 warn the operator that it is either using the wrong key or is using
846 an already claimed nickname.
848 If a router has fetched (or attempted to fetch and failed four
849 consecutive times) a network-status for every authority, and at
850 least one of the authorities is "Naming", and no live "Naming"
851 authorities publish a binding for the router's nickname, the
852 router MAY remind the operator that the chosen nickname is not
853 bound to this key at the authorities, and suggest contacting the
858 6.5. Router protocol versions
860 A client should believe that a router supports a given feature if that
861 feature is supported by the router or protocol versions in more than half
862 of the live networkstatus's "v" entries for that router. In other words,
863 if the "v" entries for some router are:
864 v Tor 0.0.8pre1 (from authority 1)
865 v Tor 0.1.2.11 (from authority 2)
866 v FutureProtocolDescription 99 (from authority 3)
867 then the client should believe that the router supports any feature
868 supported by 0.1.2.11.
870 This is currently equivalent to believing the median declared version for
871 a router in all live networkstatuses.
873 7. Standards compliance
875 All clients and servers MUST support HTTP 1.0.
879 Servers MAY set the Content-Length: header. Servers SHOULD set
880 Content-Encoding to "deflate" or "identity".
882 Servers MAY include an X-Your-Address-Is: header, whose value is the
883 apparent IP address of the client connecting to them (as a dotted quad).
884 For directory connections tunneled over a BEGIN_DIR stream, servers SHOULD
885 report the IP from which the circuit carrying the BEGIN_DIR stream reached
886 them. [Servers before version 0.1.2.5-alpha reported 127.0.0.1 for all
887 BEGIN_DIR-tunneled connections.]
889 Servers SHOULD disable caching of multiple network statuses or multiple
890 router descriptors. Servers MAY enable caching of single descriptors,
891 single network statuses, the list of all router descriptors, a v1
892 directory, or a v1 running routers document. XXX mention times.
894 7.2. HTTP status codes
896 XXX We should write down what return codes dirservers send in what situations.