6 releases

0.0.5 Jan 6, 2021
0.0.4 Sep 9, 2020
0.0.2 Jul 27, 2020
0.0.1 May 26, 2020

#28 in #sock


Used in 5 crates (via koibumi-node)

GPL-3.0-or-later

38KB
772 lines

This crate is a minimal SOCKS5 client library.

The library is usable in async context. The library is intended to be used with a local Tor SOCKS5 proxy.


lib.rs:

This crate is a minimal SOCKS5 client library.

The library is usable in async context. The library is intended to be used with a local Tor SOCKS5 proxy.

Examples

Connect to the web server at example.org:80 via a local Tor SOCKS5 proxy at 127.0.0.1:9050, issue a GET command, read and print the response:

#
use async_std::{
    io::{prelude::WriteExt, ReadExt},
    net::TcpStream,
};
use koibumi_net::{
    domain::{Domain, SocketDomain},
    socks::SocketAddr as SocksSocketAddr,
};
use koibumi_socks as socks;

let mut stream = TcpStream::connect("127.0.0.1:9050").await?;

let destination = SocksSocketAddr::Domain(
    SocketDomain::new(
        Domain::new("example.org").unwrap(), 80.into()));

let _dest = socks::connect(&mut stream, destination).await?;

stream.write_all(b"GET /\n").await?;

let mut bytes = Vec::new();
stream.read_to_end(&mut bytes).await?;
print!("{}", String::from_utf8_lossy(&bytes));
#

Dependencies

~1MB
~16K SLoC