#async-await #vpn #proxy #sock #async #io

fast-socks5

Fast SOCKS5 client/server implementation written in Rust async/.await (tokio)

24 releases

0.9.6 Mar 25, 2024
0.9.2 Nov 30, 2023
0.8.2 Apr 3, 2023
0.8.1 Aug 25, 2022
0.3.0 Jan 19, 2020

#116 in Network programming

Download history 2479/week @ 2024-01-25 3008/week @ 2024-02-01 2536/week @ 2024-02-08 1994/week @ 2024-02-15 1989/week @ 2024-02-22 3003/week @ 2024-02-29 2462/week @ 2024-03-07 2872/week @ 2024-03-14 2680/week @ 2024-03-21 3721/week @ 2024-03-28 3213/week @ 2024-04-04 2993/week @ 2024-04-11 3085/week @ 2024-04-18 4707/week @ 2024-04-25 3281/week @ 2024-05-02 2940/week @ 2024-05-09

14,493 downloads per month
Used in 11 crates (5 directly)

MIT license

100KB
2K SLoC

SOCKS5 client/server library using async/.await

License crates.io dependency status Release

This library is maintained by anyip.io a residential and mobile socks5 proxy provider.

Features

  • An async/.await SOCKS5 implementation.
  • An async/.await SOCKS4 Client implementation.
  • An async/.await SOCKS4a Client implementation.
  • No unsafe code
  • Built on-top of tokio library
  • Ultra lightweight and scalable
  • No system dependencies
  • Cross-platform
  • Authentication methods:
    • No-Auth method
    • Username/Password auth method
    • Custom auth methods can be implemented via the Authentication Trait
    • Credentials returned on authentication success
  • All SOCKS5 RFC errors (replies) should be mapped
  • AsyncRead + AsyncWrite traits are implemented on Socks5Stream & Socks5Socket
  • IPv4, IPv6, and Domains types are supported
  • Config helper for Socks5Server
  • Helpers to run a Socks5Server à la "std's TcpStream" via incoming.next().await
  • Examples come with real cases commands scenarios
  • Can disable DNS resolving
  • Can skip the authentication/handshake process, which will directly handle command's request (useful to save useless round-trips in a current authenticated environment)
  • Can disable command execution (useful if you just want to forward the request to a different server)

Install

Open in crates.io.

Examples

Please check examples directory.

# Run client
RUST_LOG=debug cargo run --example client -- --socks-server 127.0.0.1:1337 --username admin --password password -a perdu.com -p 80

# Run server
RUST_LOG=debug cargo run --example server -- --listen-addr 127.0.0.1:1337 password -u admin -p password

# Test it with cURL
curl -v --proxy socks5://admin:password@127.0.0.1:1337 https://ipapi.co/json/

TODO

  • Tests have to be implemented
  • Better Rust doc
  • UDP bind command not implemented

Inspired by

Thanks to all these SOCKS5 projects

Further consideration

Dependencies

~3–15MB
~133K SLoC