#tor #proxy #networking

bin+lib tor-stream

Rust interface for proxying network streams over the Tor network

4 releases (2 breaking)

0.3.0 Jul 10, 2021
0.2.0 Apr 25, 2019
0.1.1 Feb 27, 2019
0.1.0 Feb 25, 2019

#70 in #tor

Download history 22/week @ 2024-01-13 9/week @ 2024-01-20 7/week @ 2024-01-27 12/week @ 2024-02-03 10/week @ 2024-02-10 2/week @ 2024-02-17 26/week @ 2024-02-24 21/week @ 2024-03-02 104/week @ 2024-03-09 29/week @ 2024-03-16 11/week @ 2024-03-23 47/week @ 2024-03-30 36/week @ 2024-04-06 25/week @ 2024-04-13 37/week @ 2024-04-20 49/week @ 2024-04-27

149 downloads per month
Used in phetch

MIT license

10KB
137 lines

tor-stream

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

See the documentation for more.


lib.rs:

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

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

Usage

If your Tor proxy is running on the default address 127.0.0.1:9050, 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("www.example.com:80").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: www.example.com\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);

Credits

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

Dependencies

~140–380KB