Module tordnsel

Module tordnsel 

Source
Expand description

TorDNSEL exit list parsing.

This module parses exit list files from TorDNSEL (Tor DNS-based Exit List). These files contain information about Tor exit nodes and the IP addresses they use when exiting to the internet.

§Overview

TorDNSEL is a service that tracks which IP addresses are used by Tor exit nodes. This information is useful for:

  • Identifying traffic originating from Tor exit nodes
  • Implementing access controls based on Tor usage
  • Research and analysis of the Tor network

Exit lists are published periodically and contain entries for each known exit relay, including:

  • The relay’s fingerprint (identity)
  • When the relay was last seen in the consensus
  • The IP addresses the relay uses for exiting

§File Format

Exit list files follow this format:

@type tordnsel 1.0
Downloaded 2024-01-01 00:00:00
ExitNode <40 hex fingerprint>
Published <YYYY-MM-DD HH:MM:SS>
LastStatus <YYYY-MM-DD HH:MM:SS>
ExitAddress <IPv4 address> <YYYY-MM-DD HH:MM:SS>
ExitAddress <IPv4 address> <YYYY-MM-DD HH:MM:SS>
ExitNode <40 hex fingerprint>
...

§Example

use stem_rs::descriptor::tordnsel::{TorDNSEL, parse_exit_list};

let exit_list = 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
ExitNode 00FF300624FECA7F40515C8D854EE925332580D6
Published 2024-01-01 11:00:00
LastStatus 2024-01-01 12: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);

for entry in &entries {
    println!("Exit node: {}", entry.fingerprint);
    for (addr, date) in &entry.exit_addresses {
        println!("  Exit address: {} (seen {})", addr, date);
    }
}

§Data Source

Exit lists can be obtained from:

§See Also

  • server: Server descriptors with full relay information
  • consensus: Network status documents
  • remote: Downloading descriptors from the network

Structs§

TorDNSEL
A TorDNSEL exit list entry for a single relay.

Functions§

parse_exit_list
Parses a complete TorDNSEL exit list file.
parse_exit_list_bytes
Parses a complete TorDNSEL exit list file from raw bytes.