A high-performance proxy server written in Rust with configurable connection caching.
- TCP Proxy: Forward TCP connections to target servers
- HTTP Proxy: Forward HTTP requests to target servers
- SOCKS5 Proxy: Full SOCKS5 server with optional authentication
- Connection Caching: Configurable connection pooling to improve performance
- Async/Await: Built with Tokio for high-performance async networking
- Flexible Configuration: Command-line configuration with sensible defaults
Make sure you have Rust installed, then build the project:
cargo build --releaserustproxy --listen <address:port> [--target <address:port>] --mode <tcp|http|socks5> [--cache-size <size>] [--socks5-auth <user:pass>]--listen <address:port>- Address to listen on--target <address:port>- Address to proxy requests to (required for tcp mode only)--mode <tcp|http|socks5>- Proxy mode--cache-size <size>- Connection cache size (default: 256KB)- Examples:
0,none,256kb,1mb,8mb
- Examples:
--socks5-auth <user:pass>- SOCKS5 authentication credentials (optional)
TCP Proxy with default caching (256KB):
rustproxy --listen 127.0.0.1:8080 --target 192.168.1.100:9000 --mode tcpTCP Proxy with 1MB connection cache:
rustproxy --listen 127.0.0.1:8080 --target 192.168.1.100:9000 --mode tcp --cache-size 1mbTCP Proxy with caching disabled:
rustproxy --listen 127.0.0.1:8080 --target 192.168.1.100:9000 --mode tcp --cache-size 0HTTP Proxy (local server, no forwarding):
rustproxy --listen 127.0.0.1:8080 --mode httpSOCKS5 Proxy (no authentication):
rustproxy --listen 127.0.0.1:1080 --mode socks5SOCKS5 Proxy with authentication:
rustproxy --listen 127.0.0.1:1080 --mode socks5 --socks5-auth username:passwordSOCKS5 Proxy with custom cache size:
rustproxy --listen 127.0.0.1:1080 --mode socks5 --cache-size 2mb- TCP Proxy (
src/tcp_proxy.rs): Handles raw TCP connection forwarding - HTTP Proxy (
src/http_proxy.rs): Handles HTTP request/response forwarding - SOCKS5 Proxy (
src/socks5_proxy.rs): Full SOCKS5 server implementation with authentication support - Connection Cache (
src/connection_cache.rs): Manages connection pooling for performance optimization - Main (
src/main.rs): Command-line interface and application startup
- Protocol Compliance: Full SOCKS5 protocol implementation (RFC 1928)
- Authentication Methods:
- No authentication (anonymous access)
- Username/password authentication (RFC 1929)
- Connection Types: CONNECT command support (most common use case)
- Address Types: IPv4, IPv6, and domain name resolution
- Connection Caching: Reuse connections for improved performance
- Error Handling: Proper SOCKS5 error responses for various failure conditions
To use the SOCKS5 proxy with various applications:
cURL:
curl --socks5 127.0.0.1:1080 https://example.com
curl --socks5-hostname 127.0.0.1:1080 https://example.com # DNS through proxySSH:
ssh -o ProxyCommand='nc -X 5 -x 127.0.0.1:1080 %h %p' user@target.comFirefox:
- Go to Settings → Network Settings → Manual proxy configuration
- Set SOCKS Host: 127.0.0.1, Port: 1080, SOCKS v5
Environment Variables:
export ALL_PROXY=socks5://127.0.0.1:1080
export all_proxy=socks5://127.0.0.1:1080Quick validation:
./test_simple.shUnit tests only:
cargo testComprehensive integration tests:
./test_all.shcargo bench- tokio: Async runtime
- hyper: HTTP client/server library
- tracing: Structured logging
- bytes: Byte buffer utilities
- futures-util: Future utilities
[Add your license information here]