dir-spec.txt 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
  1. Tor directory protocol, version 3
  2. 0. Scope and preliminaries
  3. This directory protocol is used by Tor version 0.2.0.x-alpha and later.
  4. See dir-spec-v1.txt for information on the protocol used up to the
  5. 0.1.0.x series, and dir-spec-v2.txt for information on the protocol
  6. used by the 0.1.1.x and 0.1.2.x series.
  7. Caches and authorities must still support older versions of the
  8. directory protocols, until the versions of Tor that require them are
  9. finally out of commission. See Section XXXX on backward compatibility.
  10. This document merges and supersedes the following proposals:
  11. 101 Voting on the Tor Directory System
  12. 103 Splitting identity key from regularly used signing key
  13. 104 Long and Short Router Descriptors
  14. AS OF 14 JUNE 2007, THIS SPECIFICATION HAS NOT YET BEEN COMPLETELY
  15. IMPLEMENTED, OR COMPLETELY COMPLETED.
  16. XXX when to download certificates.
  17. XXX timeline
  18. XXX fill in XXXXs
  19. 0.1. History
  20. The earliest versions of Onion Routing shipped with a list of known
  21. routers and their keys. When the set of routers changed, users needed to
  22. fetch a new list.
  23. The Version 1 Directory protocol
  24. --------------------------------
  25. Early versions of Tor (0.0.2) introduced "Directory authorities": servers
  26. that served signed "directory" documents containing a list of signed
  27. "router descriptors", along with short summary of the status of each
  28. router. Thus, clients could get up-to-date information on the state of
  29. the network automatically, and be certain that the list they were getting
  30. was attested by a trusted directory authority.
  31. Later versions (0.0.8) added directory caches, which download
  32. directories from the authorities and serve them to clients. Non-caches
  33. fetch from the caches in preference to fetching from the authorities, thus
  34. distributing bandwidth requirements.
  35. Also added during the version 1 directory protocol were "router status"
  36. documents: short documents that listed only the up/down status of the
  37. routers on the network, rather than a complete list of all the
  38. descriptors. Clients and caches would fetch these documents far more
  39. frequently than they would fetch full directories.
  40. The Version 2 Directory Protocol
  41. --------------------------------
  42. During the Tor 0.1.1.x series, Tor revised its handling of directory
  43. documents in order to address two major problems:
  44. * Directories had grown quite large (over 1MB), and most directory
  45. downloads consisted mainly of router descriptors that clients
  46. already had.
  47. * Every directory authority was a trust bottleneck: if a single
  48. directory authority lied, it could make clients believe for a time
  49. an arbitrarily distorted view of the Tor network. (Clients
  50. trusted the most recent signed document they downloaded.) Thus,
  51. adding more authorities would make the system less secure, not
  52. more.
  53. To address these, we extended the directory protocol so that
  54. authorities now published signed "network status" documents. Each
  55. network status listed, for every router in the network: a hash of its
  56. identity key, a hash of its most recent descriptor, and a summary of
  57. what the authority believed about its status. Clients would download
  58. the authorities' network status documents in turn, and believe
  59. statements about routers iff they were attested to by more than half of
  60. the authorities.
  61. Instead of downloading all router descriptors at once, clients
  62. downloaded only the descriptors that they did not have. Descriptors
  63. were indexed by their digests, in order to prevent malicious caches
  64. from giving different versions of a router descriptor to different
  65. clients.
  66. Routers began working harder to upload new descriptors only when their
  67. contents were substantially changed.
  68. 0.2. Goals of the version 3 protocol
  69. Version 3 of the Tor directory protocol tries to solve the following
  70. issues:
  71. * A great deal of bandwidth used to transmit router descriptors was
  72. used by two fields that are not actually used by Tor routers
  73. (namely read-history and write-history). We save about 60% by
  74. moving them into a separate document that most clients do not
  75. fetch or use.
  76. * It was possible under certain perverse circumstances for clients
  77. to download an unusual set of network status documents, thus
  78. partitioning themselves from clients who have a more recent and/or
  79. typical set of documents. Even under the best of circumstances,
  80. clients were sensitive to the ages of the network status documents
  81. they downloaded. Therefore, instead of having the clients
  82. correlate multiple network status documents, we have the
  83. authorities collectively vote on a single consensus network status
  84. document.
  85. * The most sensitive data in the entire network (the identity keys
  86. of the directory authorities) needed to be stored unencrypted so
  87. that the authorities can sign network-status documents on the fly.
  88. Now, the authorities' identity keys are stored offline, and used
  89. to certify medium-term signing keys that can be rotated.
  90. 0.3. Some Remaining questions
  91. Things we could solve on a v3 timeframe:
  92. The SHA-1 hash is showing its age. We should do something about our
  93. dependency on it. We could probably future-proof ourselves here in
  94. this revision, at least so far as documents from the authorities are
  95. concerned.
  96. Too many things about the authorities are hardcoded by IP.
  97. Perhaps we should start accepting longer identity keys for routers
  98. too.
  99. Things to solve eventually:
  100. Requiring every client to know about every router won't scale forever.
  101. Requiring every directory cache to know every router won't scale
  102. forever.
  103. 1. Outline
  104. There is a small set (say, around 5-10) of semi-trusted directory
  105. authorities. A default list of authorities is shipped with the Tor
  106. software. Users can change this list, but are encouraged not to do so,
  107. in order to avoid partitioning attacks.
  108. Every authority has a very-secret, long-term "Authority Identity Key".
  109. This is stored encrypted and/or offline, and is used to sign "key
  110. certificate" documents. Every key certificate contains a medium-term
  111. (3-12 months) "authority signing key", that is used by the authority to
  112. sign other directory information. (Note that the authority identity
  113. key is distinct from the router identity key that the authority uses
  114. in its role as an ordinary router.)
  115. Routers periodically upload signed "routers descriptors" to the
  116. directory authorities describing their keys, capabilities, and other
  117. information. Routers may also upload signed "extra info documents"
  118. containing information that is not required for the Tor protocol.
  119. Directory authorities serve router descriptors indexed by router
  120. identity, or by hash of the descriptor.
  121. Routers may act as directory caches to reduce load on the directory
  122. authorities. They announce this in their descriptors.
  123. Periodically, each directory authority generates a view of
  124. the current descriptors and status for known routers. They send a
  125. signed summary of this view (a "status vote") to the other
  126. authorities. The authorities compute the result of this vote, and sign
  127. a "consensus status" document containing the result of the vote.
  128. Directory caches download, cache, and re-serve consensus documents.
  129. Clients, directory caches, and directory authorities all use consensus
  130. documents to find out when their list of routers is out-of-date.
  131. (Directory authorities also use vote statuses.) If it is, they download
  132. any missing router descriptors. Clients download missing descriptors
  133. from caches; caches and authorities download from authorities.
  134. Descriptors are downloaded by the hash of the descriptor, not by the
  135. server's identity key: this prevents servers from attacking clients by
  136. giving them descriptors nobody else uses.
  137. All directory information is uploaded and downloaded with HTTP.
  138. [Authorities also generate and caches also cache documents produced and
  139. used by earlier versions of this protocol; see section XXX for notes.]
  140. 1.1. What's different from version 2?
  141. Clients used to download multiple network status documents,
  142. corresponding roughly to "status votes" above. They would compute the
  143. result of the vote on the client side.
  144. Authorities used to sign documents using the same private keys they used
  145. for their roles as routers. This forced them to keep these extremely
  146. sensitive keys in memory unencrypted.
  147. All of the information in extra-info documents used to be kept in the
  148. main descriptors.
  149. 1.2. Document meta-format
  150. Router descriptors, directories, and running-routers documents all obey the
  151. following lightweight extensible information format.
  152. The highest level object is a Document, which consists of one or more
  153. Items. Every Item begins with a KeywordLine, followed by zero or more
  154. Objects. A KeywordLine begins with a Keyword, optionally followed by
  155. whitespace and more non-newline characters, and ends with a newline. A
  156. Keyword is a sequence of one or more characters in the set [A-Za-z0-9-].
  157. An Object is a block of encoded data in pseudo-Open-PGP-style
  158. armor. (cf. RFC 2440)
  159. More formally:
  160. NL = The ascii LF character (hex value 0x0a).
  161. Document ::= (Item | NL)+
  162. Item ::= KeywordLine Object*
  163. KeywordLine ::= Keyword NL | Keyword WS ArgumentChar+ 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 be 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. 1.4. Voting timeline
  224. Every consensus document has a "valid-after" (VA) time, a "fresh-until"
  225. (FU) time and a "valid-until" (VU) time. VA MUST precede FU, which MUST
  226. in turn precede VU. Times are chosen so that every consensus will be
  227. "fresh" until the next consensus becomes valid, and "valid" for a while
  228. after. At least 3 consensuses should be valid at any given time.
  229. The timeline for a given consensus is as follows:
  230. VA-DistSeconds-VoteSeconds: The authorities exchange votes.
  231. VA-DistSeconds-VoteSeconds/2: The authorities try to download any
  232. votes they don't have.
  233. VA-DistSeconds: The authorities calculate the consensus and exchange
  234. signatures.
  235. VA-DistSeconds/2: The authorities try to download any signatures
  236. they don't have.
  237. VA: All authorities have a multiply signed consensus.
  238. VA ... FU: Caches download the consensus. (Note that since caches have
  239. no way of telling what VA and FU are until they have downloaded
  240. the consensus, they assume that the present consensus's VA is
  241. equal to the previous one's FU, and that its FU is one interval after
  242. that.)
  243. FU: The consensus is no longer the freshest consensus.
  244. FU ... (the current consensus's VU): Clients download the consensus.
  245. (See note above: clients guess that the next consensus's FU will be
  246. two intervals after the current VA.)
  247. VU: The consensus is no longer valid.
  248. VoteSeconds and DistSeconds MUST each be at least 20 seconds; FU-VA and
  249. VU-FU MUST each be at least 5 minutes.
  250. 2. Router operation and formats
  251. ORs SHOULD generate a new router descriptor and a new extra-info
  252. document whenever any of the following events have occurred:
  253. - A period of time (18 hrs by default) has passed since the last
  254. time a descriptor was generated.
  255. - A descriptor field other than bandwidth or uptime has changed.
  256. - Bandwidth has changed by a factor of 2 from the last time a
  257. descriptor was generated, and at least a given interval of time
  258. (20 mins by default) has passed since then.
  259. - Its uptime has been reset (by restarting).
  260. [XXX this list is incomplete; see router_differences_are_cosmetic()
  261. in routerlist.c for others]
  262. ORs SHOULD NOT publish a new router descriptor or extra-info document
  263. if none of the above events have occurred and not much time has passed
  264. (12 hours by default).
  265. After generating a descriptor, ORs upload them to every directory
  266. authority they know, by posting them (in order) to the URL
  267. http://<hostname:port>/tor/
  268. 2.1. Router descriptor format
  269. Router descriptors consist of the following items. For backward
  270. compatibility, there should be an extra NL at the end of each router
  271. descriptor.
  272. In lines that take multiple arguments, extra arguments SHOULD be
  273. accepted and ignored. Many of the nonterminals below are defined in
  274. section 2.3.
  275. "router" nickname address ORPort SOCKSPort DirPort NL
  276. [At start, exactly once.]
  277. Indicates the beginning of a router descriptor. "nickname" must be a
  278. valid router nickname as specified in 2.3. "address" must be an IPv4
  279. address in dotted-quad format. The last three numbers indicate the
  280. TCP ports at which this OR exposes functionality. ORPort is a port at
  281. which this OR accepts TLS connections for the main OR protocol;
  282. SOCKSPort is deprecated and should always be 0; and DirPort is the
  283. port at which this OR accepts directory-related HTTP connections. If
  284. any port is not supported, the value 0 is given instead of a port
  285. number. (At least one of DirPort and ORPort SHOULD be set;
  286. authorities MAY reject any descriptor with both DirPort and ORPort of
  287. 0.)
  288. "bandwidth" bandwidth-avg bandwidth-burst bandwidth-observed NL
  289. [Exactly once]
  290. Estimated bandwidth for this router, in bytes per second. The
  291. "average" bandwidth is the volume per second that the OR is willing to
  292. sustain over long periods; the "burst" bandwidth is the volume that
  293. the OR is willing to sustain in very short intervals. The "observed"
  294. value is an estimate of the capacity this server can handle. The
  295. server remembers the max bandwidth sustained output over any ten
  296. second period in the past day, and another sustained input. The
  297. "observed" value is the lesser of these two numbers.
  298. "platform" string NL
  299. [At most once]
  300. A human-readable string describing the system on which this OR is
  301. running. This MAY include the operating system, and SHOULD include
  302. the name and version of the software implementing the Tor protocol.
  303. "published" YYYY-MM-DD HH:MM:SS NL
  304. [Exactly once]
  305. The time, in GMT, when this descriptor (and its corresponding
  306. extra-info document if any) was generated.
  307. "fingerprint" fingerprint NL
  308. [At most once]
  309. A fingerprint (a HASH_LEN-byte of asn1 encoded public key, encoded in
  310. hex, with a single space after every 4 characters) for this router's
  311. identity key. A descriptor is considered invalid (and MUST be
  312. rejected) if the fingerprint line does not match the public key.
  313. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should
  314. be marked with "opt" until earlier versions of Tor are obsolete.]
  315. "hibernating" bool NL
  316. [At most once]
  317. If the value is 1, then the Tor server was hibernating when the
  318. descriptor was published, and shouldn't be used to build circuits.
  319. [We didn't start parsing this line until Tor 0.1.0.6-rc; it should be
  320. marked with "opt" until earlier versions of Tor are obsolete.]
  321. "uptime" number NL
  322. [At most once]
  323. The number of seconds that this OR process has been running.
  324. "onion-key" NL a public key in PEM format
  325. [Exactly once]
  326. This key is used to encrypt EXTEND cells for this OR. The key MUST be
  327. accepted for at least 1 week after any new key is published in a
  328. subsequent descriptor. It MUST be 1024 bits.
  329. "signing-key" NL a public key in PEM format
  330. [Exactly once]
  331. The OR's long-term identity key. It MUST be 1024 bits.
  332. "accept" exitpattern NL
  333. "reject" exitpattern NL
  334. [Any number]
  335. These lines describe an "exit policy": the rules that an OR follows
  336. when deciding whether to allow a new stream to a given address. The
  337. 'exitpattern' syntax is described below. There MUST be at least one
  338. such entry. The rules are considered in order; if no rule matches,
  339. the address will be accepted. For clarity, the last such entry SHOULD
  340. be accept *:* or reject *:*.
  341. "router-signature" NL Signature NL
  342. [At end, exactly once]
  343. The "SIGNATURE" object contains a signature of the PKCS1-padded
  344. hash of the entire router descriptor, taken from the beginning of the
  345. "router" line, through the newline after the "router-signature" line.
  346. The router descriptor is invalid unless the signature is performed
  347. with the router's identity key.
  348. "contact" info NL
  349. [At most once]
  350. Describes a way to contact the server's administrator, preferably
  351. including an email address and a PGP key fingerprint.
  352. "family" names NL
  353. [At most once]
  354. 'Names' is a space-separated list of server nicknames or
  355. hexdigests. If two ORs list one another in their "family" entries,
  356. then OPs should treat them as a single OR for the purpose of path
  357. selection.
  358. For example, if node A's descriptor contains "family B", and node B's
  359. descriptor contains "family A", then node A and node B should never
  360. be used on the same circuit.
  361. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  362. [At most once]
  363. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  364. [At most once]
  365. Declare how much bandwidth the OR has used recently. Usage is divided
  366. into intervals of NSEC seconds. The YYYY-MM-DD HH:MM:SS field
  367. defines the end of the most recent interval. The numbers are the
  368. number of bytes used in the most recent intervals, ordered from
  369. oldest to newest.
  370. [We didn't start parsing these lines until Tor 0.1.0.6-rc; they should
  371. be marked with "opt" until earlier versions of Tor are obsolete.]
  372. [See also migration notes in section 2.2.1.]
  373. "eventdns" bool NL
  374. [At most once]
  375. Declare whether this version of Tor is using the newer enhanced
  376. dns logic. Versions of Tor with this field set to false SHOULD NOT
  377. be used for reverse hostname lookups.
  378. [All versions of Tor before 0.1.2.2-alpha should be assumed to have
  379. this option set to 0 if it is not present. All Tor versions at
  380. 0.1.2.2-alpha or later should be assumed to have this option set to
  381. 1 if it is not present. Until 0.1.2.1-alpha-dev, this option was
  382. not generated, even when the new DNS code was in use. Versions of Tor
  383. before 0.1.2.1-alpha-dev did not parse this option, so it should be
  384. marked "opt". The dnsworker logic has been removed, so this option
  385. should not be used by new server code. However, it can still be
  386. used, and should still be recognized by new code until Tor 0.1.2.x
  387. is obsolete.]
  388. "caches-extra-info" NL
  389. [At most once.]
  390. Present only if this router is a directory cache that provides
  391. extra-info documents.
  392. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  393. before 0.1.2.5-alpha will reject descriptors containing it unless
  394. it is prefixed with "opt"; it should be so prefixed until these
  395. versions are obsolete.]
  396. "extra-info-digest" digest NL
  397. [At most once]
  398. "Digest" is a hex-encoded digest (using upper-case characters) of the
  399. router's extra-info document, as signed in the router's extra-info
  400. (that is, not including the signature). (If this field is absent, the
  401. router is not uploading a corresponding extra-info document.)
  402. [Versions before 0.2.0.1-alpha don't recognize this, and versions
  403. before 0.1.2.5-alpha will reject descriptors containing it unless
  404. it is prefixed with "opt"; it should be so prefixed until these
  405. versions are obsolete.]
  406. "hidden-service-dir" *(SP VersionNum) NL
  407. [At most once.]
  408. Present only if this router stores and serves hidden service
  409. descriptors. If any VersionNum(s) are specified, this router
  410. supports those descriptor versions. If none are specified, it
  411. defaults to version 2 descriptors.
  412. [Versions of Tor before 0.1.2.5-alpha rejected router descriptors
  413. with unrecognized items; the protocols line should be preceded with
  414. an "opt" until these Tors are obsolete.]
  415. "protocols" SP "Link" SP LINK-VERSION-LIST SP "Circuit" SP
  416. CIRCUIT-VERSION-LIST NL
  417. [At most once.]
  418. Both lists are space-separated sequences of numbers, to indicate which
  419. protocols the server supports. As of 30 Mar 2008, specified
  420. protocols are "Link 1 2 Circuit 1". See section 4.1 of tor-spec.txt
  421. for more information about link protocol versions.
  422. [Versions of Tor before 0.1.2.5-alpha rejected router descriptors
  423. with unrecognized items; the protocols line should be preceded with
  424. an "opt" until these Tors are obsolete.]
  425. "allow-single-hop-exits"
  426. [At most once.]
  427. Present only if the router allows single-hop circuits to make exit
  428. connections. Most Tor servers do not support this: this is
  429. included for specialized controllers designed to support perspective
  430. access and such.
  431. 2.2. Extra-info documents
  432. Extra-info documents consist of the following items:
  433. "extra-info" Nickname Fingerprint NL
  434. [At start, exactly once.]
  435. Identifies what router this is an extra info descriptor for.
  436. Fingerprint is encoded in hex (using upper-case letters), with
  437. no spaces.
  438. "published"
  439. [Exactly once.]
  440. The time, in GMT, when this document (and its corresponding router
  441. descriptor if any) was generated. It MUST match the published time
  442. in the corresponding router descriptor.
  443. "read-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  444. [At most once.]
  445. "write-history" YYYY-MM-DD HH:MM:SS (NSEC s) NUM,NUM,NUM,NUM,NUM... NL
  446. [At most once.]
  447. As documented in 2.1 above. See migration notes in section 2.2.1.
  448. ("geoip-start" YYYY-MM-DD HH:MM:SS NL)
  449. ("geoip-client-origins" CC=N,CC=N,... NL)
  450. Only generated by bridge routers (see blocking.pdf), and only
  451. when they have been configured with a geoip database.
  452. Non-bridges SHOULD NOT generate these fields. Contains a list
  453. of mappings from two-letter country codes (CC) to the number
  454. of clients that have connected to that bridge from that
  455. country (approximate, and rounded up to the nearest multiple of 8
  456. in order to hamper traffic analysis). A country is included
  457. only if it has at least one address. The time in
  458. "geoip-start" is the time at which we began collecting geoip
  459. statistics.
  460. "geoip-start" and "geoip-client-origins" have been replaced by
  461. "bridge-stats-end" and "bridge-stats-ips" in 0.2.2.4-alpha. The
  462. reason is that the measurement interval with "geoip-stats" as
  463. determined by subtracting "geoip-start" from "published" could
  464. have had a variable length, whereas the measurement interval in
  465. 0.2.2.4-alpha and later is set to be exactly 24 hours long. In
  466. order to clearly distinguish the new measurement intervals from
  467. the old ones, the new keywords have been introduced.
  468. "bridge-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
  469. [At most once.]
  470. YYYY-MM-DD HH:MM:SS defines the end of the included measurement
  471. interval of length NSEC seconds (86400 seconds by default).
  472. A "bridge-stats-end" line, as well as any other "bridge-*" line,
  473. is only added when the relay has been running as a bridge for at
  474. least 24 hours.
  475. "bridge-ips" CC=N,CC=N,... NL
  476. [At most once.]
  477. List of mappings from two-letter country codes to the number of
  478. unique IP addresses that have connected from that country to the
  479. bridge and which are no known relays, rounded up to the nearest
  480. multiple of 8.
  481. "dirreq-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
  482. [At most once.]
  483. YYYY-MM-DD HH:MM:SS defines the end of the included measurement
  484. interval of length NSEC seconds (86400 seconds by default).
  485. A "dirreq-stats-end" line, as well as any other "dirreq-*" line,
  486. is only added when the relay has opened its Dir port and after 24
  487. hours of measuring directory requests.
  488. "dirreq-v2-ips" CC=N,CC=N,... NL
  489. [At most once.]
  490. "dirreq-v3-ips" CC=N,CC=N,... NL
  491. [At most once.]
  492. List of mappings from two-letter country codes to the number of
  493. unique IP addresses that have connected from that country to
  494. request a v2/v3 network status, rounded up to the nearest multiple
  495. of 8. Only those IP addresses are counted that the directory can
  496. answer with a 200 OK status code.
  497. "dirreq-v2-reqs" CC=N,CC=N,... NL
  498. [At most once.]
  499. "dirreq-v3-reqs" CC=N,CC=N,... NL
  500. [At most once.]
  501. List of mappings from two-letter country codes to the number of
  502. requests for v2/v3 network statuses from that country, rounded up
  503. to the nearest multiple of 8. Only those requests are counted that
  504. the directory can answer with a 200 OK status code.
  505. "dirreq-v2-share" num% NL
  506. [At most once.]
  507. "dirreq-v3-share" num% NL
  508. [At most once.]
  509. The share of v2/v3 network status requests that the directory
  510. expects to receive from clients based on its advertised bandwidth
  511. compared to the overall network bandwidth capacity. Shares are
  512. formatted in percent with two decimal places. Shares are
  513. calculated as means over the whole 24-hour interval.
  514. "dirreq-v2-resp" status=num,... NL
  515. [At most once.]
  516. "dirreq-v3-resp" status=nul,... NL
  517. [At most once.]
  518. List of mappings from response statuses to the number of requests
  519. for v2/v3 network statuses that were answered with that response
  520. status, rounded up to the nearest multiple of 4. Only response
  521. statuses with at least 1 response are reported. New response
  522. statuses can be added at any time. The current list of response
  523. statuses is as follows:
  524. "ok": a network status request is answered; this number
  525. corresponds to the sum of all requests as reported in
  526. "dirreq-v2-reqs" or "dirreq-v3-reqs", respectively, before
  527. rounding up.
  528. "not-enough-sigs: a version 3 network status is not signed by a
  529. sufficient number of requested authorities.
  530. "unavailable": a requested network status object is unavailable.
  531. "not-found": a requested network status is not found.
  532. "not-modified": a network status has not been modified since the
  533. If-Modified-Since time that is included in the request.
  534. "busy": the directory is busy.
  535. "dirreq-v2-direct-dl" key=val,... NL
  536. [At most once.]
  537. "dirreq-v3-direct-dl" key=val,... NL
  538. [At most once.]
  539. "dirreq-v2-tunneled-dl" key=val,... NL
  540. [At most once.]
  541. "dirreq-v3-tunneled-dl" key=val,... NL
  542. [At most once.]
  543. List of statistics about possible failures in the download process
  544. of v2/v3 network statuses. Requests are either "direct"
  545. HTTP-encoded requests over the relay's directory port, or
  546. "tunneled" requests using a BEGIN_DIR cell over the relay's OR
  547. port. The list of possible statistics can change, and statistics
  548. can be left out from reporting. The current list of statistics is
  549. as follows:
  550. Successful downloads and failures:
  551. "complete": a client has finished the download successfully.
  552. "timeout": a download did not finish within 10 minutes after
  553. starting to send the response.
  554. "running": a download is still running at the end of the
  555. measurement period for less than 10 minutes after starting to
  556. send the response.
  557. Download times:
  558. "min", "max": smallest and largest measured bandwidth in B/s.
  559. "d[1-4,6-9]": 1st to 4th and 6th to 9th decile of measured
  560. bandwidth in B/s. For a given decile i, i/10 of all downloads
  561. had a smaller bandwidth than di, and (10-i)/10 of all downloads
  562. had a larger bandwidth than di.
  563. "q[1,3]": 1st and 3rd quartile of measured bandwidth in B/s. One
  564. fourth of all downloads had a smaller bandwidth than q1, one
  565. fourth of all downloads had a larger bandwidth than q3, and the
  566. remaining half of all downloads had a bandwidth between q1 and
  567. q3.
  568. "md": median of measured bandwidth in B/s. Half of the downloads
  569. had a smaller bandwidth than md, the other half had a larger
  570. bandwidth than md.
  571. "entry-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
  572. [At most once.]
  573. YYYY-MM-DD HH:MM:SS defines the end of the included measurement
  574. interval of length NSEC seconds (86400 seconds by default).
  575. An "entry-stats-end" line, as well as any other "entry-*"
  576. line, is first added after the relay has been running for at least
  577. 24 hours.
  578. "entry-ips" CC=N,CC=N,... NL
  579. [At most once.]
  580. List of mappings from two-letter country codes to the number of
  581. unique IP addresses that have connected from that country to the
  582. relay and which are no known other relays, rounded up to the
  583. nearest multiple of 8.
  584. "cell-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
  585. [At most once.]
  586. YYYY-MM-DD HH:MM:SS defines the end of the included measurement
  587. interval of length NSEC seconds (86400 seconds by default).
  588. A "cell-stats-end" line, as well as any other "cell-*" line,
  589. is first added after the relay has been running for at least 24
  590. hours.
  591. "cell-processed-cells" num,...,num NL
  592. [At most once.]
  593. Mean number of processed cells per circuit, subdivided into
  594. deciles of circuits by the number of cells they have processed in
  595. descending order from loudest to quietest circuits.
  596. "cell-queued-cells" num,...,num NL
  597. [At most once.]
  598. Mean number of cells contained in queues by circuit decile. These
  599. means are calculated by 1) determining the mean number of cells in
  600. a single circuit between its creation and its termination and 2)
  601. calculating the mean for all circuits in a given decile as
  602. determined in "cell-processed-cells". Numbers have a precision of
  603. two decimal places.
  604. "cell-time-in-queue" num,...,num NL
  605. [At most once.]
  606. Mean time cells spend in circuit queues in milliseconds. Times are
  607. calculated by 1) determining the mean time cells spend in the
  608. queue of a single circuit and 2) calculating the mean for all
  609. circuits in a given decile as determined in
  610. "cell-processed-cells".
  611. "cell-circuits-per-decile" num NL
  612. [At most once.]
  613. Mean number of circuits that are included in any of the deciles,
  614. rounded up to the next integer.
  615. "exit-stats-end" YYYY-MM-DD HH:MM:SS (NSEC s) NL
  616. [At most once.]
  617. YYYY-MM-DD HH:MM:SS defines the end of the included measurement
  618. interval of length NSEC seconds (86400 seconds by default).
  619. An "exit-stats-end" line, as well as any other "exit-*" line, is
  620. first added after the relay has been running for at least 24 hours
  621. and only if the relay permits exiting (where exiting to a single
  622. port and IP address is sufficient).
  623. "exit-kibibytes-written" port=N,port=N,... NL
  624. [At most once.]
  625. "exit-kibibytes-read" port=N,port=N,... NL
  626. [At most once.]
  627. List of mappings from ports to the number of kibibytes that the
  628. relay has written to or read from exit connections to that port,
  629. rounded up to the next full kibibyte.
  630. "exit-streams-opened" port=N,port=N,... NL
  631. [At most once.]
  632. List of mappings from ports to the number of opened exit streams
  633. to that port, rounded up to the nearest multiple of 4.
  634. "router-signature" NL Signature NL
  635. [At end, exactly once.]
  636. A document signature as documented in section 1.3, using the
  637. initial item "extra-info" and the final item "router-signature",
  638. signed with the router's identity key.
  639. 2.2.1. Moving history fields to extra-info documents.
  640. Tools that want to use the read-history and write-history values SHOULD
  641. download extra-info documents as well as router descriptors. Such
  642. tools SHOULD accept history values from both sources; if they appear in
  643. both documents, the values in the extra-info documents are authoritative.
  644. New versions of Tor no longer generate router descriptors
  645. containing read-history or write-history. Tools should continue to
  646. accept read-history and write-history values in router descriptors
  647. produced by older versions of Tor until all Tor versions earlier
  648. than 0.2.0.x are obsolete.
  649. 2.3. Nonterminals in router descriptors
  650. nickname ::= between 1 and 19 alphanumeric characters ([A-Za-z0-9]),
  651. case-insensitive.
  652. hexdigest ::= a '$', followed by 40 hexadecimal characters
  653. ([A-Fa-f0-9]). [Represents a server by the digest of its identity
  654. key.]
  655. exitpattern ::= addrspec ":" portspec
  656. portspec ::= "*" | port | port "-" port
  657. port ::= an integer between 1 and 65535, inclusive.
  658. [Some implementations incorrectly generate ports with value 0.
  659. Implementations SHOULD accept this, and SHOULD NOT generate it.
  660. Connections to port 0 are never permitted.]
  661. addrspec ::= "*" | ip4spec | ip6spec
  662. ipv4spec ::= ip4 | ip4 "/" num_ip4_bits | ip4 "/" ip4mask
  663. ip4 ::= an IPv4 address in dotted-quad format
  664. ip4mask ::= an IPv4 mask in dotted-quad format
  665. num_ip4_bits ::= an integer between 0 and 32
  666. ip6spec ::= ip6 | ip6 "/" num_ip6_bits
  667. ip6 ::= an IPv6 address, surrounded by square brackets.
  668. num_ip6_bits ::= an integer between 0 and 128
  669. bool ::= "0" | "1"
  670. 3. Formats produced by directory authorities.
  671. Every authority has two keys used in this protocol: a signing key, and
  672. an authority identity key. (Authorities also have a router identity
  673. key used in their role as a router and by earlier versions of the
  674. directory protocol.) The identity key is used from time to time to
  675. sign new key certificates using new signing keys; it is very sensitive.
  676. The signing key is used to sign key certificates and status documents.
  677. There are three kinds of documents generated by directory authorities:
  678. Key certificates
  679. Status votes
  680. Status consensuses
  681. Each is discussed below.
  682. 3.1. Key certificates
  683. Key certificates consist of the following items:
  684. "dir-key-certificate-version" version NL
  685. [At start, exactly once.]
  686. Determines the version of the key certificate. MUST be "3" for
  687. the protocol described in this document. Implementations MUST
  688. reject formats they don't understand.
  689. "dir-address" IPPort NL
  690. [At most once]
  691. An IP:Port for this authority's directory port.
  692. "fingerprint" fingerprint NL
  693. [Exactly once.]
  694. Hexadecimal encoding without spaces based on the authority's
  695. identity key.
  696. "dir-identity-key" NL a public key in PEM format
  697. [Exactly once.]
  698. The long-term authority identity key for this authority. This key
  699. SHOULD be at least 2048 bits long; it MUST NOT be shorter than
  700. 1024 bits.
  701. "dir-key-published" YYYY-MM-DD HH:MM:SS NL
  702. [Exactly once.]
  703. The time (in GMT) when this document and corresponding key were
  704. last generated.
  705. "dir-key-expires" YYYY-MM-DD HH:MM:SS NL
  706. [Exactly once.]
  707. A time (in GMT) after which this key is no longer valid.
  708. "dir-signing-key" NL a key in PEM format
  709. [Exactly once.]
  710. The directory server's public signing key. This key MUST be at
  711. least 1024 bits, and MAY be longer.
  712. "dir-key-crosscert" NL CrossSignature NL
  713. [At most once.]
  714. NOTE: Authorities MUST include this field in all newly generated
  715. certificates. A future version of this specification will make
  716. the field required.
  717. CrossSignature is a signature, made using the certificate's signing
  718. key, of the digest of the PKCS1-padded hash of the certificate's
  719. identity key. For backward compatibility with broken versions of the
  720. parser, we wrap the base64-encoded signature in -----BEGIN ID
  721. SIGNATURE---- and -----END ID SIGNATURE----- tags. Implementations
  722. MUST allow the "ID " portion to be omitted, however.
  723. When encountering a certificate with a dir-key-crosscert entry,
  724. implementations MUST verify that the signature is a correct signature
  725. of the hash of the identity key using the signing key.
  726. "dir-key-certification" NL Signature NL
  727. [At end, exactly once.]
  728. A document signature as documented in section 1.3, using the
  729. initial item "dir-key-certificate-version" and the final item
  730. "dir-key-certification", signed with the authority identity key.
  731. Authorities MUST generate a new signing key and corresponding
  732. certificate before the key expires.
  733. 3.2. Vote and consensus status documents
  734. Votes and consensuses are more strictly formatted then other documents
  735. in this specification, since different authorities must be able to
  736. generate exactly the same consensus given the same set of votes.
  737. The procedure for deciding when to generate vote and consensus status
  738. documents are described in section XXX below.
  739. Status documents contain a preamble, an authority section, a list of
  740. router status entries, and one or more footer signature, in that order.
  741. Unlike other formats described above, a SP in these documents must be a
  742. single space character (hex 20).
  743. Some items appear only in votes, and some items appear only in
  744. consensuses. Unless specified, items occur in both.
  745. The preamble contains the following items. They MUST occur in the
  746. order given here:
  747. "network-status-version" SP version NL.
  748. [At start, exactly once.]
  749. A document format version. For this specification, the version is
  750. "3".
  751. "vote-status" SP type NL
  752. [Exactly once.]
  753. The status MUST be "vote" or "consensus", depending on the type of
  754. the document.
  755. "consensus-methods" SP IntegerList NL
  756. [Exactly once for votes; does not occur in consensuses.]
  757. A space-separated list of supported methods for generating
  758. consensuses from votes. See section 3.4.1 for details. Method "1"
  759. MUST be included.
  760. "consensus-method" SP Integer NL
  761. [Exactly once for consensuses; does not occur in votes.]
  762. See section 3.4.1 for details.
  763. (Only included when the vote is generated with consensus-method 2 or
  764. later.)
  765. "published" SP YYYY-MM-DD SP HH:MM:SS NL
  766. [Exactly once for votes; does not occur in consensuses.]
  767. The publication time for this status document (if a vote).
  768. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  769. [Exactly once.]
  770. The start of the Interval for this vote. Before this time, the
  771. consensus document produced from this vote should not be used.
  772. See 1.4 for voting timeline information.
  773. "fresh-until" SP YYYY-MM-DD SP HH:MM:SS NL
  774. [Exactly once.]
  775. The time at which the next consensus should be produced; before this
  776. time, there is no point in downloading another consensus, since there
  777. won't be a new one. See 1.4 for voting timeline information.
  778. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  779. [Exactly once.]
  780. The end of the Interval for this vote. After this time, the
  781. consensus produced by this vote should not be used. See 1.4 for
  782. voting timeline information.
  783. "voting-delay" SP VoteSeconds SP DistSeconds NL
  784. [Exactly once.]
  785. VoteSeconds is the number of seconds that we will allow to collect
  786. votes from all authorities; DistSeconds is the number of seconds
  787. we'll allow to collect signatures from all authorities. See 1.4 for
  788. voting timeline information.
  789. "client-versions" SP VersionList NL
  790. [At most once.]
  791. A comma-separated list of recommended client versions, in
  792. ascending order. If absent, no opinion is held about client
  793. versions.
  794. "server-versions" SP VersionList NL
  795. [At most once.]
  796. A comma-separated list of recommended server versions, in
  797. ascending order. If absent, no opinion is held about server
  798. versions.
  799. "known-flags" SP FlagList NL
  800. [Exactly once.]
  801. A space-separated list of all of the flags that this document
  802. might contain. A flag is "known" either because the authority
  803. knows about them and might set them (if in a vote), or because
  804. enough votes were counted for the consensus for an authoritative
  805. opinion to have been formed about their status.
  806. "params" SP [Parameters] NL
  807. [At most once]
  808. Parameter ::= Keyword '=' Int32
  809. Int32 ::= A decimal integer between -2147483648 and 2147483647.
  810. Parameters ::= Parameter | Parameters SP Parameter
  811. The parameters list, if present, contains a space-separated list of
  812. key-value pairs, sorted in lexical order by their keyword. Each
  813. parameter has its own meaning.
  814. (Only included when the vote is generated with consensus-method 7 or
  815. later.)
  816. Commonly used "param" arguments at this point include:
  817. "CircWindow" -- the default package window that circuits should
  818. be established with. It started out at 1000 cells, but some
  819. research indicates that a lower value would mean fewer cells in
  820. transit in the network at any given time. Obeyed by Tor 0.2.1.20
  821. and later.
  822. "CircPriorityHalflifeMsec" -- the halflife parameter used when
  823. weighting which circuit will send the next cell. Obeyed by Tor
  824. 0.2.2.7-alpha and later.
  825. The authority section of a vote contains the following items, followed
  826. in turn by the authority's current key certificate:
  827. "dir-source" SP nickname SP identity SP address SP IP SP dirport SP
  828. orport NL
  829. [Exactly once, at start]
  830. Describes this authority. The nickname is a convenient identifier
  831. for the authority. The identity is an uppercase hex fingerprint of
  832. the authority's current (v3 authority) identity key. The address is
  833. the server's hostname. The IP is the server's current IP address,
  834. and dirport is its current directory port. XXXXorport
  835. "contact" SP string NL
  836. [At most once.]
  837. An arbitrary string describing how to contact the directory
  838. server's administrator. Administrators should include at least an
  839. email address and a PGP fingerprint.
  840. "legacy-key" SP FINGERPRINT NL
  841. [At most once]
  842. Lists a fingerprint for an obsolete _identity_ key still used
  843. by this authority to keep older clients working. This option
  844. is used to keep key around for a little while in case the
  845. authorities need to migrate many identity keys at once.
  846. (Generally, this would only happen because of a security
  847. vulnerability that affected multiple authorities, like the
  848. Debian OpenSSL RNG bug of May 2008.)
  849. The authority section of a consensus contains groups the following items,
  850. in the order given, with one group for each authority that contributed to
  851. the consensus, with groups sorted by authority identity digest:
  852. "dir-source" SP nickname SP identity SP address SP IP SP dirport SP
  853. orport NL
  854. [Exactly once, at start]
  855. As in the authority section of a vote.
  856. "contact" SP string NL
  857. [At most once.]
  858. As in the authority section of a vote.
  859. "vote-digest" SP digest NL
  860. [Exactly once.]
  861. A digest of the vote from the authority that contributed to this
  862. consensus, as signed (that is, not including the signature).
  863. (Hex, upper-case.)
  864. Each router status entry contains the following items. Router status
  865. entries are sorted in ascending order by identity digest.
  866. "r" SP nickname SP identity SP digest SP publication SP IP SP ORPort
  867. SP DirPort NL
  868. [At start, exactly once.]
  869. "Nickname" is the OR's nickname. "Identity" is a hash of its
  870. identity key, encoded in base64, with trailing equals sign(s)
  871. removed. "Digest" is a hash of its most recent descriptor as
  872. signed (that is, not including the signature), encoded in base64.
  873. "Publication" is the
  874. publication time of its most recent descriptor, in the form
  875. YYYY-MM-DD HH:MM:SS, in GMT. "IP" is its current IP address;
  876. ORPort is its current OR port, "DirPort" is it's current directory
  877. port, or "0" for "none".
  878. "s" SP Flags NL
  879. [At most once.]
  880. A series of space-separated status flags, in alphabetical order.
  881. Currently documented flags are:
  882. "Authority" if the router is a directory authority.
  883. "BadExit" if the router is believed to be useless as an exit node
  884. (because its ISP censors it, because it is behind a restrictive
  885. proxy, or for some similar reason).
  886. "BadDirectory" if the router is believed to be useless as a
  887. directory cache (because its directory port isn't working,
  888. its bandwidth is always throttled, or for some similar
  889. reason).
  890. "Exit" if the router is more useful for building
  891. general-purpose exit circuits than for relay circuits. The
  892. path building algorithm uses this flag; see path-spec.txt.
  893. "Fast" if the router is suitable for high-bandwidth circuits.
  894. "Guard" if the router is suitable for use as an entry guard.
  895. "HSDir" if the router is considered a v2 hidden service directory.
  896. "Named" if the router's identity-nickname mapping is canonical,
  897. and this authority binds names.
  898. "Stable" if the router is suitable for long-lived circuits.
  899. "Running" if the router is currently usable.
  900. "Unnamed" if another router has bound the name used by this
  901. router, and this authority binds names.
  902. "Valid" if the router has been 'validated'.
  903. "V2Dir" if the router implements the v2 directory protocol.
  904. "V3Dir" if the router implements this protocol.
  905. "v" SP version NL
  906. [At most once.]
  907. The version of the Tor protocol that this server is running. If
  908. the value begins with "Tor" SP, the rest of the string is a Tor
  909. version number, and the protocol is "The Tor protocol as supported
  910. by the given version of Tor." Otherwise, if the value begins with
  911. some other string, Tor has upgraded to a more sophisticated
  912. protocol versioning system, and the protocol is "a version of the
  913. Tor protocol more recent than any we recognize."
  914. Directory authorities SHOULD omit version strings they receive from
  915. descriptors if they would cause "v" lines to be over 128 characters
  916. long.
  917. "w" SP "Bandwidth=" INT [SP "Measured=" INT] NL
  918. [At most once.]
  919. An estimate of the bandwidth of this server, in an arbitrary
  920. unit (currently kilobytes per second). Used to weight router
  921. selection.
  922. Additionally, the Measured= keyword is present in votes by
  923. participating bandwidth measurement authorities to indicate
  924. a measured bandwidth currently produced by measuring stream
  925. capacities.
  926. Other weighting keywords may be added later.
  927. Clients MUST ignore keywords they do not recognize.
  928. "p" SP ("accept" / "reject") SP PortList NL
  929. [At most once.]
  930. PortList = PortOrRange
  931. PortList = PortList "," PortOrRange
  932. PortOrRange = INT "-" INT / INT
  933. A list of those ports that this router supports (if 'accept')
  934. or does not support (if 'reject') for exit to "most
  935. addresses".
  936. The signature section contains the following item, which appears
  937. Exactly Once for a vote, and At Least Once for a consensus.
  938. "directory-signature" SP identity SP signing-key-digest NL Signature
  939. This is a signature of the status document, with the initial item
  940. "network-status-version", and the signature item
  941. "directory-signature", using the signing key. (In this case, we take
  942. the hash through the _space_ after directory-signature, not the
  943. newline: this ensures that all authorities sign the same thing.)
  944. "identity" is the hex-encoded digest of the authority identity key of
  945. the signing authority, and "signing-key-digest" is the hex-encoded
  946. digest of the current authority signing key of the signing authority.
  947. 3.3. Deciding how to vote.
  948. (This section describes how directory authorities choose which status
  949. flags to apply to routers, as of Tor 0.2.0.0-alpha-dev. Later directory
  950. authorities MAY do things differently, so long as clients keep working
  951. well. Clients MUST NOT depend on the exact behaviors in this section.)
  952. In the below definitions, a router is considered "active" if it is
  953. running, valid, and not hibernating.
  954. "Valid" -- a router is 'Valid' if it is running a version of Tor not
  955. known to be broken, and the directory authority has not blacklisted
  956. it as suspicious.
  957. "Named" -- Directory authority administrators may decide to support name
  958. binding. If they do, then they must maintain a file of
  959. nickname-to-identity-key mappings, and try to keep this file consistent
  960. with other directory authorities. If they don't, they act as clients, and
  961. report bindings made by other directory authorities (name X is bound to
  962. identity Y if at least one binding directory lists it, and no directory
  963. binds X to some other Y'.) A router is called 'Named' if the router
  964. believes the given name should be bound to the given key.
  965. Two strategies exist on the current network for deciding on
  966. values for the Named flag. In the original version, server
  967. operators were asked to send nickname-identity pairs to a
  968. mailing list of Naming directory authorities operators. The
  969. operators were then supposed to add the pairs to their
  970. mapping files; in practice, they didn't get to this often.
  971. Newer Naming authorities run a script that registers routers
  972. in their mapping files once the routers have been online at
  973. least two weeks, no other router has that nickname, and no
  974. other router has wanted the nickname for a month. If a router
  975. has not been online for six months, the router is removed.
  976. "Unnamed" -- Directory authorities that support naming should vote for a
  977. router to be 'Unnamed' if its given nickname is mapped to a different
  978. identity.
  979. "Running" -- A router is 'Running' if the authority managed to connect to
  980. it successfully within the last 30 minutes.
  981. "Stable" -- A router is 'Stable' if it is active, and either its Weighted
  982. MTBF is at least the median for known active routers or its Weighted MTBF
  983. corresponds to at least 7 days. Routers are never called Stable if they are
  984. running a version of Tor known to drop circuits stupidly. (0.1.1.10-alpha
  985. through 0.1.1.16-rc are stupid this way.)
  986. To calculate weighted MTBF, compute the weighted mean of the lengths
  987. of all intervals when the router was observed to be up, weighting
  988. intervals by $\alpha^n$, where $n$ is the amount of time that has
  989. passed since the interval ended, and $\alpha$ is chosen so that
  990. measurements over approximately one month old no longer influence the
  991. weighted MTBF much.
  992. [XXXX what happens when we have less than 4 days of MTBF info.]
  993. "Exit" -- A router is called an 'Exit' iff it allows exits to at
  994. least two of the ports 80, 443, and 6667 and allows exits to at
  995. least one /8 address space.
  996. "Fast" -- A router is 'Fast' if it is active, and its bandwidth is
  997. either in the top 7/8ths for known active routers or at least 20KB/s.
  998. "Guard" -- A router is a possible 'Guard' if its Weighted Fractional
  999. Uptime is at least the median for "familiar" active routers, and if
  1000. its bandwidth is at least median or at least 250KB/s.
  1001. If the total bandwidth of active non-BadExit Exit servers is less
  1002. than one third of the total bandwidth of all active servers, no Exit is
  1003. listed as a Guard.
  1004. To calculate weighted fractional uptime, compute the fraction
  1005. of time that the router is up in any given day, weighting so that
  1006. downtime and uptime in the past counts less.
  1007. A node is 'familiar' if 1/8 of all active nodes have appeared more
  1008. recently than it, OR it has been around for a few weeks.
  1009. "Authority" -- A router is called an 'Authority' if the authority
  1010. generating the network-status document believes it is an authority.
  1011. "V2Dir" -- A router supports the v2 directory protocol if it has an open
  1012. directory port, and it is running a version of the directory protocol that
  1013. supports the functionality clients need. (Currently, this is
  1014. 0.1.1.9-alpha or later.)
  1015. "V3Dir" -- A router supports the v3 directory protocol if it has an open
  1016. directory port, and it is running a version of the directory protocol that
  1017. supports the functionality clients need. (Currently, this is
  1018. 0.2.0.?????-alpha or later.)
  1019. "HSDir" -- A router is a v2 hidden service directory if it stores and
  1020. serves v2 hidden service descriptors and the authority managed to connect
  1021. to it successfully within the last 24 hours.
  1022. Directory server administrators may label some servers or IPs as
  1023. blacklisted, and elect not to include them in their network-status lists.
  1024. Authorities SHOULD 'disable' any servers in excess of 3 on any single IP.
  1025. When there are more than 3 to choose from, authorities should first prefer
  1026. authorities to non-authorities, then prefer Running to non-Running, and
  1027. then prefer high-bandwidth to low-bandwidth. To 'disable' a server, the
  1028. authority *should* advertise it without the Running or Valid flag.
  1029. Thus, the network-status vote includes all non-blacklisted,
  1030. non-expired, non-superseded descriptors.
  1031. The bandwidth in a "w" line should be taken as the best estimate
  1032. of the router's actual capacity that the authority has. For now,
  1033. this should be the lesser of the observed bandwidth and bandwidth
  1034. rate limit from the router descriptor. It is given in kilobytes
  1035. per second, and capped at some arbitrary value (currently 10 MB/s).
  1036. The Measured= keyword on a "w" line vote is currently computed
  1037. by multiplying the previous published consensus bandwidth by the
  1038. ratio of the measured average node stream capacity to the network
  1039. average. If 3 or more authorities provide a Measured= keyword for
  1040. a router, the authorities produce a consensus containing a "w"
  1041. Bandwidth= keyword equal to the median of the Measured= votes.
  1042. The ports listed in a "p" line should be taken as those ports for
  1043. which the router's exit policy permits 'most' addresses, ignoring any
  1044. accept not for all addresses, ignoring all rejects for private
  1045. netblocks. "Most" addresses are permitted if no more than 2^25
  1046. IPv4 addresses (two /8 networks) were blocked. The list is encoded
  1047. as described in 3.4.2.
  1048. 3.4. Computing a consensus from a set of votes
  1049. Given a set of votes, authorities compute the contents of the consensus
  1050. document as follows:
  1051. The "valid-after", "valid-until", and "fresh-until" times are taken as
  1052. the median of the respective values from all the votes.
  1053. The times in the "voting-delay" line are taken as the median of the
  1054. VoteSeconds and DistSeconds times in the votes.
  1055. Known-flags is the union of all flags known by any voter.
  1056. Entries are given on the "params" line for every keyword on which any
  1057. authority voted. The values given are the low-median of all votes on
  1058. that keyword.
  1059. "client-versions" and "server-versions" are sorted in ascending
  1060. order; A version is recommended in the consensus if it is recommended
  1061. by more than half of the voting authorities that included a
  1062. client-versions or server-versions lines in their votes.
  1063. The authority item groups (dir-source, contact, fingerprint,
  1064. vote-digest) are taken from the votes of the voting
  1065. authorities. These groups are sorted by the digests of the
  1066. authorities identity keys, in ascending order. If the consensus
  1067. method is 3 or later, a dir-source line must be included for
  1068. every vote with legacy-key entry, using the legacy-key's
  1069. fingerprint, the voter's ordinary nickname with the string
  1070. "-legacy" appended, and all other fields as from the original
  1071. vote's dir-source line.
  1072. A router status entry:
  1073. * is included in the result if some router status entry with the same
  1074. identity is included by more than half of the authorities (total
  1075. authorities, not just those whose votes we have).
  1076. * For any given identity, we include at most one router status entry.
  1077. * A router entry has a flag set if that is included by more than half
  1078. of the authorities who care about that flag.
  1079. * Two router entries are "the same" if they have the same
  1080. <descriptor digest, published time, nickname, IP, ports> tuple.
  1081. We choose the tuple for a given router as whichever tuple appears
  1082. for that router in the most votes. We break ties first in favor of
  1083. the more recently published, then in favor of smaller server
  1084. descriptor digest.
  1085. * The Named flag appears if it is included for this routerstatus by
  1086. _any_ authority, and if all authorities that list it list the same
  1087. nickname. However, if consensus-method 2 or later is in use, and
  1088. any authority calls this identity/nickname pair Unnamed, then
  1089. this routerstatus does not get the Named flag.
  1090. * If consensus-method 2 or later is in use, the Unnamed flag is
  1091. set for a routerstatus if any authorities have voted for a different
  1092. identities to be Named with that nickname, or if any authority
  1093. lists that nickname/ID pair as Unnamed.
  1094. (With consensus-method 1, Unnamed is set like any other flag.)
  1095. * The version is given as whichever version is listed by the most
  1096. voters, with ties decided in favor of more recent versions.
  1097. * If consensus-method 4 or later is in use, then routers that
  1098. do not have the Running flag are not listed at all.
  1099. * If consensus-method 5 or later is in use, then the "w" line
  1100. is generated using a low-median of the bandwidth values from
  1101. the votes that included "w" lines for this router.
  1102. * If consensus-method 5 or later is in use, then the "p" line
  1103. is taken from the votes that have the same policy summary
  1104. for the descriptor we are listing. (They should all be the
  1105. same. If they are not, we pick the most commonly listed
  1106. one, breaking ties in favor of the lexicographically larger
  1107. vote.) The port list is encoded as specified in 3.4.2.
  1108. * If consensus-method 6 or later is in use and if 3 or more
  1109. authorities provide a Measured= keyword in their votes for
  1110. a router, the authorities produce a consensus containing a
  1111. Bandwidth= keyword equal to the median of the Measured= votes.
  1112. * If consensus-method 7 or later is in use, the params line is
  1113. included in the output.
  1114. The signatures at the end of a consensus document are sorted in
  1115. ascending order by identity digest.
  1116. All ties in computing medians are broken in favor of the smaller or
  1117. earlier item.
  1118. 3.4.1. Forward compatibility
  1119. Future versions of Tor will need to include new information in the
  1120. consensus documents, but it is important that all authorities (or at least
  1121. half) generate and sign the same signed consensus.
  1122. To achieve this, authorities list in their votes their supported methods
  1123. for generating consensuses from votes. Later methods will be assigned
  1124. higher numbers. Currently recognized methods:
  1125. "1" -- The first implemented version.
  1126. "2" -- Added support for the Unnamed flag.
  1127. "3" -- Added legacy ID key support to aid in authority ID key rollovers
  1128. "4" -- No longer list routers that are not running in the consensus
  1129. "5" -- adds support for "w" and "p" lines.
  1130. "6" -- Prefers measured bandwidth values rather than advertised
  1131. Before generating a consensus, an authority must decide which consensus
  1132. method to use. To do this, it looks for the highest version number
  1133. supported by more than 2/3 of the authorities voting. If it supports this
  1134. method, then it uses it. Otherwise, it falls back to method 1.
  1135. (The consensuses generated by new methods must be parsable by
  1136. implementations that only understand the old methods, and must not cause
  1137. those implementations to compromise their anonymity. This is a means for
  1138. making changes in the contents of consensus; not for making
  1139. backward-incompatible changes in their format.)
  1140. 3.4.2. Encoding port lists
  1141. Whether the summary shows the list of accepted ports or the list of
  1142. rejected ports depends on which list is shorter (has a shorter string
  1143. representation). In case of ties we choose the list of accepted
  1144. ports. As an exception to this rule an allow-all policy is
  1145. represented as "accept 1-65535" instead of "reject " and a reject-all
  1146. policy is similarly given as "reject 1-65535".
  1147. Summary items are compressed, that is instead of "80-88,89-100" there
  1148. only is a single item of "80-100", similarly instead of "20,21" a
  1149. summary will say "20-21".
  1150. Port lists are sorted in ascending order.
  1151. The maximum allowed length of a policy summary (including the "accept "
  1152. or "reject ") is 1000 characters. If a summary exceeds that length we
  1153. use an accept-style summary and list as much of the port list as is
  1154. possible within these 1000 bytes. [XXXX be more specific.]
  1155. 3.5. Detached signatures
  1156. Assuming full connectivity, every authority should compute and sign the
  1157. same consensus directory in each period. Therefore, it isn't necessary to
  1158. download the consensus computed by each authority; instead, the
  1159. authorities only push/fetch each others' signatures. A "detached
  1160. signature" document contains items as follows:
  1161. "consensus-digest" SP Digest NL
  1162. [At start, at most once.]
  1163. The digest of the consensus being signed.
  1164. "valid-after" SP YYYY-MM-DD SP HH:MM:SS NL
  1165. "fresh-until" SP YYYY-MM-DD SP HH:MM:SS NL
  1166. "valid-until" SP YYYY-MM-DD SP HH:MM:SS NL
  1167. [As in the consensus]
  1168. "directory-signature"
  1169. [As in the consensus; the signature object is the same as in the
  1170. consensus document.]
  1171. 4. Directory server operation
  1172. All directory authorities and directory caches ("directory servers")
  1173. implement this section, except as noted.
  1174. 4.1. Accepting uploads (authorities only)
  1175. When a router posts a signed descriptor to a directory authority, the
  1176. authority first checks whether it is well-formed and correctly
  1177. self-signed. If it is, the authority next verifies that the nickname
  1178. in question is not already assigned to a router with a different
  1179. public key.
  1180. Finally, the authority MAY check that the router is not blacklisted
  1181. because of its key, IP, or another reason.
  1182. If the descriptor passes these tests, and the authority does not already
  1183. have a descriptor for a router with this public key, it accepts the
  1184. descriptor and remembers it.
  1185. If the authority _does_ have a descriptor with the same public key, the
  1186. newly uploaded descriptor is remembered if its publication time is more
  1187. recent than the most recent old descriptor for that router, and either:
  1188. - There are non-cosmetic differences between the old descriptor and the
  1189. new one.
  1190. - Enough time has passed between the descriptors' publication times.
  1191. (Currently, 12 hours.)
  1192. Differences between router descriptors are "non-cosmetic" if they would be
  1193. sufficient to force an upload as described in section 2 above.
  1194. Note that the "cosmetic difference" test only applies to uploaded
  1195. descriptors, not to descriptors that the authority downloads from other
  1196. authorities.
  1197. When a router posts a signed extra-info document to a directory authority,
  1198. the authority again checks it for well-formedness and correct signature,
  1199. and checks that its matches the extra-info-digest in some router
  1200. descriptor that it believes is currently useful. If so, it accepts it and
  1201. stores it and serves it as requested. If not, it drops it.
  1202. 4.2. Voting (authorities only)
  1203. Authorities divide time into Intervals. Authority administrators SHOULD
  1204. try to all pick the same interval length, and SHOULD pick intervals that
  1205. are commonly used divisions of time (e.g., 5 minutes, 15 minutes, 30
  1206. minutes, 60 minutes, 90 minutes). Voting intervals SHOULD be chosen to
  1207. divide evenly into a 24-hour day.
  1208. Authorities SHOULD act according to interval and delays in the
  1209. latest consensus. Lacking a latest consensus, they SHOULD default to a
  1210. 30-minute Interval, a 5 minute VotingDelay, and a 5 minute DistDelay.
  1211. Authorities MUST take pains to ensure that their clocks remain accurate
  1212. within a few seconds. (Running NTP is usually sufficient.)
  1213. The first voting period of each day begins at 00:00 (midnight) GMT. If
  1214. the last period of the day would be truncated by one-half or more, it is
  1215. merged with the second-to-last period.
  1216. An authority SHOULD publish its vote immediately at the start of each voting
  1217. period (minus VoteSeconds+DistSeconds). It does this by making it
  1218. available at
  1219. http://<hostname>/tor/status-vote/next/authority.z
  1220. and sending it in an HTTP POST request to each other authority at the URL
  1221. http://<hostname>/tor/post/vote
  1222. If, at the start of the voting period, minus DistSeconds, an authority
  1223. does not have a current statement from another authority, the first
  1224. authority downloads the other's statement.
  1225. Once an authority has a vote from another authority, it makes it available
  1226. at
  1227. http://<hostname>/tor/status-vote/next/<fp>.z
  1228. where <fp> is the fingerprint of the other authority's identity key.
  1229. And at
  1230. http://<hostname>/tor/status-vote/next/d/<d>.z
  1231. where <d> is the digest of the vote document.
  1232. The consensus status, along with as many signatures as the server
  1233. currently knows, should be available at
  1234. http://<hostname>/tor/status-vote/next/consensus.z
  1235. All of the detached signatures it knows for consensus status should be
  1236. available at:
  1237. http://<hostname>/tor/status-vote/next/consensus-signatures.z
  1238. Once there are enough signatures, or once the voting period starts,
  1239. these documents are available at
  1240. http://<hostname>/tor/status-vote/current/consensus.z
  1241. and
  1242. http://<hostname>/tor/status-vote/current/consensus-signatures.z
  1243. [XXX current/consensus-signatures is not currently implemented, as it
  1244. is not used in the voting protocol.]
  1245. The other vote documents are analogously made available under
  1246. http://<hostname>/tor/status-vote/current/authority.z
  1247. http://<hostname>/tor/status-vote/current/<fp>.z
  1248. http://<hostname>/tor/status-vote/current/d/<d>.z
  1249. once the consensus is complete.
  1250. Once an authority has computed and signed a consensus network status, it
  1251. should send its detached signature to each other authority in an HTTP POST
  1252. request to the URL:
  1253. http://<hostname>/tor/post/consensus-signature
  1254. [XXX Note why we support push-and-then-pull.]
  1255. [XXX possible future features include support for downloading old
  1256. consensuses.]
  1257. 4.3. Downloading consensus status documents (caches only)
  1258. All directory servers (authorities and caches) try to keep a recent
  1259. network-status consensus document to serve to clients. A cache ALWAYS
  1260. downloads a network-status consensus if any of the following are true:
  1261. - The cache has no consensus document.
  1262. - The cache's consensus document is no longer valid.
  1263. Otherwise, the cache downloads a new consensus document at a randomly
  1264. chosen time in the first half-interval after its current consensus
  1265. stops being fresh. (This time is chosen at random to avoid swarming
  1266. the authorities at the start of each period. The interval size is
  1267. inferred from the difference between the valid-after time and the
  1268. fresh-until time on the consensus.)
  1269. [For example, if a cache has a consensus that became valid at 1:00,
  1270. and is fresh until 2:00, that cache will fetch a new consensus at
  1271. a random time between 2:00 and 2:30.]
  1272. 4.4. Downloading and storing router descriptors (authorities and caches)
  1273. Periodically (currently, every 10 seconds), directory servers check
  1274. whether there are any specific descriptors that they do not have and that
  1275. they are not currently trying to download. Caches identify these
  1276. descriptors by hash in the recent network-status consensus documents;
  1277. authorities identify them by hash in vote (if publication date is more
  1278. recent than the descriptor we currently have).
  1279. [XXXX need a way to fetch descriptors ahead of the vote? v2 status docs can
  1280. do that for now.]
  1281. If so, the directory server launches requests to the authorities for these
  1282. descriptors, such that each authority is only asked for descriptors listed
  1283. in its most recent vote (if the requester is an authority) or in the
  1284. consensus (if the requester is a cache). If we're an authority, and more
  1285. than one authority lists the descriptor, we choose which to ask at random.
  1286. If one of these downloads fails, we do not try to download that descriptor
  1287. from the authority that failed to serve it again unless we receive a newer
  1288. network-status (consensus or vote) from that authority that lists the same
  1289. descriptor.
  1290. Directory servers must potentially cache multiple descriptors for each
  1291. router. Servers must not discard any descriptor listed by any recent
  1292. consensus. If there is enough space to store additional descriptors,
  1293. servers SHOULD try to hold those which clients are likely to download the
  1294. most. (Currently, this is judged based on the interval for which each
  1295. descriptor seemed newest.)
  1296. [XXXX define recent]
  1297. Authorities SHOULD NOT download descriptors for routers that they would
  1298. immediately reject for reasons listed in 3.1.
  1299. 4.5. Downloading and storing extra-info documents
  1300. All authorities, and any cache that chooses to cache extra-info documents,
  1301. and any client that uses extra-info documents, should implement this
  1302. section.
  1303. Note that generally, clients don't need extra-info documents.
  1304. Periodically, the Tor instance checks whether it is missing any extra-info
  1305. documents: in other words, if it has any router descriptors with an
  1306. extra-info-digest field that does not match any of the extra-info
  1307. documents currently held. If so, it downloads whatever extra-info
  1308. documents are missing. Caches download from authorities; non-caches try
  1309. to download from caches. We follow the same splitting and back-off rules
  1310. as in 4.4 (if a cache) or 5.3 (if a client).
  1311. 4.6. General-use HTTP URLs
  1312. "Fingerprints" in these URLs are base-16-encoded SHA1 hashes.
  1313. The most recent v3 consensus should be available at:
  1314. http://<hostname>/tor/status-vote/current/consensus.z
  1315. Starting with Tor version 0.2.1.1-alpha is also available at:
  1316. http://<hostname>/tor/status-vote/current/consensus/<F1>+<F2>+<F3>.z
  1317. Where F1, F2, etc. are authority identity fingerprints the client trusts.
  1318. Servers will only return a consensus if more than half of the requested
  1319. authorities have signed the document, otherwise a 404 error will be sent
  1320. back. The fingerprints can be shortened to a length of any multiple of
  1321. two, using only the leftmost part of the encoded fingerprint. Tor uses
  1322. 3 bytes (6 hex characters) of the fingerprint.
  1323. Clients SHOULD sort the fingerprints in ascending order. Server MUST
  1324. accept any order.
  1325. Clients SHOULD use this format when requesting consensus documents from
  1326. directory authority servers and from caches running a version of Tor
  1327. that is known to support this URL format.
  1328. A concatenated set of all the current key certificates should be available
  1329. at:
  1330. http://<hostname>/tor/keys/all.z
  1331. The key certificate for this server (if it is an authority) should be
  1332. available at:
  1333. http://<hostname>/tor/keys/authority.z
  1334. The key certificate for an authority whose authority identity fingerprint
  1335. is <F> should be available at:
  1336. http://<hostname>/tor/keys/fp/<F>.z
  1337. The key certificate whose signing key fingerprint is <F> should be
  1338. available at:
  1339. http://<hostname>/tor/keys/sk/<F>.z
  1340. The key certificate whose identity key fingerprint is <F> and whose signing
  1341. key fingerprint is <S> should be available at:
  1342. http://<hostname>/tor/keys/fp-sk/<F>-<S>.z
  1343. (As usual, clients may request multiple certificates using:
  1344. http://<hostname>/tor/keys/fp-sk/<F1>-<S1>+<F2>-<S2>.z )
  1345. [The above fp-sk format was not supported before Tor 0.2.1.9-alpha.]
  1346. The most recent descriptor for a server whose identity key has a
  1347. fingerprint of <F> should be available at:
  1348. http://<hostname>/tor/server/fp/<F>.z
  1349. The most recent descriptors for servers with identity fingerprints
  1350. <F1>,<F2>,<F3> should be available at:
  1351. http://<hostname>/tor/server/fp/<F1>+<F2>+<F3>.z
  1352. (NOTE: Implementations SHOULD NOT download descriptors by identity key
  1353. fingerprint. This allows a corrupted server (in collusion with a cache) to
  1354. provide a unique descriptor to a client, and thereby partition that client
  1355. from the rest of the network.)
  1356. The server descriptor with (descriptor) digest <D> (in hex) should be
  1357. available at:
  1358. http://<hostname>/tor/server/d/<D>.z
  1359. The most recent descriptors with digests <D1>,<D2>,<D3> should be
  1360. available at:
  1361. http://<hostname>/tor/server/d/<D1>+<D2>+<D3>.z
  1362. The most recent descriptor for this server should be at:
  1363. http://<hostname>/tor/server/authority.z
  1364. [Nothing in the Tor protocol uses this resource yet, but it is useful
  1365. for debugging purposes. Also, the official Tor implementations
  1366. (starting at 0.1.1.x) use this resource to test whether a server's
  1367. own DirPort is reachable.]
  1368. A concatenated set of the most recent descriptors for all known servers
  1369. should be available at:
  1370. http://<hostname>/tor/server/all.z
  1371. Extra-info documents are available at the URLS
  1372. http://<hostname>/tor/extra/d/...
  1373. http://<hostname>/tor/extra/fp/...
  1374. http://<hostname>/tor/extra/all[.z]
  1375. http://<hostname>/tor/extra/authority[.z]
  1376. (As for /tor/server/ URLs: supports fetching extra-info
  1377. documents by their digest, by the fingerprint of their servers,
  1378. or all at once. When serving by fingerprint, we serve the
  1379. extra-info that corresponds to the descriptor we would serve by
  1380. that fingerprint. Only directory authorities of version
  1381. 0.2.0.1-alpha or later are guaranteed to support the first
  1382. three classes of URLs. Caches may support them, and MUST
  1383. support them if they have advertised "caches-extra-info".)
  1384. For debugging, directories SHOULD expose non-compressed objects at URLs like
  1385. the above, but without the final ".z".
  1386. Clients MUST handle compressed concatenated information in two forms:
  1387. - A concatenated list of zlib-compressed objects.
  1388. - A zlib-compressed concatenated list of objects.
  1389. Directory servers MAY generate either format: the former requires less
  1390. CPU, but the latter requires less bandwidth.
  1391. Clients SHOULD use upper case letters (A-F) when base16-encoding
  1392. fingerprints. Servers MUST accept both upper and lower case fingerprints
  1393. in requests.
  1394. 5. Client operation: downloading information
  1395. Every Tor that is not a directory server (that is, those that do
  1396. not have a DirPort set) implements this section.
  1397. 5.1. Downloading network-status documents
  1398. Each client maintains a list of directory authorities. Insofar as
  1399. possible, clients SHOULD all use the same list.
  1400. Clients try to have a live consensus network-status document at all times.
  1401. A network-status document is "live" if the time in its valid-until field
  1402. has not passed.
  1403. If a client is missing a live network-status document, it tries to fetch
  1404. it from a directory cache (or from an authority if it knows no caches).
  1405. On failure, the client waits briefly, then tries that network-status
  1406. document again from another cache. The client does not build circuits
  1407. until it has a live network-status consensus document, and it has
  1408. descriptors for more than 1/4 of the routers that it believes are running.
  1409. (Note: clients can and should pick caches based on the network-status
  1410. information they have: once they have first fetched network-status info
  1411. from an authority, they should not need to go to the authority directly
  1412. again.)
  1413. To avoid swarming the caches whenever a consensus expires, the
  1414. clients download new consensuses at a randomly chosen time after the
  1415. caches are expected to have a fresh consensus, but before their
  1416. consensus will expire. (This time is chosen uniformly at random from
  1417. the interval between the time 3/4 into the first interval after the
  1418. consensus is no longer fresh, and 7/8 of the time remaining after
  1419. that before the consensus is invalid.)
  1420. [For example, if a cache has a consensus that became valid at 1:00,
  1421. and is fresh until 2:00, and expires at 4:00, that cache will fetch
  1422. a new consensus at a random time between 2:45 and 3:50, since 3/4
  1423. of the one-hour interval is 45 minutes, and 7/8 of the remaining 75
  1424. minutes is 65 minutes.]
  1425. 5.2. Downloading and storing router descriptors
  1426. Clients try to have the best descriptor for each router. A descriptor is
  1427. "best" if:
  1428. * It is listed in the consensus network-status document.
  1429. Periodically (currently every 10 seconds) clients check whether there are
  1430. any "downloadable" descriptors. A descriptor is downloadable if:
  1431. - It is the "best" descriptor for some router.
  1432. - The descriptor was published at least 10 minutes in the past.
  1433. (This prevents clients from trying to fetch descriptors that the
  1434. mirrors have probably not yet retrieved and cached.)
  1435. - The client does not currently have it.
  1436. - The client is not currently trying to download it.
  1437. - The client would not discard it immediately upon receiving it.
  1438. - The client thinks it is running and valid (see 6.1 below).
  1439. If at least 16 known routers have downloadable descriptors, or if
  1440. enough time (currently 10 minutes) has passed since the last time the
  1441. client tried to download descriptors, it launches requests for all
  1442. downloadable descriptors, as described in 5.3 below.
  1443. When a descriptor download fails, the client notes it, and does not
  1444. consider the descriptor downloadable again until a certain amount of time
  1445. has passed. (Currently 0 seconds for the first failure, 60 seconds for the
  1446. second, 5 minutes for the third, 10 minutes for the fourth, and 1 day
  1447. thereafter.) Periodically (currently once an hour) clients reset the
  1448. failure count.
  1449. Clients retain the most recent descriptor they have downloaded for each
  1450. router so long as it is not too old (currently, 48 hours), OR so long as
  1451. no better descriptor has been downloaded for the same router.
  1452. [Versions of Tor before 0.1.2.3-alpha would discard descriptors simply for
  1453. being published too far in the past.] [The code seems to discard
  1454. descriptors in all cases after they're 5 days old. True? -RD]
  1455. 5.3. Managing downloads
  1456. When a client has no consensus network-status document, it downloads it
  1457. from a randomly chosen authority. In all other cases, the client
  1458. downloads from caches randomly chosen from among those believed to be V2
  1459. directory servers. (This information comes from the network-status
  1460. documents; see 6 below.)
  1461. When downloading multiple router descriptors, the client chooses multiple
  1462. mirrors so that:
  1463. - At least 3 different mirrors are used, except when this would result
  1464. in more than one request for under 4 descriptors.
  1465. - No more than 128 descriptors are requested from a single mirror.
  1466. - Otherwise, as few mirrors as possible are used.
  1467. After choosing mirrors, the client divides the descriptors among them
  1468. randomly.
  1469. After receiving any response client MUST discard any network-status
  1470. documents and descriptors that it did not request.
  1471. 6. Using directory information
  1472. Everyone besides directory authorities uses the approaches in this section
  1473. to decide which servers to use and what their keys are likely to be.
  1474. (Directory authorities just believe their own opinions, as in 3.1 above.)
  1475. 6.1. Choosing routers for circuits.
  1476. Circuits SHOULD NOT be built until the client has enough directory
  1477. information: a live consensus network status [XXXX fallback?] and
  1478. descriptors for at least 1/4 of the servers believed to be running.
  1479. A server is "listed" if it is included by the consensus network-status
  1480. document. Clients SHOULD NOT use unlisted servers.
  1481. These flags are used as follows:
  1482. - Clients SHOULD NOT use non-'Valid' or non-'Running' routers unless
  1483. requested to do so.
  1484. - Clients SHOULD NOT use non-'Fast' routers for any purpose other than
  1485. very-low-bandwidth circuits (such as introduction circuits).
  1486. - Clients SHOULD NOT use non-'Stable' routers for circuits that are
  1487. likely to need to be open for a very long time (such as those used for
  1488. IRC or SSH connections).
  1489. - Clients SHOULD NOT choose non-'Guard' nodes when picking entry guard
  1490. nodes.
  1491. - Clients SHOULD NOT download directory information from non-'V2Dir'
  1492. caches.
  1493. See the "path-spec.txt" document for more details.
  1494. 6.2. Managing naming
  1495. In order to provide human-memorable names for individual server
  1496. identities, some directory servers bind names to IDs. Clients handle
  1497. names in two ways:
  1498. When a client encounters a name it has not mapped before:
  1499. If the consensus lists any router with that name as "Named", or if
  1500. consensus-method 2 or later is in use and the consensus lists any
  1501. router with that name as having the "Unnamed" flag, then the name is
  1502. bound. (It's bound to the ID listed in the entry with the Named,
  1503. or to an unknown ID if no name is found.)
  1504. When the user refers to a bound name, the implementation SHOULD provide
  1505. only the router with ID bound to that name, and no other router, even
  1506. if the router with the right ID can't be found.
  1507. When a user tries to refer to a non-bound name, the implementation SHOULD
  1508. warn the user. After warning the user, the implementation MAY use any
  1509. router that advertises the name.
  1510. Not every router needs a nickname. When a router doesn't configure a
  1511. nickname, it publishes with the default nickname "Unnamed". Authorities
  1512. SHOULD NOT ever mark a router with this nickname as Named; client software
  1513. SHOULD NOT ever use a router in response to a user request for a router
  1514. called "Unnamed".
  1515. 6.3. Software versions
  1516. An implementation of Tor SHOULD warn when it has fetched a consensus
  1517. network-status, and it is running a software version not listed.
  1518. 6.4. Warning about a router's status.
  1519. If a router tries to publish its descriptor to a Naming authority
  1520. that has its nickname mapped to another key, the router SHOULD
  1521. warn the operator that it is either using the wrong key or is using
  1522. an already claimed nickname.
  1523. If a router has fetched a consensus document,, and the
  1524. authorities do not publish a binding for the router's nickname, the
  1525. router MAY remind the operator that the chosen nickname is not
  1526. bound to this key at the authorities, and suggest contacting the
  1527. authority operators.
  1528. ...
  1529. 6.5. Router protocol versions
  1530. A client should believe that a router supports a given feature if that
  1531. feature is supported by the router or protocol versions in more than half
  1532. of the live networkstatuses' "v" entries for that router. In other words,
  1533. if the "v" entries for some router are:
  1534. v Tor 0.0.8pre1 (from authority 1)
  1535. v Tor 0.1.2.11 (from authority 2)
  1536. v FutureProtocolDescription 99 (from authority 3)
  1537. then the client should believe that the router supports any feature
  1538. supported by 0.1.2.11.
  1539. This is currently equivalent to believing the median declared version for
  1540. a router in all live networkstatuses.
  1541. 7. Standards compliance
  1542. All clients and servers MUST support HTTP 1.0. Clients and servers MAY
  1543. support later versions of HTTP as well.
  1544. 7.1. HTTP headers
  1545. Servers MAY set the Content-Length: header. Servers SHOULD set
  1546. Content-Encoding to "deflate" or "identity".
  1547. Servers MAY include an X-Your-Address-Is: header, whose value is the
  1548. apparent IP address of the client connecting to them (as a dotted quad).
  1549. For directory connections tunneled over a BEGIN_DIR stream, servers SHOULD
  1550. report the IP from which the circuit carrying the BEGIN_DIR stream reached
  1551. them. [Servers before version 0.1.2.5-alpha reported 127.0.0.1 for all
  1552. BEGIN_DIR-tunneled connections.]
  1553. Servers SHOULD disable caching of multiple network statuses or multiple
  1554. router descriptors. Servers MAY enable caching of single descriptors,
  1555. single network statuses, the list of all router descriptors, a v1
  1556. directory, or a v1 running routers document. XXX mention times.
  1557. 7.2. HTTP status codes
  1558. Tor delivers the following status codes. Some were chosen without much
  1559. thought; other code SHOULD NOT rely on specific status codes yet.
  1560. 200 -- the operation completed successfully
  1561. -- the user requested statuses or serverdescs, and none of the ones we
  1562. requested were found (0.2.0.4-alpha and earlier).
  1563. 304 -- the client specified an if-modified-since time, and none of the
  1564. requested resources have changed since that time.
  1565. 400 -- the request is malformed, or
  1566. -- the URL is for a malformed variation of one of the URLs we support,
  1567. or
  1568. -- the client tried to post to a non-authority, or
  1569. -- the authority rejected a malformed posted document, or
  1570. 404 -- the requested document was not found.
  1571. -- the user requested statuses or serverdescs, and none of the ones
  1572. requested were found (0.2.0.5-alpha and later).
  1573. 503 -- we are declining the request in order to save bandwidth
  1574. -- user requested some items that we ordinarily generate or store,
  1575. but we do not have any available.
  1576. 9. Backward compatibility and migration plans
  1577. Until Tor versions before 0.1.1.x are completely obsolete, directory
  1578. authorities should generate, and mirrors should download and cache, v1
  1579. directories and running-routers lists, and allow old clients to download
  1580. them. These documents and the rules for retrieving, serving, and caching
  1581. them are described in dir-spec-v1.txt.
  1582. Until Tor versions before 0.2.0.x are completely obsolete, directory
  1583. authorities should generate, mirrors should download and cache, v2
  1584. network-status documents, and allow old clients to download them.
  1585. Additionally, all directory servers and caches should download, store, and
  1586. serve any router descriptor that is required because of v2 network-status
  1587. documents. These documents and the rules for retrieving, serving, and
  1588. caching them are described in dir-spec-v1.txt.
  1589. A. Consensus-negotiation timeline.
  1590. Period begins: this is the Published time.
  1591. Everybody sends votes
  1592. Reconciliation: everybody tries to fetch missing votes.
  1593. consensus may exist at this point.
  1594. End of voting period:
  1595. everyone swaps signatures.
  1596. Now it's okay for caches to download
  1597. Now it's okay for clients to download.
  1598. Valid-after/valid-until switchover