Expand description
Network status consensus document parsing.
This module provides types for parsing Tor network status consensus documents which describe the current state of the Tor network including all known relays.
§Overview
Network status documents are the authoritative source of information about the Tor network. They come in two forms:
- Votes: Individual directory authority opinions about the network
- Consensus: The agreed-upon view signed by multiple authorities
Clients download the consensus to learn about available relays, their capabilities, and which relays are recommended for different purposes.
§Document Types
| Type | Description |
|---|---|
| Consensus | Agreed network status signed by authorities |
| Vote | Individual authority’s view before consensus |
| Microdesc Consensus | Consensus using microdescriptor hashes |
§Validity Times
Consensus documents have three important timestamps:
- valid-after: When the consensus becomes valid
- fresh-until: When clients should fetch a new consensus
- valid-until: When the consensus expires completely
Clients should fetch a new consensus between fresh-until and valid-until.
§Document Format
network-status-version 3 [microdesc]
vote-status consensus|vote
consensus-method <N>
valid-after <YYYY-MM-DD HH:MM:SS>
fresh-until <YYYY-MM-DD HH:MM:SS>
valid-until <YYYY-MM-DD HH:MM:SS>
voting-delay <vote-seconds> <dist-seconds>
known-flags <flag> <flag> ...
recommended-client-protocols <proto>=<versions> ...
required-client-protocols <proto>=<versions> ...
params <key>=<value> ...
dir-source <nickname> <identity> <hostname> <address> <dirport> <orport>
...
directory-footer
bandwidth-weights <key>=<value> ...
directory-signature <identity> <signing-key-digest>
-----BEGIN SIGNATURE-----
<base64 signature>
-----END SIGNATURE-----§Example
use stem_rs::descriptor::{NetworkStatusDocument, Descriptor};
let content = std::fs::read_to_string("cached-consensus").unwrap();
let consensus = NetworkStatusDocument::parse(&content).unwrap();
println!("Consensus method: {:?}", consensus.consensus_method);
println!("Valid after: {}", consensus.valid_after);
println!("Valid until: {}", consensus.valid_until);
println!("Known flags: {:?}", consensus.known_flags);
println!("Authorities: {}", consensus.authorities.len());
println!("Signatures: {}", consensus.signatures.len());
// Check protocol requirements
if let Some(versions) = consensus.required_client_protocols.get("Link") {
println!("Required Link protocol versions: {:?}", versions);
}§Shared Randomness
Modern consensus documents include shared randomness values used for hidden service directory assignment. These are computed collaboratively by the directory authorities.
§See Also
RouterStatusEntry- Individual relay entries in consensusDirectoryAuthority- Authority information- Python Stem NetworkStatusDocument
Structs§
- Document
Signature - A signature on a network status document.
- Network
Status Document - A network status consensus or vote document.
- Shared
Randomness - Shared randomness value from directory authority collaboration.