parse_exit_list

Function parse_exit_list 

Source
pub fn parse_exit_list(content: &str) -> Result<Vec<TorDNSEL>, Error>
Expand description

Parses a complete TorDNSEL exit list file.

This function parses a file containing multiple exit list entries, returning a vector of all entries found.

§Arguments

  • content - The complete exit list file content as a string

§Returns

A vector of parsed TorDNSEL entries on success.

§Errors

Returns Error::Parse if any entry in the file is malformed. Parsing stops at the first error.

§Example

use stem_rs::descriptor::tordnsel::parse_exit_list;

let exit_list = r#"@type tordnsel 1.0
Downloaded 2024-01-01 00:00:00
ExitNode 003A71137D959748C8157C4A76ECA639CEF5E33E
Published 2024-01-01 12:00:00
ExitAddress 192.168.1.1 2024-01-01 13:30:00
ExitNode 00FF300624FECA7F40515C8D854EE925332580D6
Published 2024-01-01 11:00:00
ExitAddress 10.0.0.1 2024-01-01 12:30:00
"#;

let entries = parse_exit_list(exit_list)?;
assert_eq!(entries.len(), 2);