pub struct TorDNSEL {
pub fingerprint: String,
pub published: Option<DateTime<Utc>>,
pub last_status: Option<DateTime<Utc>>,
pub exit_addresses: Vec<(Ipv4Addr, DateTime<Utc>)>,
/* private fields */
}Expand description
A TorDNSEL exit list entry for a single relay.
Each entry represents one Tor exit relay and contains information about when it was last seen and what IP addresses it uses for exiting traffic.
§Structure
A TorDNSEL entry contains:
- The relay’s fingerprint (40-character hex string)
- Publication and last-seen timestamps
- One or more exit addresses with observation times
§Exit Addresses
A relay may have multiple exit addresses because:
- It may use different addresses for different exit ports
- It may have changed addresses over time
- It may be multi-homed (multiple network interfaces)
Each exit address is paired with the time it was observed being used.
§Example
use stem_rs::descriptor::tordnsel::TorDNSEL;
let content = r#"ExitNode 003A71137D959748C8157C4A76ECA639CEF5E33E
Published 2024-01-01 12:00:00
LastStatus 2024-01-01 13:00:00
ExitAddress 192.168.1.1 2024-01-01 13:30:00
"#;
let entry = TorDNSEL::parse(content)?;
assert_eq!(entry.fingerprint, "003A71137D959748C8157C4A76ECA639CEF5E33E");
assert_eq!(entry.exit_addresses.len(), 1);Fields§
§fingerprint: StringSHA-1 fingerprint of the relay’s identity key.
This is a 40-character hexadecimal string that uniquely identifies the relay. It matches the fingerprint in server descriptors and consensus documents.
published: Option<DateTime<Utc>>Time when the relay published its descriptor.
This indicates when the relay last updated its server descriptor.
May be None if the field was missing or unparseable.
last_status: Option<DateTime<Utc>>Time when the relay was last seen in a network status.
This indicates when the relay was last included in a consensus
document. A relay not seen recently may no longer be active.
May be None if the field was missing or unparseable.
exit_addresses: Vec<(Ipv4Addr, DateTime<Utc>)>List of exit addresses observed for this relay.
Each entry is a tuple of (IPv4 address, observation time). The observation time indicates when TorDNSEL detected that the relay was using this address for exit traffic.
A relay may have multiple exit addresses if it uses different addresses for different connections or has changed addresses.
Implementations§
Source§impl TorDNSEL
impl TorDNSEL
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses a TorDNSEL entry from a string.
This method parses a single exit list entry containing information about one relay.
§Arguments
content- The entry content as a string
§Returns
A parsed TorDNSEL entry on success.
§Errors
Returns Error::Parse if:
- The
ExitNodeline is missing - The fingerprint is not a valid 40-character hex string
Note: Invalid timestamps are silently ignored rather than causing errors.
§Example
use stem_rs::descriptor::tordnsel::TorDNSEL;
let content = r#"ExitNode 003A71137D959748C8157C4A76ECA639CEF5E33E
Published 2024-01-01 12:00:00
ExitAddress 192.168.1.1 2024-01-01 13:30:00
"#;
let entry = TorDNSEL::parse(content)?;
assert_eq!(entry.fingerprint, "003A71137D959748C8157C4A76ECA639CEF5E33E");Sourcepub fn parse_bytes(content: &[u8]) -> Result<Self, Error>
pub fn parse_bytes(content: &[u8]) -> Result<Self, Error>
Parses a TorDNSEL entry from raw bytes.
This is the byte-oriented version of parse(),
useful when reading directly from files or network streams.
§Arguments
content- The entry content as bytes (UTF-8 encoded)
§Returns
A parsed TorDNSEL entry on success.
§Errors
Returns Error::Parse if:
- The
ExitNodeline is missing - The fingerprint is not a valid 40-character hex string
§Note
Invalid UTF-8 sequences are replaced with the Unicode replacement character (U+FFFD) rather than causing an error.
Sourcepub fn raw_content(&self) -> &[u8] ⓘ
pub fn raw_content(&self) -> &[u8] ⓘ
Returns the raw bytes of the original entry content.
This provides access to the exact bytes that were parsed, useful for debugging or storing entries in their original format.
§Returns
A byte slice containing the original entry content.
Sourcepub fn unrecognized_lines(&self) -> &[String]
pub fn unrecognized_lines(&self) -> &[String]
Returns lines that were not recognized during parsing.
Unrecognized lines are preserved for forward compatibility with future exit list format extensions.
§Returns
A slice of strings, each representing an unrecognized line. Empty if all lines were recognized.
Sourcepub fn to_descriptor_string(&self) -> String
pub fn to_descriptor_string(&self) -> String
Converts the entry back to its string representation.
This produces a string in the standard TorDNSEL format that can be parsed again or written to a file.
§Returns
A string containing the entry in standard format.
§Example
use stem_rs::descriptor::tordnsel::TorDNSEL;
let content = r#"ExitNode 003A71137D959748C8157C4A76ECA639CEF5E33E
Published 2024-01-01 12:00:00
ExitAddress 192.168.1.1 2024-01-01 13:30:00
"#;
let entry = TorDNSEL::parse(content)?;
let output = entry.to_descriptor_string();
assert!(output.contains("ExitNode 003A71137D959748C8157C4A76ECA639CEF5E33E"));