Files
rustunnel/droid-wiki/systems/socks5-proxy.md
T
rootandfactory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> 0166fb6511
CI / cargo fmt (push) Has been cancelled
CI / cargo clippy (macos-latest) (push) Has been cancelled
CI / cargo clippy (ubuntu-latest) (push) Has been cancelled
CI / cargo clippy (windows-latest) (push) Has been cancelled
CI / cargo test (macos-latest) (push) Has been cancelled
CI / cargo test (ubuntu-latest) (push) Has been cancelled
CI / cargo test (windows-latest) (push) Has been cancelled
CI / cargo build (macos-latest) (push) Has been cancelled
CI / cargo build (ubuntu-latest) (push) Has been cancelled
CI / cargo build (windows-latest) (push) Has been cancelled
CI / cargo build --release (macos-latest) (push) Has been cancelled
CI / cargo build --release (ubuntu-latest) (push) Has been cancelled
CI / cargo build --release (windows-latest) (push) Has been cancelled
CI / CLI smoke (macos-latest) (push) Has been cancelled
CI / CLI smoke (ubuntu-latest) (push) Has been cancelled
CI / CLI smoke (windows-latest) (push) Has been cancelled
CI / Minimal E2E (macos-latest) (push) Has been cancelled
CI / Minimal E2E (ubuntu-latest) (push) Has been cancelled
CI / Minimal E2E (windows-latest) (push) Has been cancelled
docs: add comprehensive project wiki for v1.0
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-06-04 14:07:55 -06:00

1.8 KiB

SOCKS5 proxy

The SOCKS5 module in src/socks5.rs implements RFC 1928 (SOCKS5 protocol) and RFC 1929 (username/password authentication).

Purpose

Handle the SOCKS5 handshake on the connector side, parse CONNECT requests, and resolve target addresses so that local applications can forward traffic through the tunnel.

Supported features

  • CONNECT command only (no BIND or UDP)
  • No-auth and username/password authentication methods
  • IPv4 and domain name targets (no IPv6)
  • Target DNS resolution on the connector side

Key abstractions

Type File Description
Socks5Target src/socks5.rs Enum: Ipv4(addr, port) or Domain { domain, port }
Socks5State src/socks5.rs State machine: ExpectGreeting → ExpectAuth → ExpectRequest → RequestReceived → Established → Closed
Socks5Error src/socks5.rs Error enum for malformed input, unsupported methods, and parse failures
parse_greeting src/socks5.rs Parse client greeting and choose auth method
parse_auth_request src/socks5.rs Parse username/password auth request
parse_connect_request src/socks5.rs Parse CONNECT request and extract target
resolve_target src/socks5.rs Async DNS resolution of a Socks5Target to a SocketAddr

Integration

The connector's run_socks5_proxy in src/tunnel.rs calls socks5_handshake (an async function in src/tunnel.rs that uses src/socks5.rs constants and helpers) for each incoming SOCKS5 connection. After handshake, it opens a stream via StreamMux::open_stream and forwards data bidirectionally.

Key source files

File Purpose
src/socks5.rs SOCKS5 protocol constants, parsing, target resolution
src/tunnel.rs Async SOCKS5 handshake and proxy integration