Crate tor_stream[][src]

Expand description

Provides an interface for proxying network streams over the Tor network.

See setup for information on creating a local Tor SOCKS5 proxy.


If your Tor proxy is running on the default address, you can use TorStream::connect(). If that is not the case, you can specify your address in a call to TorStream::connect_with_address().

use tor_stream::TorStream;
use std::io::prelude::*;

let mut stream = TorStream::connect("").expect("Failed to connect");

// The stream can be used like a normal TCP stream

stream.write_all(b"GET / HTTP/1.1\r\nConnection: Close\r\nHost:\r\n\r\n").expect("Failed to send request");

// If you want the raw stream, call `into_inner()`

let mut stream = stream.into_inner();

let mut buf = String::new();
stream.read_to_string(&mut buf).expect("Failed to read response");

println!("Server response:\n{}", buf);


This crate is mostly a wrapper about Steven Fackler’s socks crate.


pub extern crate socks;


Instructions on setting up a local Tor proxy


The default TOR socks5 proxy address, The proxy can be configured in the SOCKS section of /etc/tor/torrc. See the TOR manual for more information on torrc.

A stream proxied over the Tor network. After connecting, it can be used like a normal TcpStream.


A trait for objects that can be converted to TargetAddr.