pub struct NetworkStatusDocument {Show 26 fields
pub version: u32,
pub version_flavor: String,
pub is_consensus: bool,
pub is_vote: bool,
pub is_microdescriptor: bool,
pub consensus_method: Option<u32>,
pub consensus_methods: Option<Vec<u32>>,
pub published: Option<DateTime<Utc>>,
pub valid_after: DateTime<Utc>,
pub fresh_until: DateTime<Utc>,
pub valid_until: DateTime<Utc>,
pub vote_delay: Option<u32>,
pub dist_delay: Option<u32>,
pub client_versions: Vec<Version>,
pub server_versions: Vec<Version>,
pub known_flags: Vec<String>,
pub recommended_client_protocols: HashMap<String, Vec<u32>>,
pub recommended_relay_protocols: HashMap<String, Vec<u32>>,
pub required_client_protocols: HashMap<String, Vec<u32>>,
pub required_relay_protocols: HashMap<String, Vec<u32>>,
pub params: HashMap<String, i32>,
pub shared_randomness_previous: Option<SharedRandomness>,
pub shared_randomness_current: Option<SharedRandomness>,
pub bandwidth_weights: HashMap<String, i32>,
pub authorities: Vec<DirectoryAuthority>,
pub signatures: Vec<DocumentSignature>,
/* private fields */
}Expand description
A network status consensus or vote document.
This is the primary document that describes the state of the Tor network. Clients download the consensus to learn about available relays and their capabilities.
§Document Types
- Consensus (
is_consensus = true): The agreed-upon network view - Vote (
is_vote = true): An individual authority’s opinion - Microdesc (
is_microdescriptor = true): Uses microdescriptor hashes
§Validity Times
The document has three important timestamps that control its lifecycle:
valid-after -----> fresh-until -----> valid-until
| | |
| Document is | Should fetch | Document
| fresh/current | new consensus | expired§Example
use stem_rs::descriptor::{NetworkStatusDocument, Descriptor};
let content = std::fs::read_to_string("cached-consensus").unwrap();
let doc = NetworkStatusDocument::parse(&content).unwrap();
// Check document type
if doc.is_consensus {
println!("This is a consensus document");
}
// Check validity
let now = chrono::Utc::now();
if now > doc.valid_until {
println!("Consensus has expired!");
} else if now > doc.fresh_until {
println!("Should fetch a new consensus");
}
// Check required protocols
for (proto, versions) in &doc.required_client_protocols {
println!("Required {}: {:?}", proto, versions);
}§Thread Safety
NetworkStatusDocument is Send and Sync as it contains only owned data.
Fields§
§version: u32Network status version (typically 3).
version_flavor: StringVersion flavor (empty string or “microdesc”).
is_consensus: boolWhether this is a consensus document.
is_vote: boolWhether this is a vote document.
is_microdescriptor: boolWhether this uses microdescriptor format.
consensus_method: Option<u32>Consensus method used (consensus only).
consensus_methods: Option<Vec<u32>>Supported consensus methods (vote only).
published: Option<DateTime<Utc>>When this vote was published (vote only).
valid_after: DateTime<Utc>When this document becomes valid.
fresh_until: DateTime<Utc>When clients should fetch a new document.
valid_until: DateTime<Utc>When this document expires.
vote_delay: Option<u32>Seconds authorities wait for votes.
dist_delay: Option<u32>Seconds authorities wait for signatures.
client_versions: Vec<Version>Recommended Tor versions for clients.
server_versions: Vec<Version>Recommended Tor versions for relays.
known_flags: Vec<String>Flags that may appear on relay entries.
recommended_client_protocols: HashMap<String, Vec<u32>>Recommended protocol versions for clients.
recommended_relay_protocols: HashMap<String, Vec<u32>>Recommended protocol versions for relays.
required_client_protocols: HashMap<String, Vec<u32>>Required protocol versions for clients.
required_relay_protocols: HashMap<String, Vec<u32>>Required protocol versions for relays.
params: HashMap<String, i32>Consensus parameters (key=value pairs).
Previous shared randomness value.
Current shared randomness value.
bandwidth_weights: HashMap<String, i32>Bandwidth weights for path selection.
Directory authorities that contributed to this document.
signatures: Vec<DocumentSignature>Signatures from directory authorities.
Trait Implementations§
Source§impl Clone for NetworkStatusDocument
impl Clone for NetworkStatusDocument
Source§fn clone(&self) -> NetworkStatusDocument
fn clone(&self) -> NetworkStatusDocument
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more