trojan-client
SOCKS5 proxy client that tunnels traffic through a Trojan protocol server.
Overview
This crate implements a local SOCKS5 proxy that forwards traffic over a TLS connection to a remote trojan-server:
- SOCKS5 proxy — Listens locally and accepts SOCKS5 CONNECT and UDP ASSOCIATE requests
- TLS transport — Connects to the remote server via TLS with configurable SNI and custom CA support
- TCP CONNECT — Proxies TCP connections with header coalescing for reduced round trips
- UDP ASSOCIATE — Full UDP relay with SOCKS5 encapsulation and idle timeout
- Graceful shutdown — CancellationToken-based shutdown with SIGTERM/SIGINT handling
Architecture
Application ──SOCKS5──▶ trojan-client ──TLS──▶ trojan-server ──▶ Target
│
┌───────────┼───────────┐
▼ ▼
TCP CONNECT UDP ASSOCIATE
(relay) (UDP relay loop)
Usage
As a binary (via main crate)
As a library
use ;
use CancellationToken;
let token = new;
run.await?;
Configuration
[]
= "127.0.0.1:1080"
= "server.example.com:443"
= "your-password"
[]
= "server.example.com"
= ["h2", "http/1.1"]
= false
# ca = "/path/to/ca.pem" # Custom CA certificate
[]
= true
= 60
[]
= "info"
= "pretty"
CLI Overrides
License
GPL-3.0-only