pub struct RouterStatusEntry {Show 22 fields
pub entry_type: RouterStatusEntryType,
pub nickname: String,
pub fingerprint: String,
pub digest: Option<String>,
pub published: DateTime<Utc>,
pub address: IpAddr,
pub or_port: u16,
pub dir_port: Option<u16>,
pub or_addresses: Vec<(IpAddr, u16, bool)>,
pub flags: Vec<String>,
pub version_line: Option<String>,
pub version: Option<Version>,
pub bandwidth: Option<u64>,
pub measured: Option<u64>,
pub is_unmeasured: bool,
pub unrecognized_bandwidth_entries: Vec<String>,
pub exit_policy: Option<MicroExitPolicy>,
pub protocols: HashMap<String, Vec<u32>>,
pub microdescriptor_digest: Option<String>,
pub microdescriptor_hashes: Vec<MicrodescriptorHash>,
pub identifier_type: Option<String>,
pub identifier: Option<String>,
/* private fields */
}Expand description
Information about an individual relay in a network status document.
A RouterStatusEntry contains the essential information about a single
relay as recorded in a network status consensus or vote. This includes
the relay’s identity, network location, capabilities, and performance
characteristics.
§Overview
Router status entries are the building blocks of consensus documents. Each entry describes one relay and contains:
- Identity: Nickname, fingerprint, and optional Ed25519 identity
- Network: IP address, OR port, directory port, additional addresses
- Capabilities: Flags assigned by directory authorities
- Performance: Bandwidth weights for path selection
- Policy: Exit policy summary
- Version: Tor software version
§Entry Types
The entry_type field determines the format:
| Type | Digest Field | Microdescriptor |
|---|---|---|
| V2 | digest (hex) | N/A |
| V3 | digest (hex) | Via m line in votes |
| MicroV3 | N/A | microdescriptor_digest |
| Bridge | digest (hex) | N/A |
§Parsing
Use the appropriate parsing method for your entry type:
parse()- Standard V3 consensus entriesparse_micro()- Microdescriptor consensus entriesparse_v2()- Legacy V2 entriesparse_vote()- Vote document entries
§Example
use stem_rs::descriptor::router_status::RouterStatusEntry;
let content = r#"r example ARIJF2zbqirB9IwsW0mQznccWww oQZFLYe9e4A7bOkWKR7TaNxb0JE 2024-01-15 12:00:00 192.0.2.1 9001 9030
s Fast Guard Running Stable Valid
v Tor 0.4.8.10
w Bandwidth=5000 Measured=4800
p accept 80,443"#;
let entry = RouterStatusEntry::parse(content).unwrap();
// Access relay identity
assert_eq!(entry.nickname, "example");
assert!(!entry.fingerprint.is_empty());
// Check flags
assert!(entry.flags.contains(&"Guard".to_string()));
assert!(entry.flags.contains(&"Running".to_string()));
// Check bandwidth
assert_eq!(entry.bandwidth, Some(5000));
assert_eq!(entry.measured, Some(4800));§Flags
The flags field contains strings assigned by directory authorities.
Common flags include:
Authority- A directory authorityBadExit- Believed to be useless as an exitExit- Suitable for exit trafficFast- Suitable for high-bandwidth circuitsGuard- Suitable as an entry guardHSDir- Hidden service directoryRunning- Currently usableStable- Suitable for long-lived circuitsValid- Has been validated
§Thread Safety
RouterStatusEntry is Send and Sync, making it safe to share
across threads.
§See Also
crate::descriptor::consensus::NetworkStatusDocument- Contains router status entriescrate::Flag- Enum of standard relay flags
Fields§
§entry_type: RouterStatusEntryTypeThe type of this router status entry.
Determines the format and which fields are available.
nickname: StringThe relay’s nickname (1-19 alphanumeric characters).
Nicknames are not unique identifiers; use fingerprint for
reliable relay identification.
fingerprint: StringThe relay’s identity fingerprint as uppercase hexadecimal.
This is a 40-character hex string representing the SHA-1 hash of the relay’s identity key. This is the authoritative identifier for a relay.
digest: Option<String>SHA-1 digest of the relay’s server descriptor (hex, uppercase).
Present in V2, V3, and Bridge entries. Not present in MicroV3
entries (use microdescriptor_digest instead).
published: DateTime<Utc>When the relay’s descriptor was published (UTC).
address: IpAddrThe relay’s primary IP address.
or_port: u16The relay’s OR (onion router) port for relay traffic.
dir_port: Option<u16>The relay’s directory port, if it serves directory information.
None if the relay doesn’t serve directory information (port 0).
or_addresses: Vec<(IpAddr, u16, bool)>Additional OR addresses (typically IPv6).
Each tuple contains (address, port, is_ipv6). The primary address
is in the address field; this contains additional addresses
from a lines.
flags: Vec<String>Flags assigned to this relay by directory authorities.
Common flags: “Authority”, “BadExit”, “Exit”, “Fast”, “Guard”, “HSDir”, “Running”, “Stable”, “Valid”, “V2Dir”.
version_line: Option<String>The raw version line from the entry.
Typically starts with “Tor “ followed by the version number.
version: Option<Version>Parsed Tor version, if the version line was parseable.
None if the relay uses a non-standard version format.
bandwidth: Option<u64>Consensus bandwidth weight (arbitrary units, typically KB/s).
Used for path selection weighting. Higher values indicate more bandwidth capacity.
measured: Option<u64>Bandwidth measured by bandwidth authorities.
More accurate than self-reported bandwidth. Used when available.
is_unmeasured: boolWhether the bandwidth value is unmeasured.
true if the bandwidth is not based on actual measurements
(fewer than 3 measurements available).
unrecognized_bandwidth_entries: Vec<String>Unrecognized entries from the w (bandwidth) line.
Contains any bandwidth-related key=value pairs that weren’t recognized during parsing.
exit_policy: Option<MicroExitPolicy>Exit policy summary from the p line.
A compact representation of the relay’s exit policy.
protocols: HashMap<String, Vec<u32>>Protocol versions supported by this relay.
Maps protocol names (e.g., “Link”, “Relay”) to lists of supported version numbers.
microdescriptor_digest: Option<String>Microdescriptor digest (base64) for MicroV3 entries.
Used to fetch the corresponding microdescriptor.
microdescriptor_hashes: Vec<MicrodescriptorHash>Microdescriptor hashes from vote documents.
Contains digests computed using different consensus methods. Only present in vote documents, not consensus documents.
identifier_type: Option<String>Ed25519 identity key type (typically “ed25519”).
Present in vote documents when the relay has an Ed25519 key.
identifier: Option<String>Ed25519 identity key value (base64).
The value “none” indicates the relay doesn’t have an Ed25519 key.
Implementations§
Source§impl RouterStatusEntry
impl RouterStatusEntry
Sourcepub fn new(
entry_type: RouterStatusEntryType,
nickname: String,
fingerprint: String,
published: DateTime<Utc>,
address: IpAddr,
or_port: u16,
) -> Self
pub fn new( entry_type: RouterStatusEntryType, nickname: String, fingerprint: String, published: DateTime<Utc>, address: IpAddr, or_port: u16, ) -> Self
Creates a new router status entry with minimal required fields.
This constructor creates an entry with only the essential fields populated. Optional fields are set to their default values.
§Arguments
entry_type- The type of entry (V2, V3, MicroV3, or Bridge)nickname- The relay’s nickname (1-19 alphanumeric characters)fingerprint- The relay’s identity fingerprint (40 hex characters)published- When the relay’s descriptor was publishedaddress- The relay’s primary IP addressor_port- The relay’s OR port
§Example
use stem_rs::descriptor::router_status::{RouterStatusEntry, RouterStatusEntryType};
use chrono::Utc;
use std::net::IpAddr;
let entry = RouterStatusEntry::new(
RouterStatusEntryType::V3,
"example".to_string(),
"AABBCCDD".repeat(5),
Utc::now(),
"192.0.2.1".parse().unwrap(),
9001,
);
assert_eq!(entry.nickname, "example");
assert_eq!(entry.or_port, 9001);Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses a V3 router status entry from a string.
This is the standard parsing method for entries from network status v3 consensus documents.
§Arguments
content- The entry content as a multi-line string
§Returns
A parsed RouterStatusEntry on success.
§Errors
Returns Error::Parse if:
- The
rline is missing or malformed - Required fields cannot be parsed
- The fingerprint cannot be decoded from base64
§Example
use stem_rs::descriptor::router_status::RouterStatusEntry;
let content = r#"r example ARIJF2zbqirB9IwsW0mQznccWww oQZFLYe9e4A7bOkWKR7TaNxb0JE 2024-01-15 12:00:00 192.0.2.1 9001 0
s Fast Running Valid"#;
let entry = RouterStatusEntry::parse(content).unwrap();
assert_eq!(entry.nickname, "example");Sourcepub fn parse_micro(content: &str) -> Result<Self, Error>
pub fn parse_micro(content: &str) -> Result<Self, Error>
Parses a microdescriptor-flavored V3 router status entry.
Use this method for entries from microdescriptor consensus documents.
The main difference from parse() is that the r line
does not contain a server descriptor digest.
§Arguments
content- The entry content as a multi-line string
§Returns
A parsed RouterStatusEntry with entry_type set to MicroV3.
§Errors
Returns Error::Parse if the entry is malformed.
§Example
use stem_rs::descriptor::router_status::RouterStatusEntry;
let content = r#"r example ARIJF2zbqirB9IwsW0mQznccWww 2024-01-15 12:00:00 192.0.2.1 9001 0
m aiUklwBrua82obG5AsTX+iEpkjQA2+AQHxZ7GwMfY70
s Fast Running Valid"#;
let entry = RouterStatusEntry::parse_micro(content).unwrap();
assert!(entry.digest.is_none());
assert!(entry.microdescriptor_digest.is_some());Sourcepub fn parse_v2(content: &str) -> Result<Self, Error>
pub fn parse_v2(content: &str) -> Result<Self, Error>
Parses a legacy V2 router status entry.
Use this method for entries from older network status v2 documents.
§Arguments
content- The entry content as a multi-line string
§Returns
A parsed RouterStatusEntry with entry_type set to V2.
§Errors
Returns Error::Parse if the entry is malformed.
Sourcepub fn parse_vote(content: &str) -> Result<Self, Error>
pub fn parse_vote(content: &str) -> Result<Self, Error>
Parses a router status entry from a vote document.
Vote documents may contain additional fields not present in
consensus documents, such as Ed25519 identity keys (id line)
and microdescriptor hashes (m lines with method numbers).
§Arguments
content- The entry content as a multi-line string
§Returns
A parsed RouterStatusEntry with vote-specific fields populated.
§Errors
Returns Error::Parse if the entry is malformed.
§Example
use stem_rs::descriptor::router_status::RouterStatusEntry;
let content = r#"r example ARIJF2zbqirB9IwsW0mQznccWww oQZFLYe9e4A7bOkWKR7TaNxb0JE 2024-01-15 12:00:00 192.0.2.1 9001 0
s Fast Running Valid
id ed25519 8RH34kO07Pp+XYwzdoATVyCibIvmbslUjRkAm7J4IA8
m 13,14,15 sha256=uaAYTOVuYRqUwJpNfP2WizjzO0FiNQB4U97xSQu+vMc"#;
let entry = RouterStatusEntry::parse_vote(content).unwrap();
assert_eq!(entry.identifier_type, Some("ed25519".to_string()));
assert!(!entry.microdescriptor_hashes.is_empty());Sourcepub fn parse_with_type(
content: &str,
entry_type: RouterStatusEntryType,
is_vote: bool,
) -> Result<Self, Error>
pub fn parse_with_type( content: &str, entry_type: RouterStatusEntryType, is_vote: bool, ) -> Result<Self, Error>
Parses a router status entry with explicit type and vote flag.
This is the general-purpose parsing method that other parse methods delegate to. Use this when you need explicit control over the entry type and whether vote-specific parsing should be enabled.
§Arguments
content- The entry content as a multi-line stringentry_type- The type of entry to parse asis_vote- Whether to enable vote-specific parsing (formandidlines)
§Returns
A parsed RouterStatusEntry on success.
§Errors
Returns Error::Parse if:
- The
rline is missing or has insufficient fields - The fingerprint or digest cannot be decoded from base64
- The IP address is invalid
- The ports are invalid
- The publication timestamp is malformed
§Line Parsing
The following lines are recognized:
| Keyword | Description |
|---|---|
r | Router identity (required) |
a | Additional OR addresses |
s | Flags |
v | Version |
w | Bandwidth weights |
p | Exit policy summary |
pr | Protocol versions |
m | Microdescriptor digest/hashes |
id | Ed25519 identity (votes only) |
Sourcepub fn unrecognized_lines(&self) -> &[String]
pub fn unrecognized_lines(&self) -> &[String]
Returns lines that weren’t recognized during parsing.
This is useful for forward compatibility when new fields are added to the router status entry format.
§Returns
A slice of unrecognized line strings.
Trait Implementations§
Source§impl Clone for RouterStatusEntry
impl Clone for RouterStatusEntry
Source§fn clone(&self) -> RouterStatusEntry
fn clone(&self) -> RouterStatusEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RouterStatusEntry
impl Debug for RouterStatusEntry
Source§impl Display for RouterStatusEntry
Formats the router status entry back to its string representation.
impl Display for RouterStatusEntry
Formats the router status entry back to its string representation.
The output follows the standard router status entry format and can
be parsed back using the appropriate parse_* method.
Source§impl FromStr for RouterStatusEntry
Parses a router status entry from a string.
impl FromStr for RouterStatusEntry
Parses a router status entry from a string.
This implementation delegates to RouterStatusEntry::parse(),
parsing the content as a V3 consensus entry.
§Example
use stem_rs::descriptor::router_status::RouterStatusEntry;
use std::str::FromStr;
let content = r#"r example ARIJF2zbqirB9IwsW0mQznccWww oQZFLYe9e4A7bOkWKR7TaNxb0JE 2024-01-15 12:00:00 192.0.2.1 9001 0
s Running Valid"#;
let entry = RouterStatusEntry::from_str(content).unwrap();
assert_eq!(entry.nickname, "example");