tor_netdoc/doc/netstatus/
each_variety.rs

1//! network status documents - items for all varieties, that vary
2//!
3//! **This file is reincluded multiple times**,
4//! by the macros in [`crate::doc::ns_variety_definition_macros`],
5//! once for votes, and once for each consensus flavour.
6//! It is *not* a module `crate::doc::netstatus::rs::each_variety`.
7//!
8//! Each time this file is included by one of the macros mentioned above,
9//! the `ns_***` macros (such as `ns_const_name!`) may expand to different values.
10//!
11//! See [`crate::doc::ns_variety_definition_macros`].
12
13use super::*;
14
15ns_use_this_variety! {
16    pub use [crate::doc::netstatus::rs]::?::{RouterStatus};
17}
18
19/// The preamble of a network status document, except for the intro and `vote-status` items.
20///
21/// <https://spec.torproject.org/dir-spec/consensus-formats.html#section:preable>
22///
23/// **Does not include `network-status-version` and `vote-status`**.
24/// In the old parser this is not represented directly;
25/// instead, in `Consensus.flavor`, there's just the `ConsensusFlavor`.
26/// `parse2` doesn't (currently) support subdocuments which contain the parent's intro item
27/// (ie, `#[deftly(netdoc(flatten))]` is not supported on the first field.)
28#[derive(Debug, Clone)]
29#[non_exhaustive]
30pub struct Preamble {
31    /// Over what time is this consensus valid?  (For votes, this is
32    /// the time over which the voted-upon consensus should be valid.)
33    pub lifetime: Lifetime,
34    /// List of recommended Tor client versions.
35    pub client_versions: Vec<String>,
36    /// List of recommended Tor relay versions.
37    pub server_versions: Vec<String>,
38    /// Lists of recommended and required subprotocols.
39    ///
40    /// **`{recommended,required}-{client,relay}-protocols`**
41    pub proto_statuses: Arc<ProtoStatuses>,
42    /// Declared parameters for tunable settings about how to the
43    /// network should operator. Some of these adjust timeouts and
44    /// whatnot; some features things on and off.
45    pub params: NetParams<i32>,
46    /// How long in seconds should voters wait for votes and
47    /// signatures (respectively) to propagate?
48    pub voting_delay: Option<(u32, u32)>,
49    /// What "method" was used to produce this consensus?  (A
50    /// consensus method is a version number used by authorities to
51    /// upgrade the consensus algorithm.)
52    pub consensus_method: u32,
53    /// Global shared-random value for the previous shared-random period.
54    pub shared_rand_previous_value: Option<SharedRandStatus>,
55    /// Global shared-random value for the current shared-random period.
56    pub shared_rand_current_value: Option<SharedRandStatus>,
57}