dir-spec.txt 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. $Id$
  2. Tor directory protocol, version 3
  3. 0. Scope and preliminaries
  4. This directory protocol is used by Tor version 0.2.0.x-alpha and later.
  5. See dir-spec-v1.txt for information on the protocol used up to the
  6. 0.1.0.x series, and dir-spec-v2.txt for information on the protocol
  7. used by the 0.1.1.x and 0.1.2.x series.
  8. Caches and authorities must still support older versions of the
  9. directory protocols, until the versions of Tor that require them are
  10. finally out of commission. See Section XXXX on backward compatibility.
  11. This document merges and supersedes the following proposals:
  12. 101 Voting on the Tor Directory System
  13. 103 Splitting identity key from regularly used signing key
  14. 104 Long and Short Router Descriptors
  15. AS OF 18 MAY 2007, THIS SPECIFICATION HAS NOT YET BEEN COMPLETELY
  16. IMPLEMENTED, OR COMPLETELY COMPLETED.
  17. XXX when to download certificates.
  18. XXX timeline
  19. XXX fill in XXXXs
  20. 0.1. History
  21. The earliest versions of Onion Routing shipped with a list of known
  22. routers and their keys. When the set of routers changed, users needed to
  23. fetch a new list.
  24. The Version 1 Directory protocol
  25. --------------------------------
  26. [XXX say which versions added what.]
  27. Early versions of Tor introduced "Directory authorities": servers that
  28. served signed "directory" documents containing a list of signed "router
  29. descriptors", along with short summary of the status of each router.
  30. Thus, clients could get up-to-date information on the state of the
  31. network automatically, and be certain that they list they were getting
  32. was attested by a trusted directory authority.
  33. Later versions added directory caches, which download directories from
  34. the authorities and serve them to clients. Non-caches fetch from the
  35. caches in preference to fetching from the authorities, thus distributing
  36. bandwidth requirements.
  37. Also added during the version 1 directory protocol were "router status"
  38. documents: short documents that listed only the up/down status of the
  39. routers on the network, rather than a complete list of all the
  40. descriptors. Clients and caches would fetch these documents far more
  41. frequently than they would fetch full directories.
  42. The Version 2 Directory Protocol
  43. --------------------------------
  44. During the Tor 0.1.1.x series, Tor revised its handling of directory
  45. documents in order to address two major problems:
  46. * Directories had grown quite large (over 1MB), and most directory
  47. downloads consisted mainly of router descriptors that clients
  48. already had.
  49. * Every directory authorities was a trust bottleneck: if a single
  50. directory authority lied, it could make clients believe for a time
  51. an arbitrarily distorted view of the Tor network. (Clients
  52. trusted the most recent signed document they downloaded.) Thus,
  53. adding more authorities would make the system less secure, not
  54. more.
  55. To address these, we extended the directory protocol so that
  56. authorities now published signed "network status" documents. Each
  57. network status listed, for every router in the network: a hash of its
  58. identity key, a hash of its most recent descriptor, and a summary of
  59. what the authority believed about its status. Clients would download
  60. the authorities' network status documents in turn, and believe
  61. statements about routers iff they were attested to by more than half of
  62. the authorities.
  63. Instead of downloading all router descriptors at once, clients
  64. downloaded only the descriptors that they did not have. Descriptors
  65. were indexed by their digests, in order to prevent malicious caches
  66. from giving different versions of a router descriptor to different
  67. clients.
  68. Routers began working harder to upload new descriptors only when their
  69. contents were substantially changed.
  70. 0.2. Goals of the version 3 protocol
  71. Version 3 of the Tor directory protocol tries to solve the following
  72. issues:
  73. * A great deal of bandwidth used to transmit router descriptors was
  74. used by two fields that are not actually used by Tor routers. We
  75. save about 60% by moving them into a separate document that most
  76. clients do not fetch or use.
  77. * It was possible under certain perverse circumstances for clients
  78. to download an unusual set of network status documents, thus
  79. partitioning themselves from clients who have a more recent and/or
  80. typical set of documents. Even under the best of circumstances,
  81. clients were sensitive to the ages of the network status documents
  82. they downloaded. Therefore, instead of having the clients
  83. correlate multiple network status documents, we have the
  84. authorities collectively vote on a single consensus network status
  85. document.
  86. * The most sensitive data in the entire network (the identity keys
  87. of the directory authorities) needed to be stored unencrypted so
  88. that the authorities can sign network-status documents on the fly.
  89. Now, the authorities' identity keys are stored offline, and used
  90. to certify medium-term signing keys that can be rotated.
  91. 0.3. Some Remaining questions
  92. Things we could solve on a v3 timeframe:
  93. The SHA-1 hash is showing its age. We should do something about our
  94. dependency on it. We could probably future-proof ourselves here in
  95. this revision, at least so far as documents from the authorities are
  96. concerned.
  97. Too many things about the authorities are hardcoded by IP.
  98. Perhaps we should start accepting longer identity keys for routers
  99. too.
  100. Things to solve eventually:
  101. Requiring every client to know about every router won't scale forever.
  102. Requiring every directory cache to know every router won't scale
  103. forever.
  104. 1. Outline
  105. There is a small set (say, around 5-10) of semi-trusted directory
  106. authorities. A default list of authorities is shipped with the Tor
  107. software. Users can change this list, but are encouraged not to do so,
  108. in order to avoid partitioning attacks.
  109. Every authority has a very-secret, long-term "Authority Identity Key".
  110. This is stored encrypted and/or offline, and is used to sign "key
  111. certificate" documents. Every key certificate contains a medium-term
  112. (3-12 months) "authority signing key", that is used by the authority to
  113. sign other directory information. (Note that the authority identity
  114. key is distinct from the router identity key that the authority uses
  115. in its role as an ordinary router.)
  116. Routers periodically upload signed "routers descriptors" to the
  117. directory authorities describing their keys, capabilities, and other
  118. information. Routers may also upload signed "extra info documents"
  119. containing information that is not required for the Tor protocol.
  120. Directory authorities serve router descriptors indexed by router
  121. identity, or by hash of the descriptor.
  122. Routers may act as directory caches to reduce load on the directory
  123. authorities. They announce this in their descriptors.
  124. Periodically, each directory authority periodically generates a view of
  125. the current descriptors and status for known routers. They send a
  126. signed summary of this view (a "status vote") to the other
  127. authorities. The authorities compute the result of this vote, and sign
  128. a "consensus status" document containing the result of the vote.
  129. Directory caches download, cache, and re-serve consensus documents.
  130. Clients, directory caches, and directory authorities all use consensus
  131. documents to find out when their list of routers is out-of-date.
  132. (Directory authorities also use vote statuses.) If it is, they download
  133. any missing router descriptors. Clients download missing descriptors
  134. from caches; caches and authorities download from authorities.
  135. Descriptors are downloaded by the hash of the descriptor, not by the
  136. server's identity key: this prevents servers from attacking clients by
  137. giving them descriptors nobody else uses.
  138. All directory information is uploaded and downloaded with HTTP.
  139. [Authorities also generate and caches also cache documents produced and
  140. used by earlier versions of this protocol; see section XXX for notes.]
  141. 1.1. What's different from version 2?
  142. Clients used to download a multiple network status documents,
  143. corresponding roughly to "status votes" above. They would compute the
  144. result of the vote on the client side.
  145. Authorities used sign documents using the same private keys they used
  146. for their roles as routers. This forced them to keep these extremely
  147. sensitive keys in memory unencrypted.
  148. All of the information in extra-info documents used to be kept in the
  149. main descriptors.
  150. 1.2. Document meta-format
  151. Router descriptors, directories, and running-routers documents all obey the
  152. following lightweight extensible information format.
  153. The highest level object is a Document, which consists of one or more
  154. Items. Every Item begins with a KeywordLine, followed by one or more
  155. Objects. A KeywordLine begins with a Keyword, optionally followed by
  156. whitespace and more non-newline characters, and ends with a newline. A
  157. Keyword is a sequence of one or more characters in the set [A-Za-z0-9-].
  158. An Object is a block of encoded data in pseudo-Open-PGP-style
  159. armor. (cf. RFC 2440)
  160. More formally:
  161. Document ::= (Item | NL)+
  162. Item ::= KeywordLine Object*
  163. KeywordLine ::= Keyword NL | Keyword WS ArgumentsChar+ NL
  164. Keyword = KeywordChar+
  165. KeywordChar ::= 'A' ... 'Z' | 'a' ... 'z' | '0' ... '9' | '-'
  166. ArgumentChar ::= any printing ASCII character except NL.
  167. WS = (SP | TAB)+
  168. Object ::= BeginLine Base-64-encoded-data EndLine
  169. BeginLine ::= "-----BEGIN " Keyword "-----" NL
  170. EndLine ::= "-----END " Keyword "-----" NL
  171. The BeginLine and EndLine of an Object must use the same keyword.
  172. When interpreting a Document, software MUST ignore any KeywordLine that
  173. starts with a keyword it doesn't recognize; future implementations MUST NOT
  174. require current clients to understand any KeywordLine not currently
  175. described.
  176. The "opt" keyword was used until Tor 0.1.2.5-alpha for non-critical future
  177. extensions. All implementations MUST ignore any item of the form "opt
  178. keyword ....." when they would not recognize "keyword ....."; and MUST
  179. treat "opt keyword ....." as synonymous with "keyword ......" when keyword
  180. is recognized.
  181. Implementations before 0.1.2.5-alpha rejected any document with a
  182. KeywordLine that started with a keyword that they didn't recognize.
  183. When generating documents that need to be read by older versions of Tor,
  184. implementations MUST prefix items not recognized by older versions of
  185. Tor with an "opt" until those versions of Tor are obsolete. [Note that
  186. key certificates, status vote documents, extra info documents, and
  187. status consensus documents will never by read by older versions of Tor.]
  188. Other implementations that want to extend Tor's directory format MAY
  189. introduce their own items. The keywords for extension items SHOULD start
  190. with the characters "x-" or "X-", to guarantee that they will not conflict
  191. with keywords used by future versions of Tor.
  192. In our document descriptions below, we tag Items with a multiplicity in
  193. brackets. Possible tags are:
  194. "At start, exactly once": These items MUST occur in every instance of
  195. the document type, and MUST appear exactly once, and MUST be the
  196. first item in their documents.
  197. "Exactly once": These items MUST occur exactly one time in every
  198. instance of the document type.
  199. "At end, exactly once": These items MUST occur in every instance of
  200. the document type, and MUST appear exactly once, and MUST be the
  201. last item in their documents.
  202. "At most once": These items MAY occur zero or one times in any
  203. instance of the document type, but MUST NOT occur more than once.
  204. "Any number": These items MAY occur zero, one, or more times in any
  205. instance of the document type.
  206. "Once or more": These items MUST occur at least once in any instance
  207. of the document type, and MAY occur more.
  208. 1.3. Signing documents
  209. Every signable document below is signed in a similar manner, using a
  210. given "Initial Item", a final "Signature Item", a digest algorithm, and
  211. a signing key.
  212. The Initial Item must be the first item in the document.
  213. The Signature Item has the following format:
  214. <signature item keyword> [arguments] NL SIGNATURE NL
  215. The "SIGNATURE" Object contains a signature (using the signing key) of
  216. the PKCS1-padded digest of the entire document, taken from the
  217. beginning of the Initial item, through the newline after the Signature
  218. Item's keyword and its arguments.
  219. Unless otherwise, the digest algorithm is SHA-1.
  220. All documents are invalid unless signed with the correct signing key.
  221. The "Digest" of a document, unless stated otherwise, is its digest *as
  222. signed by this signature scheme*.
  223. 2. Router operation and formats
  224. ORs SHOULD generate a new router descriptor and a new extra-info
  225. document whenever any of the following events have occurred:
  226. - A period of time (18 hrs by default) has passed since the last
  227. time a descriptor was generated.
  228. - A descriptor field other than bandwidth or uptime has changed.
  229. - Bandwidth has changed by more than +/- 50% from the last time a
  230. descriptor was generated, and at least a given interval of time
  231. (20 mins by default) has passed since then.
  232. - Its uptime has been reset (by restarting).
  233. After generating a descriptor, ORs upload them to every directory
  234. authority they know, by posting them (in order) to the URL
  235. http://<hostname:port>/tor/
  236. 2.1. Router descriptor format
  237. Router descriptors consist of the following items. For backward
  238. compatibility, there should be an extra NL at the end of each router
  239. descriptor.
  240. In lines that take multiple arguments, extra arguments SHOULD be
  241. accepted and ignored.
  242. "router" nickname address ORPort SOCKSPort DirPort NL
  243. [At start, exactly once.]
  244. Indicates the beginning of a router descriptor. "address" must be an
  245. IPv4 address in dotted-quad format. The last three numbers indicate
  246. the TCP ports at which this OR exposes functionality. ORPort is a port
  247. at which this OR accepts TLS connections for the main OR protocol;
  248. SOCKSPort is deprecated and should always be 0; and DirPort is the
  249. port at which this OR accepts directory-related HTTP connections. If
  250. any port is not supported, the value 0 is given instead of a port
  251. number.
  252. "bandwidth" bandwidth-avg bandwidth-burst bandwidth-observed NL
  253. [Exactly once]
  254. Estimated bandwidth for this router, in bytes per second. The
  255. "average" bandwidth is the volume per second that the OR is willing to
  256. sustain over long periods; the "burst" bandwidth is the volume that
  257. the OR is willing to sustain in very short intervals. The "observed"
  258. value is an estimate of the capacity this server can handle. The
  259. server remembers the max bandwidth sustained output over any ten
  260. second period in the past day, and another sustained input. The
  261. "observed" value is the lesser of these two numbers.
  262. "platform" string NL
  263. [At most once]
  264. A human-readable string describing the system on which this OR is
  265. running. This MAY include the operating system, and SHOULD include
  266. the name and version of the software implementing the Tor protocol.
  267. "published" YYYY-MM-DD HH:MM:SS NL
  268. [Exactly once]
  269. The time, in GMT, when this descriptor (and its corresponding
  270. extra-info document if any) was generated.
  271. "fingerprint" fingerprint NL
  272. [At most once]
  273. A fingerprint (a HASH_LEN-byte of asn1 encoded public key, encoded in
  274. hex, with a single space after every 4 characters) for this router's
  275. identity key. A descriptor is considered invalid (and MUST be
  276. rejected) if the fingerprint line does not match the public key.
  277. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should
  278. be marked with "opt" until earlier versions of Tor are obsolete.]
  279. "hibernating" bool NL
  280. [At most once]
  281. If the value is 1, then the Tor server was hibernating when the
  282. descriptor was published, and shouldn't be used to build circuits.
  283. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should be
  284. marked with "opt" until earlier versions of Tor are obsolete.]
  285. "uptime" number NL
  286. [At most once]
  287. The number of seconds that this OR process has been running.
  288. "onion-key" NL a public key in PEM format
  289. [Exactly once]
  290. This key is used to encrypt EXTEND cells for this OR. The key MUST be
  291. accepted for at least 1 week after any new key is published in a
  292. subsequent descriptor. It MUST be 1024 bits.
  293. "signing-key" NL a public key in PEM format
  294. [Exactly once]
  295. The OR's long-term identity key. It MUST be 1024 bits.
  296. "accept" exitpattern NL
  297. "reject" exitpattern NL
  298. [Any number]
  299. These lines describe an "exit policy": the rules that an OR follows when
  300. deciding whether to allow a new stream to a given address. The
  301. 'exitpattern' syntax is described below. The rules are considered in
  302. order; if no rule matches, the address will be accepted. For clarity,
  303. the last such entry SHOULD be accept *:* or reject *:*.
  304. "router-signature" NL Signature NL
  305. [At end, exactly once]
  306. The "SIGNATURE" object contains a signature of the PKCS1-padded
  307. hash of the entire router descriptor, taken from the beginning of the
  308. "router" line, through the newline after the "router-signature" line.
  309. The router descriptor is invalid unless the signature is performed
  310. with the router's identity key.
  311. "contact" info NL
  312. [At most once]
  313. Describes a way to contact the server's administrator, preferably
  314. including an email address and a PGP key fingerprint.
  315. "family" names NL
  316. [At most once]
  317. 'Names' is a space-separated list of server nicknames or
  318. hexdigests. If two ORs list one another in their "family" entries,
  319. then OPs should treat them as a single OR for the purpose of path
  320. selection.
  321. For example, if node A's descriptor contains "family B", and node B's
  322. descriptor contains "family A", then node A and node B should never
  323. be used on the same circuit.
  324. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  325. [At most once]
  326. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  327. [At most once]
  328. Declare how much bandwidth the OR has used recently. Usage is divided
  329. into intervals of NSEC seconds. The YYYY-MM-DD HH:MM:SS field
  330. defines the end of the most recent interval. The numbers are the
  331. number of bytes used in the most recent intervals, ordered from
  332. oldest to newest.
  333. [We didn't start parsing these lines until Tor 0.1.0.6-rc; they should
  334. be marked with "opt" until earlier versions of Tor are obsolete.]
  335. [See also migration notes in section 2.2.1.]
  336. "eventdns" bool NL
  337. [At most once]
  338. Declare whether this version of Tor is using the newer enhanced
  339. dns logic. Versions of Tor without eventdns SHOULD NOT be used for
  340. reverse hostname lookups.
  341. [All versions of Tor before 0.1.2.2-alpha should be assumed to have
  342. this option set to 0 if it is not present. All Tor versions at
  343. 0.1.2.2-alpha or later should be assumed to have this option set to
  344. 1 if it is not present. Until 0.1.2.1-alpha-dev, this option was
  345. not generated, even when eventdns was in use. Versions of Tor
  346. before 0.1.2.1-alpha-dev did not parse this option, so it should be
  347. marked "opt". The dnsworker logic has been removed, so this option
  348. should not be used by new server code. However, it can still be
  349. used, and should still be recognized by new code until Tor 0.1.2.x
  350. is obsolete.]
  351. "caches-extra-info" NL
  352. [At most once.]
  353. Present only if this router is a directory cache that provides
  354. extra-info documents.
  355. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  356. before 0.1.2.5-alpha will reject descriptors containing it unless
  357. it is prefixed with "opt"; it should be so prefixed until these
  358. versions are obsolete.]
  359. "extra-info-digest" digest NL
  360. [At most once]
  361. "Digest" is a hex-encoded digest (using upper-case characters)
  362. of the router's extra-info document, as signed in the router's
  363. extra-info. (If this field is absent, the router is not uploading
  364. a corresponding extra-info document.)
  365. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  366. before 0.1.2.5-alpha will reject descriptors containing it unless
  367. it is prefixed with "opt"; it should be so prefixed until these
  368. versions are obsolete.]
  369. 2.2. Extra-info documents
  370. Extra-info documents consist of the following items:
  371. "extra-info" Nickname Fingerprint NL
  372. [At start, exactly once.]
  373. Identifies what router this is an extra info descriptor for.
  374. Fingerprint is encoded in hex (using upper-case letters), with
  375. no spaces.
  376. "published"
  377. [Exactly once.]
  378. The time, in GMT, when this document (and its corresponding router
  379. descriptor if any) was generated. It MUST match the published time
  380. in the corresponding router descriptor.
  381. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  382. [At most once.]
  383. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  384. [At most once.]
  385. As documented in 2.1 above. See migration notes in section 2.2.1.
  386. "router-signature" NL Signature NL
  387. [At end, exactly once.]
  388. A document signature as documented in section 1.3, using the
  389. initial item "extra-info" and the final item "router-signature",
  390. signed with the router's identity key.
  391. 2.2.1. Moving history fields to extra-info documents.
  392. Tools that want to use the read-history and write-history values SHOULD
  393. download extra-info documents as well as router descriptors. Such
  394. tools SHOULD accept history values from both sources; if they appear in
  395. both documents, the values in the extra-info documents are authoritative.
  396. At some future time, to save space, new versions of Tor will no longer
  397. generate router descriptors containing read-history or write-history.
  398. Tools should continue to accept read-history and write-history values
  399. in router descriptors produced by older versions of Tor.
  400. 2.3. Nonterminals in router descriptors
  401. nickname ::= between 1 and 19 alphanumeric characters, case-insensitive.
  402. hexdigest ::= a '$', followed by 20 hexadecimal characters.
  403. [Represents a server by the digest of its identity key.]
  404. exitpattern ::= addrspec ":" portspec
  405. portspec ::= "*" | port | port "-" port
  406. port ::= an integer between 1 and 65535, inclusive.
  407. [Some implementations incorrectly generate ports with value 0.
  408. Implementations SHOULD accept this, and SHOULD NOT generate it.
  409. Connections to port 0 are never permitted.]
  410. addrspec ::= "*" | ip4spec | ip6spec
  411. ipv4spec ::= ip4 | ip4 "/" num_ip4_bits | ip4 "/" ip4mask
  412. ip4 ::= an IPv4 address in dotted-quad format
  413. ip4mask ::= an IPv4 mask in dotted-quad format
  414. num_ip4_bits ::= an integer between 0 and 32
  415. ip6spec ::= ip6 | ip6 "/" num_ip6_bits
  416. ip6 ::= an IPv6 address, surrounded by square brackets.
  417. num_ip6_bits ::= an integer between 0 and 128
  418. bool ::= "0" | "1"
  419. 3. Formats produced by directory authorities.
  420. Every authority has two keys used in this protocol: a signing key, and
  421. an authority identity key. (Authorities also have a router identity
  422. key used in their role as a router and by earlier versions of the
  423. directory protocol.) The identity key is used from time to time to
  424. sign new key certificates using new signing keys; it is very sensitive.
  425. The signing key is used to sign key certificates and status documents.
  426. There are three kinds of documents generated by directory authorities:
  427. Key certificates
  428. Status votes
  429. Status consensuses
  430. Each is discussed below.
  431. 3.1. Key certificates
  432. Key certificates consist of the following items:
  433. "dir-key-certificate-version" version NL
  434. [At start, exactly once.]
  435. Determines the version of the key certificate. MUST be "3" for
  436. the protocol described in this document. Implementations MUST
  437. reject formats they don't understand.
  438. "fingerprint" fingerprint NL
  439. [Exactly once.]
  440. Hexadecimal encoding without spaces based on the authority's
  441. identity key.
  442. "dir-identity-key" NL a public key in PEM format
  443. [Exactly once.]
  444. The long-term authority identity key for this authority. This key
  445. SHOULD be at least 2048 bits long; it MUST NOT be shorter than
  446. 1024 bits.
  447. "dir-key-published" YYYY-MM-DD HH:MM:SS NL
  448. [Exactly once.]
  449. The time (in GMT) when this document and corresponding key were
  450. last generated.
  451. "dir-key-expires" YYYY-MM-DD HH:MM:SS NL
  452. [Exactly once.]
  453. A time (in GMT) after which this key is no longer valid.
  454. "dir-signing-key" NL a key in PEM format
  455. [Exactly once.]
  456. The directory server's public signing key. This key MUST be at
  457. least 1024 bits, and MAY be longer.
  458. "dir-key-certification" NL Signature NL
  459. [At end, exactly once.]
  460. A document signature as documented in section 1.3, using the
  461. initial item "dir-key-certificate-version" and the final item
  462. "dir-key-certification", signed with the authority identity key.
  463. Authorities MUST generate a new signing key and corresponding
  464. certificate before the key expires.
  465. 3.2. Vote and consensus status documents
  466. Votes and consensuses are more strictly formatted then other documents
  467. in this specification, since different authorities must be able to
  468. generate exactly the same consensus given the same set of votes.
  469. The procedure for deciding when to generate vote and consensus status
  470. documents are described in section XXX below.
  471. Status documents contain a preamble, an authority section, a list of
  472. router status entries, and one more footers signature, in that order.
  473. Unlike other formats described above, a SP in these documents must be a
  474. single space character (hex 20).
  475. Some items appear only in votes, and some items appear only in
  476. consensuses. Unless specified, items occur in both.
  477. The preamble contains the following items. They MUST occur in the
  478. order given here:
  479. "network-status-version" SP version NL.
  480. [At start, exactly once.]
  481. A document format version. For this specification, the version is
  482. "3".
  483. "vote-status" SP type NL
  484. [Exactly once.]
  485. The status MUST be "vote" or "consensus", depending on the type of
  486. the document.
  487. "published" SP YYYY-MM-DD SP HH:MM:SS NL
  488. [Exactly once for votes; Does not occur in consensuses.]
  489. The publication time for this status document (if a vote).
  490. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  491. [Exactly once.]
  492. The start of the Interval for this vote.
  493. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  494. [Exactly once.]
  495. The end of the Interval for this vote, plus CONSENSUS_DELAY.
  496. "client-versions" SP VersionList NL
  497. [At most once.]
  498. A comma-separated list of recommended client versions, in
  499. ascending order. If absent, no opinion is held about client
  500. versions.
  501. "server-versions" SP VersionList NL
  502. [At most once.]
  503. A comma-separated list of recommended server versions, in
  504. ascending order. If absent, no opinion is held about server
  505. versions.
  506. "known-flags" SP FlagList NL
  507. [Exactly once.]
  508. A space-separated list of all of the flags that this document
  509. might contain. A flag is "known" either because the authority
  510. knows about them and might set them (if in a vote), or because
  511. enough votes were counted for the consensus for an authoritative
  512. opinion to have been formed about their status.
  513. The authority section of a vote contains the following items, followed
  514. in turn by the authority's current key certificate:
  515. "dir-source" SP nickname SP identity SP address SP IP SP dirport NL
  516. [Exactly once, at start]
  517. Describes this authority. The nickname is a convenient identifier
  518. for the authority. The identity is a hex fingerprint of the
  519. authority's current identity key. The address is the server's
  520. hostname. The IP is the server's current IP address, and dirport
  521. is its current directory port.
  522. "contact" SP string NL
  523. [At most once.]
  524. An arbitrary string describing how to contact the directory
  525. server's administrator. Administrators should include at least an
  526. email address and a PGP fingerprint.
  527. The authority section of a consensus contains groups the following
  528. items, in the order given, with one group for each authority that
  529. contributed to the consensus:
  530. "dir-source" SP nickname SP address SP IP SP dirport NL
  531. [Exactly once, at start]
  532. As in the authority section of a vote.
  533. "contact" SP string NL
  534. [At most once.]
  535. As in the authority section of a vote.
  536. "fingerprint" SP fingerprint NL
  537. [Exactly once.]
  538. A hex fingerprint, without spaces, of the authority's current
  539. identity key.
  540. "vote-digest" SP digest NL
  541. [Exactly once.]
  542. A digest of the vote from the authority that contributed to this
  543. consensus.
  544. Each router status entry contains the following items. Router status
  545. entries are sorted in ascending order by identity digest.
  546. "r" SP nickname SP identity SP digest SP publication SP IP SP ORPort
  547. SP DirPort NL
  548. [At start, exactly once.]
  549. "Nickname" is the OR's nickname. "Identity" is a hash of its
  550. identity key, encoded in base64, with trailing equals sign(s)
  551. removed. "Digest" is a hash of its most recent descriptor (as
  552. signed), encoded in base64 as "identity". "Publication" is the
  553. publication time of its most recent descriptor, in the form
  554. YYYY-MM-DD HH:MM:SS, in GMT. "IP" is its current IP address;
  555. ORPort is its current OR port, "DirPort" is it's current directory
  556. port, or "0" for "none".
  557. "s" SP Flags NL
  558. [At most once.]
  559. A series of space-separated status flags, in alphabetical order.
  560. Currently documented flags are:
  561. "Authority" if the router is a directory authority.
  562. "BadExit" if the router is believed to be useless as an exit node
  563. (because its ISP censors it, because it is behind a restrictive
  564. proxy, or for some similar reason).
  565. "BadDirectory" if the router is believed to be useless as a
  566. directory cache (because its directory port isn't working,
  567. its bandwidth is always throttled, or for some similar
  568. reason).
  569. "Exit" if the router is useful for building general-purpose exit
  570. circuits.
  571. "Fast" if the router is suitable for high-bandwidth circuits.
  572. "Guard" if the router is suitable for use as an entry guard.
  573. "Named" if the router's identity-nickname mapping is canonical,
  574. and this authority binds names.
  575. "Stable" if the router is suitable for long-lived circuits.
  576. "Running" if the router is currently usable.
  577. "Valid" if the router has been 'validated'.
  578. "V2Dir" if the router implements the v2 directory protocol.
  579. "V3Dir" if the router implements this protocol.
  580. "v" SP version NL
  581. [At most once.]
  582. The version of the Tor protocol that this server is running. If
  583. the value begins with "Tor" SP, the rest of the string is a Tor
  584. version number, and the protocol is "The Tor protocol as supported
  585. by the given version of Tor." Otherwise, if the value begins with
  586. some other string, Tor has upgraded to a more sophisticated
  587. protocol versioning system, and the protocol is "a version of the
  588. Tor protocol more recent than any we recognize."
  589. The signature section contains the following item, which appears
  590. Exactly Once for a vote, and At Least Once for a consensus.
  591. "directory-signature" SP identity SP digest NL Signature
  592. This is a signature of the status document, with the initial item
  593. "network-status-version", and the signature item
  594. "directory-signature", using the signing key. (In this case, we
  595. take the hash through the _space_ after directory-signature, not
  596. the newline: this ensures that all authorities sign the same
  597. thing.) "identity" is the hex-encoded digest of the authority
  598. identity key of the signing authority, and "digest" is the
  599. hex-encoded digest of the current authority signing key of the
  600. signing authority.
  601. 3.3. Deciding how to vote.
  602. (This section describes how directory authorities choose which status
  603. flags to apply to routers, as of Tor 0.2.0.0-alpha-dev. Later directory
  604. authorities MAY do things differently, so long as clients keep working
  605. well. Clients MUST NOT depend on the exact behaviors in this section.)
  606. In the below definitions, a router is considered "active" if it is
  607. running, valid, and not hibernating.
  608. "Valid" -- a router is 'Valid' if it is running a version of Tor not
  609. known to be broken, and the directory authority has not blacklisted
  610. it as suspicious.
  611. "Named" -- Directory authority administrators may decide to support name
  612. binding. If they do, then they must maintain a file of
  613. nickname-to-identity-key mappings, and try to keep this file consistent
  614. with other directory authorities. If they don't, they act as clients, and
  615. report bindings made by other directory authorities (name X is bound to
  616. identity Y if at least one binding directory lists it, and no directory
  617. binds X to some other Y'.) A router is called 'Named' if the router
  618. believes the given name should be bound to the given key.
  619. "Running" -- A router is 'Running' if the authority managed to connect to
  620. it successfully within the last 30 minutes.
  621. "Stable" -- A router is 'Stable' if it is active, and either its
  622. uptime is at least the median uptime for known active routers, or
  623. its uptime is at least 30 days. Routers are never called stable if
  624. they are running a version of Tor known to drop circuits stupidly.
  625. (0.1.1.10-alpha through 0.1.1.16-rc are stupid this way.)
  626. "Fast" -- A router is 'Fast' if it is active, and its bandwidth is
  627. in the top 7/8ths for known active routers.
  628. "Guard" -- A router is a possible 'Guard' if it is 'Stable' and its
  629. bandwidth is above median for known active routers. If the total
  630. bandwidth of active non-BadExit Exit servers is less than one third
  631. of the total bandwidth of all active servers, no Exit is listed as
  632. a Guard.
  633. "Authority" -- A router is called an 'Authority' if the authority
  634. generating the network-status document believes it is an authority.
  635. "V2Dir" -- A router supports the v2 directory protocol if it has an open
  636. directory port, and it is running a version of the directory protocol that
  637. supports the functionality clients need. (Currently, this is
  638. 0.1.1.9-alpha or later.)
  639. "V3Dir" -- A router supports the v3 directory protocol if it has an open
  640. directory port, and it is running a version of the directory protocol that
  641. supports the functionality clients need. (Currently, this is
  642. 0.2.0.?????-alpha or later.)
  643. Directory server administrators may label some servers or IPs as
  644. blacklisted, and elect not to include them in their network-status lists.
  645. Thus, the network-status list includes all non-blacklisted,
  646. non-expired, non-superseded descriptors.
  647. 3.4. Computing a consensus from a set of votes
  648. Given a set of votes, authorities compute the contents of the consensus
  649. document as follows:
  650. The "valid-after" is the latest of all valid-after times on the votes.
  651. The "valid-until" is the earliest of all valid-until times on the
  652. votes.
  653. "client-versions" and "server-versions" are sorted in ascending
  654. order; A version is recommended in the consensus if it is recommended
  655. by more than half of the voting authorities that included a
  656. client-versions or server-versions lines in their votes.
  657. The authority item groups (dir-source, contact, fignerprint,
  658. vote-digest) are taken from the votes of the voting
  659. authorities. These groups are sorted by the digests of the
  660. authorities identity keys, in ascending order.
  661. A router status entry is included in the result if it is included by more
  662. than half of the authorities (total authorities, not just those whose
  663. votes we have). A router entry has a flag set if it is included by
  664. more than half of the authorities who care about that flag. Two
  665. router entries are "the same" if they have the same identity digest.
  666. We use whatever descriptor digest is attested to by the most
  667. authorities among the voters, breaking ties in favor of the one with
  668. the most recent publication time.
  669. The signatures at the end of the document appear are sorted in
  670. ascending order by identity digest.
  671. 3.4. Detached signatures
  672. Assuming full connectivity, every authority should compute and sign the
  673. same consensus directory in each period. Therefore, it isn't necessary to
  674. download the consensus computed by each authority; instead, the
  675. authorities only push/fetch each others' signatures. A "detached
  676. signature" document contains items as follows:
  677. "consensus-digest" SP Digest NL
  678. [At start, at most once.]
  679. The digest of the consensus being signed.
  680. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  681. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  682. [As in the consensus]
  683. "directory signature"
  684. [As in the consensus; the signature object is the same as in the
  685. consensus document.]
  686. 4. Directory server operation
  687. All directory authorities and directory caches ("directory servers")
  688. implement this section, except as noted.
  689. 4.1. Accepting uploads (authorities only)
  690. When a router posts a signed descriptor to a directory authority, the
  691. authority first checks whether it is well-formed and correctly
  692. self-signed. If it is, the authority next verifies that the nickname
  693. question is already assigned to a router with a different public key.
  694. Finally, the authority MAY check that the router is not blacklisted
  695. because of its key, IP, or another reason.
  696. If the descriptor passes these tests, and the authority does not already
  697. have a descriptor for a router with this public key, it accepts the
  698. descriptor and remembers it.
  699. If the authority _does_ have a descriptor with the same public key, the
  700. newly uploaded descriptor is remembered if its publication time is more
  701. recent than the most recent old descriptor for that router, and either:
  702. - There are non-cosmetic differences between the old descriptor and the
  703. new one.
  704. - Enough time has passed between the descriptors' publication times.
  705. (Currently, 12 hours.)
  706. Differences between router descriptors are "non-cosmetic" if they would be
  707. sufficient to force an upload as described in section 2 above.
  708. Note that the "cosmetic difference" test only applies to uploaded
  709. descriptors, not to descriptors that the authority downloads from other
  710. authorities.
  711. When a router posts a signed extra-info document to a directory authority,
  712. the authority again checks it for well-formedness and correct signature,
  713. and checks that its matches the extra-info-digest in some router
  714. descriptor that it believes is currently useful. If so, it accepts it and
  715. stores it and serves it as requested. If not, it drops it.
  716. 4.2. Voting (authorities only)
  717. Authorities divide time into Intervals. Authority administrators SHOULD
  718. try to all pick the same interval length, and SHOULD pick intervals that
  719. are commonly used divisions of time (e.g., 5 minutes, 15 minutes, 30
  720. minutes, 60 minutes, 90 minutes). Voting intervals SHOULD be chosen to
  721. divide evenly into a 24-hour day.
  722. Authorities MUST take pains to ensure that their clocks remain accurate,
  723. for example by running NTP.
  724. The first voting period of each day begins at 00:00 (midnight) GMT. If
  725. the last period of the day would be truncated by one-half or more, it is
  726. merged with the second-to-last period.
  727. An authority SHOULD publish its vote immediately at the start of each voting
  728. period. It does this by making it available at
  729. http://<hostname>/tor/status-vote/current/authority.z
  730. and sending it in an HTTP POST request to each other authority at the URL
  731. http://<hostname>/tor/post/vote
  732. (Note that this requires the authority to settle upon and finalize its
  733. vote slightly before the start of the voting period.)
  734. If, VOTING_DELAY minutes after the voting period has begun, an authority
  735. does not have a current statement from another authority, the first
  736. authority retrieves the other's statement.
  737. Once an authority has a vote from another authority, it makes it available
  738. at
  739. http://<hostname>/tor/status-vote/current/<fp>.z
  740. where <fp> is the fingerprint of the other authority's identity key.
  741. The consensus status, along with as many signatures as the server
  742. currently knows, should be available at
  743. http://<hostname>/tor/status-vote/current/consensus.z
  744. All of the detached signatures it knows for consensus status should be
  745. available at:
  746. http://<hostname>/tor/status-vote/current/consensus-signatures.z
  747. Once an authority has computed and signed a consensus network status, it
  748. should send its detached signature to each other authority in an HTTP POST
  749. request to the URL:
  750. http://<hostname>/tor/post/consensus-signature
  751. [XXX Note why we support push-and-then-pull.]
  752. [XXX possible future features include support for downloading old
  753. consensuses.]
  754. [XXX Constants: VOTING_DELAY, CONSENSUS_DELAY]
  755. 4.3. Downloading consensus status documents (caches only)
  756. All directory servers (authorities and caches) try to keep a fresh
  757. set of network-status consensus documents to serve to clients. Every
  758. 15 minutes, or whenever the valid-until field on its most current
  759. consensus is about to expire
  760. [XXXX finish this section]
  761. 4.4. Downloading and storing router descriptors (authorities and caches)
  762. Periodically (currently, every 10 seconds), directory servers check
  763. whether there are any specific descriptors that they do not have and that
  764. they are not currently trying to download. Caches identify these
  765. descriptors by hash in the recent network-status consensus documents;
  766. authorities identify them by hash in vote (if publication date is more
  767. recent than the descriptor we currently have).
  768. [XXXX need a way to fetch descriptors ahead of the vote? v2 status docs can
  769. do that for now.]
  770. If so, the directory server launches requests to the authorities for these
  771. descriptors, such that each authority is only asked for descriptors listed
  772. in its most recent vote (if the requester is an authority) or in the
  773. consensus (if the requester is a cache). If we're an authority, and more
  774. than one authority lists the descriptor, we choose which to ask at random.
  775. If one of these downloads fails, we do not try to download that descriptor
  776. from the authority that failed to serve it again unless we receive a newer
  777. network-status (consensus or vote) from that authority that lists the same
  778. descriptor.
  779. Directory servers must potentially cache multiple descriptors for each
  780. router. Servers must not discard any descriptor listed by any recent
  781. consensus. If there is enough space to store additional descriptors,
  782. servers SHOULD try to hold those which clients are likely to download the
  783. most. (Currently, this is judged based on the interval for which each
  784. descriptor seemed newest.)
  785. [XXXX define recent]
  786. Authorities SHOULD NOT download descriptors for routers that they would
  787. immediately reject for reasons listed in 3.1.
  788. 4.5. Downloading and storing extra-info documents
  789. All authorities, and any cache that chooses to cache extra-info documents,
  790. and any client that uses extra-info documents, should implement this
  791. section.
  792. Note that generally, clients don't need extra-info documents.
  793. Periodically, the Tor instance checks whether it is missing any extra-info
  794. documents: in other words, if it has any router descriptors with an
  795. extra-info-digest field that does not match any of the extra-info
  796. documents currently held. If so, it downloads whatever extra-info
  797. documents are missing. Caches download from authorities; non-caches try
  798. to download from caches. We follow the same splitting and back-off rules
  799. as in 4.4 (if a cache) or 5.3 (if a client).
  800. 4.6. General-use HTTP URLs
  801. "Fingerprints" in these URLs are base-16-encoded SHA1 hashes.
  802. The most recent v3 consensus should be available at:
  803. http://<hostname>/tor/status-vote/current/consensus.z
  804. A concatenated set of all the current key certificates should be available
  805. at:
  806. http://<hostname>/tor/keys/all.z
  807. The key certificate for this server (if it is an authority) should be
  808. available at:
  809. http://<hostname>/tor/keys/authority.z
  810. The most recent descriptor for a server whose identity key has a
  811. fingerprint of <F> should be available at:
  812. http://<hostname>/tor/server/fp/<F>.z
  813. The most recent descriptors for servers with identity fingerprints
  814. <F1>,<F2>,<F3> should be available at:
  815. http://<hostname>/tor/server/fp/<F1>+<F2>+<F3>.z
  816. (NOTE: Implementations SHOULD NOT download descriptors by identity key
  817. fingerprint. This allows a corrupted server (in collusion with a cache) to
  818. provide a unique descriptor to a client, and thereby partition that client
  819. from the rest of the network.)
  820. The server descriptor with (descriptor) digest <D> (in hex) should be
  821. available at:
  822. http://<hostname>/tor/server/d/<D>.z
  823. The most recent descriptors with digests <D1>,<D2>,<D3> should be
  824. available at:
  825. http://<hostname>/tor/server/d/<D1>+<D2>+<D3>.z
  826. The most recent descriptor for this server should be at:
  827. http://<hostname>/tor/server/authority.z
  828. [Nothing in the Tor protocol uses this resource yet, but it is useful
  829. for debugging purposes. Also, the official Tor implementations
  830. (starting at 0.1.1.x) use this resource to test whether a server's
  831. own DirPort is reachable.]
  832. A concatenated set of the most recent descriptors for all known servers
  833. should be available at:
  834. http://<hostname>/tor/server/all.z
  835. Extra-info documents are available at the URLS
  836. http://<hostname>/tor/extra/d/...
  837. http://<hostname>/tor/extra/fp/...
  838. http://<hostname>/tor/extra/all[.z]
  839. http://<hostname>/tor/extra/authority[.z]
  840. (As for /tor/server/ URLs: supports fetching extra-info
  841. documents by their digest, by the fingerprint of their servers,
  842. or all at once. When serving by fingerprint, we serve the
  843. extra-info that corresponds to the descriptor we would serve by
  844. that fingerprint. Only directory authorities of version
  845. 0.2.0.1-alpha or later are guaranteed to support the first
  846. three classes of URLs. Caches may support them, and MUST
  847. support them if they have advertised "caches-extra-info".)
  848. For debugging, directories SHOULD expose non-compressed objects at URLs like
  849. the above, but without the final ".z".
  850. Clients MUST handle compressed concatenated information in two forms:
  851. - A concatenated list of zlib-compressed objects.
  852. - A zlib-compressed concatenated list of objects.
  853. Directory servers MAY generate either format: the former requires less
  854. CPU, but the latter requires less bandwidth.
  855. Clients SHOULD use upper case letters (A-F) when base16-encoding
  856. fingerprints. Servers MUST accept both upper and lower case fingerprints
  857. in requests.
  858. 5. Client operation: downloading information
  859. Every Tor that is not a directory server (that is, those that do
  860. not have a DirPort set) implements this section.
  861. 5.1. Downloading network-status documents
  862. Each client maintains a list of directory authorities. Insofar as
  863. possible, clients SHOULD all use the same list.
  864. Clients try to have a live consensus network-status document at all times.
  865. A network-status document is "live" if the time in its valid-until field
  866. has not passed.
  867. If a client is missing a live network-status document, it tries to fetch
  868. it from a directory cache (or from an authority if it knows no caches).
  869. On failure, the client waits briefly, then tries that network-status
  870. document again from another cache. The client does not build circuits
  871. until it has a live network-status consensus document, and it has
  872. descriptors for more than 1/4 of the routers that it believes are running.
  873. [XXXX handling clock skew at client side?]
  874. [XXXX fall-back to most recent?]
  875. (Note: clients can and should pick caches based on the network-status
  876. information they have: once they have first fetched network-status info
  877. from an authority, they should not need to go to the authority directly
  878. again.)
  879. 5.2. Downloading and storing router descriptors
  880. Clients try to have the best descriptor for each router. A descriptor is
  881. "best" if:
  882. * It is listed in the consensus network-status document.
  883. Periodically (currently every 10 seconds) clients check whether there are
  884. any "downloadable" descriptors. A descriptor is downloadable if:
  885. - It is the "best" descriptor for some router.
  886. - The descriptor was published at least 10 minutes in the past.
  887. (This prevents clients from trying to fetch descriptors that the
  888. mirrors have probably not yet retrieved and cached.)
  889. - The client does not currently have it.
  890. - The client is not currently trying to download it.
  891. - The client would not discard it immediately upon receiving it.
  892. - The client thinks it is running and valid (see 6.1 below).
  893. If at least 16 known routers have downloadable descriptors, or if
  894. enough time (currently 10 minutes) has passed since the last time the
  895. client tried to download descriptors, it launches requests for all
  896. downloadable descriptors, as described in 5.3 below.
  897. When a descriptor download fails, the client notes it, and does not
  898. consider the descriptor downloadable again until a certain amount of time
  899. has passed. (Currently 0 seconds for the first failure, 60 seconds for the
  900. second, 5 minutes for the third, 10 minutes for the fourth, and 1 day
  901. thereafter.) Periodically (currently once an hour) clients reset the
  902. failure count.
  903. Clients retain the most recent descriptor they have downloaded for each
  904. router so long as it is not too old (currently, 48 hours), OR so long as
  905. no better descriptor has been downloaded for the same router.
  906. [Versions of Tor before 0.1.2.3-alpha would discard descriptors simply for
  907. being published too far in the past.] [The code seems to discard
  908. descriptors in all cases after they're 5 days old. True? -RD]
  909. 5.3. Managing downloads
  910. When a client has no consensus network-status document, it downloads it
  911. from a randomly chosen authority. In all other cases, the client
  912. downloads from caches randomly chosen from among those believed to be V2
  913. directory servers. (This information comes from the network-status
  914. documents; see 6 below.)
  915. When downloading multiple router descriptors, the client chooses multiple
  916. mirrors so that:
  917. - At least 3 different mirrors are used, except when this would result
  918. in more than one request for under 4 descriptors.
  919. - No more than 128 descriptors are requested from a single mirror.
  920. - Otherwise, as few mirrors as possible are used.
  921. After choosing mirrors, the client divides the descriptors among them
  922. randomly.
  923. After receiving any response client MUST discard any network-status
  924. documents and descriptors that it did not request.
  925. 6. Using directory information
  926. Everyone besides directory authorities uses the approaches in this section
  927. to decide which servers to use and what their keys are likely to be.
  928. (Directory authorities just believe their own opinions, as in 3.1 above.)
  929. 6.1. Choosing routers for circuits.
  930. Circuits SHOULD NOT be built until the client has enough directory
  931. information: a live consensus network status [XXXX fallback?] and
  932. descriptors for at least 1/4 of the servers believed to be running.
  933. A server is "listed" if it is included by the consensus network-status
  934. document. Clients SHOULD NOT use unlisted servers.
  935. These flags are used as follows:
  936. - Clients SHOULD NOT use non-'Valid' or non-'Running' routers unless
  937. requested to do so.
  938. - Clients SHOULD NOT use non-'Fast' routers for any purpose other than
  939. very-low-bandwidth circuits (such as introduction circuits).
  940. - Clients SHOULD NOT use non-'Stable' routers for circuits that are
  941. likely to need to be open for a very long time (such as those used for
  942. IRC or SSH connections).
  943. - Clients SHOULD NOT choose non-'Guard' nodes when picking entry guard
  944. nodes.
  945. - Clients SHOULD NOT download directory information from non-'V2Dir'
  946. caches.
  947. 6.2. Managing naming
  948. [XXXX rewrite for v3]
  949. In order to provide human-memorable names for individual server
  950. identities, some directory servers bind names to IDs. Clients handle
  951. names in two ways:
  952. When a client encounters a name it has not mapped before:
  953. If all the live "Naming" network-status documents the client has
  954. claim that the name binds to some identity ID, and the client has at
  955. least three live network-status documents, the client maps the name to
  956. ID.
  957. When a user tries to refer to a router with a name that does not have a
  958. mapping under the above rules, the implementation SHOULD warn the user.
  959. After giving the warning, the implementation MAY use a router that at
  960. least one Naming authority maps the name to, so long as no other naming
  961. authority maps that name to a different router. If no Naming authority
  962. maps the name to a router, the implementation MAY use any router that
  963. advertises the name.
  964. Not every router needs a nickname. When a router doesn't configure a
  965. nickname, it publishes with the default nickname "Unnamed". Authorities
  966. SHOULD NOT ever mark a router with this nickname as Named; client software
  967. SHOULD NOT ever use a router in response to a user request for a router
  968. called "Unnamed".
  969. 6.3. Software versions
  970. An implementation of Tor SHOULD warn when it has fetched a consensus
  971. network-status, and it is running a software version not listed.
  972. 6.4. Warning about a router's status.
  973. If a router tries to publish its descriptor to a Naming authority
  974. that has its nickname mapped to another key, the router SHOULD
  975. warn the operator that it is either using the wrong key or is using
  976. an already claimed nickname.
  977. If a router has fetched a consensus document,, and the
  978. authorities do not publish a binding for the router's nickname, the
  979. router MAY remind the operator that the chosen nickname is not
  980. bound to this key at the authorities, and suggest contacting the
  981. authority operators.
  982. ...
  983. 6.5. Router protocol versions
  984. A client should believe that a router supports a given feature if that
  985. feature is supported by the router or protocol versions in more than half
  986. of the live networkstatus's "v" entries for that router. In other words,
  987. if the "v" entries for some router are:
  988. v Tor 0.0.8pre1 (from authority 1)
  989. v Tor 0.1.2.11 (from authority 2)
  990. v FutureProtocolDescription 99 (from authority 3)
  991. then the client should believe that the router supports any feature
  992. supported by 0.1.2.11.
  993. This is currently equivalent to believing the median declared version for
  994. a router in all live networkstatuses.
  995. 7. Standards compliance
  996. All clients and servers MUST support HTTP 1.0. Clients and servers MAY
  997. support later versions of HTTP as well.
  998. 7.1. HTTP headers
  999. Servers MAY set the Content-Length: header. Servers SHOULD set
  1000. Content-Encoding to "deflate" or "identity".
  1001. Servers MAY include an X-Your-Address-Is: header, whose value is the
  1002. apparent IP address of the client connecting to them (as a dotted quad).
  1003. For directory connections tunneled over a BEGIN_DIR stream, servers SHOULD
  1004. report the IP from which the circuit carrying the BEGIN_DIR stream reached
  1005. them. [Servers before version 0.1.2.5-alpha reported 127.0.0.1 for all
  1006. BEGIN_DIR-tunneled connections.]
  1007. Servers SHOULD disable caching of multiple network statuses or multiple
  1008. router descriptors. Servers MAY enable caching of single descriptors,
  1009. single network statuses, the list of all router descriptors, a v1
  1010. directory, or a v1 running routers document. XXX mention times.
  1011. 7.2. HTTP status codes
  1012. XXX We should write down what return codes dirservers send in what situations.
  1013. 9. Backward compatibility and migration plans
  1014. Until Tor versions before 0.1.1.x are completely obsolete, directory
  1015. authorities should generate, and mirrors should download and cache, v1
  1016. directories and running-routers lists, and allow old clients to download
  1017. them. These documents and the rules for retrieving, serving, and caching
  1018. them are described in dir-spec-v1.txt.
  1019. Until Tor versions before 0.2.0.x are completely obsolete, directory
  1020. authorities should generate, mirrors should download and cache, v2
  1021. network-status documents, and allow old clients to download them.
  1022. Additionally, all directory servers and caches should download, store, and
  1023. serve any router descriptor that is required because of v2 network-status
  1024. documents. These documents and the rules for retrieving, serving, and
  1025. caching them are described in dir-spec-v1.txt.
  1026. A. Consensus-negotiation timeline.
  1027. Period begins: this is the Published time.
  1028. Everybody sends votes
  1029. Reconciliation: everybody tries to fetch missing votes.
  1030. consensus may exist at this point.
  1031. End of voting period:
  1032. everyone swaps signatures.
  1033. Now it's okay for caches to download
  1034. Now it's okay for clients to download.
  1035. Valid-after/valid-until switchover