socks5-impl 0.8.1

Fundamental abstractions and async read / write functions for SOCKS5 protocol and Relatively low-level asynchronized SOCKS5 server implementation based on tokio
Documentation
use socks5_impl::{Result, client};
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufStream};
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<()> {
    let s5_proxy = TcpStream::connect("127.0.0.1:1080").await?;
    let mut stream = BufStream::new(s5_proxy);
    let addr = client::connect(&mut stream, ("google.com", 80), None).await?;
    println!("connected {addr}");

    // write http request
    let req = b"GET / HTTP/1.0\r\nHost: google.com\r\n\r\n";
    stream.write_all(req).await?;
    stream.flush().await?;

    // read http response
    let mut buf = vec![0; 1024];
    let n = stream.read(&mut buf).await?;
    println!("read {n} bytes");
    println!("{}", String::from_utf8_lossy(&buf[..n]));

    Ok(())
}