pub struct DirectoryAuthority {Show 17 fields
pub nickname: String,
pub v3ident: String,
pub hostname: String,
pub address: IpAddr,
pub dir_port: Option<u16>,
pub or_port: u16,
pub is_legacy: bool,
pub contact: Option<String>,
pub vote_digest: Option<String>,
pub legacy_dir_key: Option<String>,
pub key_certificate: Option<KeyCertificate>,
pub is_shared_randomness_participate: bool,
pub shared_randomness_commitments: Vec<SharedRandomnessCommitment>,
pub shared_randomness_previous_reveal_count: Option<u32>,
pub shared_randomness_previous_value: Option<String>,
pub shared_randomness_current_reveal_count: Option<u32>,
pub shared_randomness_current_value: Option<String>,
/* private fields */
}Expand description
A directory authority entry from a network status document.
Directory authorities are trusted relays that vote on the state of the Tor network. This struct represents an authority’s entry as it appears in vote or consensus documents.
§Conceptual Role
Directory authorities are the backbone of Tor’s distributed trust model. They:
- Collect and validate relay server descriptors
- Vote on relay flags (Guard, Exit, Stable, etc.)
- Produce the network consensus that clients use
- Participate in shared randomness generation
§Vote vs Consensus Entries
Authority entries differ based on document type:
| Field | Vote | Consensus |
|---|---|---|
key_certificate | Required | Not present |
vote_digest | Not present | Required |
legacy_dir_key | May be present | Not present |
§Legacy Authorities
Some authority entries have a -legacy suffix on their nickname,
indicating they are legacy entries for backward compatibility.
Legacy entries have relaxed validation requirements.
§Example
use stem_rs::descriptor::authority::DirectoryAuthority;
// Parse a consensus authority entry
let content = r#"dir-source gabelmoo F2044413DAC2E02E3D6BCF4735A19BCA1DE97281 131.188.40.189 131.188.40.189 80 443
contact 4096R/261C5FBE77285F88FB0C343266C8C2D7C5AA446D Sebastian Hahn <tor@sebastianhahn.net>
vote-digest 49015F787433103580E3B66A1707A00E60F2D15B
"#;
let authority = DirectoryAuthority::parse(content, false)?;
assert_eq!(authority.nickname, "gabelmoo");
assert!(!authority.is_legacy);§See Also
KeyCertificate: Authority signing keysNetworkStatusDocument: Contains authority entries
Fields§
§nickname: StringThe authority’s nickname (1-19 alphanumeric characters).
May have a -legacy suffix for legacy entries.
v3ident: StringThe authority’s v3 identity key fingerprint (40 hex characters). Used to identify the authority and verify signatures.
hostname: StringThe authority’s hostname.
address: IpAddrThe authority’s IP address (IPv4 or IPv6).
dir_port: Option<u16>The directory port for HTTP directory requests, or None if not available.
or_port: u16The OR (onion router) port for relay traffic.
is_legacy: boolWhether this is a legacy authority entry (nickname ends with -legacy).
contact: Option<String>Contact information for the authority operator.
vote_digest: Option<String>Digest of the authority’s vote (only in consensus documents).
legacy_dir_key: Option<String>Legacy directory key fingerprint (only in votes, for backward compatibility).
key_certificate: Option<KeyCertificate>The authority’s key certificate (only in vote documents).
Whether this authority participates in the shared randomness protocol.
Commitments to shared random values from this authority.
Number of authorities that revealed for the previous shared random value.
The previous shared random value (base64 encoded).
Number of authorities that revealed for the current shared random value.
The current shared random value (base64 encoded).
Implementations§
Source§impl DirectoryAuthority
impl DirectoryAuthority
Sourcepub fn parse(content: &str, is_vote: bool) -> Result<Self, Error>
pub fn parse(content: &str, is_vote: bool) -> Result<Self, Error>
Parses a directory authority entry from its string representation.
This method parses authority entries with full validation enabled.
Use parse_with_validation for control
over validation behavior.
§Arguments
content- The raw authority entry textis_vote-trueif parsing from a vote document,falsefor consensus
§Errors
Returns Error::Parse if:
- The entry doesn’t start with a
dir-sourceline - Required fields are missing or malformed
- Fingerprints are not valid 40-character hex strings
- IP addresses or ports are invalid
- Vote entries lack a key certificate
- Consensus entries have fields that should only appear in votes
§Example
use stem_rs::descriptor::authority::DirectoryAuthority;
// Parse a consensus entry
let consensus_entry = r#"dir-source moria1 D586D18309DED4CD6D57C18FDB97EFA96D330566 128.31.0.39 128.31.0.39 9131 9101
contact arma
vote-digest 49015F787433103580E3B66A1707A00E60F2D15B
"#;
let authority = DirectoryAuthority::parse(consensus_entry, false)?;Sourcepub fn parse_with_validation(
content: &str,
validate: bool,
is_vote: bool,
) -> Result<Self, Error>
pub fn parse_with_validation( content: &str, validate: bool, is_vote: bool, ) -> Result<Self, Error>
Parses a directory authority entry with configurable validation.
When validation is disabled, the parser is more lenient and will attempt to extract as much information as possible even from malformed entries.
§Arguments
content- The raw authority entry textvalidate- Whether to perform strict validationis_vote-trueif parsing from a vote document,falsefor consensus
§Errors
When validate is true, returns Error::Parse for validation failures.
When validate is false, parsing errors are silently ignored where possible.
Sourcepub fn raw_content(&self) -> &[u8] ⓘ
pub fn raw_content(&self) -> &[u8] ⓘ
Returns the raw bytes of the authority entry as it appeared in the document.
This preserves the original formatting and can be used for signature verification or re-serialization.
Sourcepub fn unrecognized_lines(&self) -> &[String]
pub fn unrecognized_lines(&self) -> &[String]
Returns lines that were not recognized during parsing.
Unrecognized lines may indicate:
- New fields added in newer Tor versions
- Malformed or corrupted data
- Custom extensions
§Example
use stem_rs::descriptor::authority::DirectoryAuthority;
let content = r#"dir-source test AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA example.com 1.2.3.4 80 443
contact test
unknown-field some-value
vote-digest AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
"#;
let authority = DirectoryAuthority::parse(content, false)?;
assert!(authority.unrecognized_lines().iter().any(|l| l.contains("unknown-field")));Sourcepub fn to_descriptor_string(&self) -> String
pub fn to_descriptor_string(&self) -> String
Converts the authority entry back to its descriptor string format.
The output follows the Tor directory protocol format and can be used for serialization or debugging.
§Note
The output may not be byte-for-byte identical to the original input due to normalization of whitespace and field ordering.
Trait Implementations§
Source§impl Clone for DirectoryAuthority
impl Clone for DirectoryAuthority
Source§fn clone(&self) -> DirectoryAuthority
fn clone(&self) -> DirectoryAuthority
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more