Tor control protocol
for Rust.
A complete Rust implementation of the Tor control protocol. Connect to Tor, authenticate with any method, query network information, and subscribe to real-time events.
Everything you need to control Tor
A complete toolkit for building Tor-integrated applications with idiomatic Rust patterns and comprehensive type safety.
Control Socket
Connect to Tor via TCP or Unix domain sockets. Full async I/O with Tokio integration for high-performance applications.
Authentication
All authentication methods with automatic detection. Secure credential handling with constant-time comparison.
Controller API
High-level interface for Tor interaction. Query configuration, send signals, manage circuits, and control hidden services.
Descriptor Parsing
Complete parsing for all Tor descriptor types. Server, micro, consensus, extra-info, and hidden service descriptors.
Event Handling
Subscribe to real-time Tor events. Monitor bandwidth, circuit status, stream events, and log messages as they happen.
Exit Policy
Parse and evaluate exit policies. Determine what traffic a relay allows and make informed routing decisions.
Up and running in minutes
Clear, well-documented examples to get you started with the most common use cases.
use stem::{ConnectOptions, connect};
#[tokio::main]
async fn main() -> stem::Result<()> {
let controller = connect(ConnectOptions::default()).await?;
println!("Connected to Tor!");
Ok(())
}let version = controller.get_version().await?;
println!("Tor version: {version}");
let bytes_read = controller.get_info("traffic/read").await?;
let bytes_written = controller.get_info("traffic/written").await?;
let circuits = controller.get_circuits().await?;use stem::events::EventType;
let (_, mut events) = controller
.subscribe(&[EventType::Bw, EventType::Circ])
.await?;
while let Some(event) = events.recv().await {
println!("{} {:?}", event.event_type, event.data);
}Explore the modules
Comprehensive documentation with examples for every module and function.