Crates.io | socks5-proxy |
lib.rs | socks5-proxy |
version | 0.1.1 |
source | src |
created_at | 2021-04-19 11:16:29.369324 |
updated_at | 2021-04-20 11:01:36.004385 |
description | socks5-proxy is a socks5 library based on tokio offering both server and client functions |
homepage | |
repository | https://github.com/0xacc/socks5-proxy |
max_upload_size | |
id | 386626 |
size | 18,920 |
socks5-proxy is a socks5 library based on tokio offering both server and client functions.
Add this to your Cargo.toml dependency
socks5-proxy = "0.1"
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"
use anyhow::Result;
use socks5_proxy::server;
#[tokio::main]
async fn main() -> Result<()> {
let s = server::new("127.0.0.1:8080".parse()?, None)?;
s.run().await?;
Ok(())
}
use anyhow::Result;
use socks5_proxy::{client, Addr};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
#[tokio::main]
async fn main() -> Result<()> {
let mut client = client::new(
"localhost:1080",
&Addr::HostnamePort("www.google.com:80".into()),
None,
)
.await?;
client.write_all(b"GET / HTTP/1.0\r\n\r\n").await?;
let mut buffer = Vec::new();
client.read_to_end(&mut buffer).await?;
println!("{}", String::from_utf8_lossy(&buffer));
Ok(())
}
All kinds of issues and PRs are welcome!