dir-spec.txt 58 KB

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