MCPcopy Index your code
hub / github.com/dizda/fast-socks5

github.com/dizda/fast-socks5 @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
215 symbols 437 edges 15 files 68 documented · 32% updated 5mo agov1.0.0 · 2026-01-20★ 6142 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

License crates.io dependency status Release

anyIP Logo

Fast SOCKS5 TCP and UDP client/server library for Rust async (Tokio)


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
  • Exhaustive examples are provided that can be run immediately:
  • client
  • server
  • custom_auth_server
  • router
  • udp_client

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

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/

Inspired by

Thanks to all these SOCKS5 projects

  • https://github.com/sfackler/rust-socks/blob/master/src/v5.rs
  • https://github.com/shadowsocks/shadowsocks-rust/blob/master/src/relay/socks5.rs
  • https://github.com/ylxdzsw/v2socks/blob/master/src/socks.rs

Further Considerations

  • Implementation made with Tokio-codec https://github.com/yfaming/yimu-rs/blob/master/src/socks5.rs

Extension points exported contracts — how you extend this code

ToTargetAddr (Interface)
A trait for objects that can be converted to `TargetAddr`. [8 implementers]
src/util/target_addr.rs
AuthMethodSuccessState (Interface)
A trait for the final successful state of an authentication method's implementation. This allows `Socks5ServerProtocol< [3 …
src/server.rs
AuthMethod (Interface)
A metadata trait for authentication methods, essentially binding an ID value (as used in the method negotiation) to an a [3 …
src/server.rs
Authentication (Interface)
(no doc) [3 implementers]
src/server.rs
CheckResult (Interface)
(no doc) [3 implementers]
src/server.rs
ErrorContext (Interface)
(no doc) [2 implementers]
src/server.rs

Core symbols most depended-on inside this repo

err_when
called by 28
src/server.rs
accept
called by 9
src/server.rs
init
called by 8
src/lib.rs
finish_auth
called by 7
src/server.rs
reply_error
called by 7
src/server.rs
to_socket_addrs
called by 7
src/util/target_addr.rs
recv_from
called by 6
src/client.rs
to_be_bytes
called by 6
src/util/target_addr.rs

Shape

Method 108
Function 55
Class 31
Enum 14
Interface 7

Languages

Rust99%
Python1%

Modules by API surface

src/server.rs85 symbols
src/client.rs34 symbols
src/socks4/client.rs19 symbols
src/lib.rs17 symbols
src/util/target_addr.rs14 symbols
examples/custom_auth_server.rs12 symbols
examples/server.rs7 symbols
examples/router.rs7 symbols
src/util/stream.rs4 symbols
src/socks4/mod.rs4 symbols
examples/udp_client.rs4 symbols
examples/client.rs4 symbols

For agents

$ claude mcp add fast-socks5 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact