Expand description
MAPADDRESS response parsing.
This module parses responses from the MAPADDRESS command, which creates address mappings in Tor. These mappings redirect connections from one address to another, useful for hostname-to-IP mappings or virtual addresses.
§Response Format
A successful MAPADDRESS response contains address mappings:
250 1.2.3.4=tor.freehaven.netResponses can contain a mixture of successes and failures:
512-syntax error: invalid address '@@@'
250 1.2.3.4=tor.freehaven.net§Example
use stem_rs::response::{ControlMessage, MapAddressResponse};
// Single successful mapping
let msg = ControlMessage::from_str(
"250 1.2.3.4=tor.freehaven.net\r\n",
None,
false
).unwrap();
let response = MapAddressResponse::from_message(&msg).unwrap();
assert_eq!(
response.mapped.get("1.2.3.4"),
Some(&"tor.freehaven.net".to_string())
);
assert!(response.failures.is_empty());§Partial Failures
The response can contain both successful mappings and failures. The from_message method only returns an error if ALL mappings fail.
§See Also
crate::Controller::map_address: High-level API for address mapping- Tor Control Protocol: MAPADDRESS
Structs§
- MapAddress
Response - Parsed response from the MAPADDRESS command.