Crates.io | socksprox |
lib.rs | socksprox |
version | 0.1.1 |
source | src |
created_at | 2024-02-07 23:21:05.242366 |
updated_at | 2024-02-07 23:29:58.801293 |
description | Simple SOCKS5 Proxy Server in Rust. Probably shouldn't use this, but you can. |
homepage | |
repository | https://github.com/carterburn/socksprox |
max_upload_size | |
id | 1131083 |
size | 66,026 |
Simple SOCKS5 Proxy Server in Rust. Probably shouldn't use this, but you can.
A super simple, feature-lacking async SOCKS5 server. Currently only supports the CONNECT command (TCP) and limited authentication (Username/Password). No authentication is also supported.
Why would you want to use this? You probably don't, better implementations exist. BUT if you want a straightforward, easy-to-use SOCKS5 library, well, you found it. This can be used (along with the provided binary) to quickly and easily deploy a SOCKS5 Server.
To use in your own binary, all you need is the tokio runtime. Using anyhow for errors is also convienent to easily handle errors provided by the library. The main function for the binary in it's nascent stages looked something like this:
use socksprox::Socks5Server;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut server = match Socks5Server::new("0.0.0.0", 4444, None, None).await {
Ok(s) => s,
Err(e) => { return Err(anyhow::anyhow!("Error starting server: {e}")); }
};
server.serve().await;
Ok(())
}
Add the library to your project to be able to quickly add a Socks5 proxy to your existing code with:
cargo add socksprox
If you want to run the provided binary, use cargo
to install it:
cargo install socksprox
To build from source (which you technically do with cargo install
):
git clone https://github.com/carterburn/socksprox.git
cd socksprox
cargo build --release
Compiling for different OS / architectures can be done using standard cargo
arguments if you have the requisite Rust toolchain installed.
PR's are definitely welcome. Feautres that could be nice:
I sought some help from merino (another SOCKS5 implementation in Rust) that can be found here. The design is roughly the same with some tweaks here or there that I added. The 'additions' that I added are probably not correct or industry standard, but gave it my best shot. If clippy didn't complain, it's perfect in my opinion.
The RFC for SOCKS5 is very easy to understand as well, so it was a good first stab at implementing a network protocol in Rust. RFC1928
I am trying to learn how to use tokio and needed something small that I could start working toward. 🧑🔧 Hoping to put out better projects using tokio in the future. Have to start somewhere.