pub struct AddrMapEvent {
pub hostname: String,
pub destination: Option<String>,
pub expiry: Option<DateTime<Local>>,
pub error: Option<String>,
pub utc_expiry: Option<DateTime<Utc>>,
pub cached: Option<bool>,
/* private fields */
}Expand description
Event indicating a new address mapping has been created.
Address map events are emitted when Tor creates a mapping between
a hostname and its resolved address. This can occur due to DNS
resolution, MAPADDRESS commands, or TrackHostExits configuration.
§Expiration
Address mappings have an expiration time after which they are no longer
valid. The expiry field contains the local time, while utc_expiry
contains the UTC time (if available).
§Caching
The cached field indicates whether the mapping will be kept until
expiration (true) or may be evicted earlier (false).
§Error Mappings
When DNS resolution fails, destination will be None and the error
field will contain the error code.
§Example
use stem_rs::events::AddrMapEvent;
fn handle_addrmap(event: &AddrMapEvent) {
match &event.destination {
Some(dest) => {
println!("{} -> {} (expires: {:?})",
event.hostname, dest, event.expiry);
}
None => {
println!("Resolution failed for {}: {:?}",
event.hostname, event.error);
}
}
}Fields§
§hostname: StringThe hostname being resolved.
destination: Option<String>The resolved address, or None if resolution failed.
expiry: Option<DateTime<Local>>Expiration time in local time.
error: Option<String>Error code if resolution failed.
utc_expiry: Option<DateTime<Utc>>Expiration time in UTC.
cached: Option<bool>Whether the mapping is cached until expiration.
Implementations§
Source§impl AddrMapEvent
impl AddrMapEvent
Sourcepub fn parse(content: &str) -> Result<Self, Error>
pub fn parse(content: &str) -> Result<Self, Error>
Parses an address map event from raw control protocol content.
§Arguments
content- The event content after the event type
§Event Format
Hostname Destination Expiry [error=...] [EXPIRES="..."] [CACHED=YES|NO]§Errors
Returns Error::Protocol if required fields are missing.
Trait Implementations§
Source§impl Clone for AddrMapEvent
impl Clone for AddrMapEvent
Source§fn clone(&self) -> AddrMapEvent
fn clone(&self) -> AddrMapEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more