25 releases

1.0.0-beta.2 Feb 6, 2025
0.10.0 Dec 18, 2024
0.9.6 Mar 25, 2024
0.9.2 Nov 30, 2023
0.3.0 Jan 19, 2020

#101 in Network programming

Download history 8166/week @ 2024-10-28 7849/week @ 2024-11-04 8109/week @ 2024-11-11 8966/week @ 2024-11-18 9819/week @ 2024-11-25 9512/week @ 2024-12-02 10527/week @ 2024-12-09 10125/week @ 2024-12-16 3010/week @ 2024-12-23 4025/week @ 2024-12-30 8278/week @ 2025-01-06 9180/week @ 2025-01-13 9432/week @ 2025-01-20 8729/week @ 2025-01-27 9756/week @ 2025-02-03 8987/week @ 2025-02-10

37,482 downloads per month
Used in 15 crates (8 directly)

MIT license

120KB
2.5K 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 the Tokio runtime
  • Ultra lightweight and scalable
  • No system dependencies
  • Cross-platform
  • Infinitely extensible, explicit server API based on typestates for safety
    • You control the request handling, the library only ensures you follow the proper protocol flow
    • Can skip DNS resolution
    • Can skip the authentication/handshake process (not RFC-compliant, for private use, to save on useless round-trips)
    • Instead of proxying in-process, swap out run_tcp_proxy for custom handling to build a router or to use a custom accelerated proxying method
  • Authentication methods:
    • No-Auth method (0x00)
    • Username/Password auth method (0x02)
    • Custom auth methods can be implemented on the server side via the AuthMethod Trait
      • Multiple auth methods with runtime negotiation can be supported, with fast static dispatch (enums can be generated with the auth_method_enums macro)
  • UDP is supported
  • All SOCKS5 RFC errors (replies) should be mapped
  • IPv4, IPv6, and Domains types are supported

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

Inspired by

Thanks to all these SOCKS5 projects

Further consideration

Dependencies

~3–11MB
~119K SLoC