A high-performance HTTP proxy written in Rust, designed for learning systems programming concepts.
- HTTP/1.1 Forward Proxy: Routes HTTP traffic between clients and target servers
- HTTPS CONNECT Tunneling: Full support for HTTPS via HTTP CONNECT method
- Async I/O: Built with Tokio for high-performance concurrent connections
- Connection Limiting: Configurable maximum connection limits with semaphore-based throttling
- Timeout Management: Configurable timeouts for all network operations
- Configuration System: TOML-based configuration with CLI overrides
- Structured Logging: Comprehensive request/response logging with configurable levels
cargo build --releaseBasic usage (listens on localhost:8080):
cargo runWith custom port and connection limit:
cargo run -- --port 9000 --max-connections 200With configuration file:
cargo run -- --config proxy.tomlUsing curl:
curl -x http://localhost:8080 http://httpbin.org/getUsing Python test script:
python test_proxy.pyCreate a proxy.toml file:
[server]
host = "127.0.0.1"
port = 8080
max_connections = 100
timeout_seconds = 30
[upstream]
default_target = "httpbin.org:80"-p, --port <PORT>: Port to listen on (default: 8080)-h, --host <HOST>: Host to bind to (default: 127.0.0.1)-t, --target <TARGET>: Default target server URL-l, --log-level <LEVEL>: Log level (default: info)--config <FILE>: Configuration file path--max-connections <NUM>: Maximum concurrent connections (default: 100)
+--------+ +------------+ +-----------+
| Client | ----> | Tachyon | ----> | Target |
| (curl) | <---- | Proxy | <---- | Server |
+--------+ +------------+ +-----------+
- Client sends HTTP request to the proxy
- Proxy parses the request and forwards it to the target server
- Target Server responds
- Proxy relays the response back to the client
src/
├── main.rs # CLI setup and startup
├── proxy.rs # Core proxy logic
├── http.rs # HTTP parsing
└── config.rs # Configuration management
- Async I/O: Non-blocking network operations with Tokio
- Connection Limiting: Semaphore-based connection throttling
- Timeout Management: Prevents hanging connections
- Memory Efficiency: Bounded buffers and efficient parsing
This project demonstrates:
- Low-level Networking: TCP socket management and HTTP protocol parsing
- Concurrency: Handling multiple client connections simultaneously
- Systems Programming: Memory management, error handling, and performance optimization
- Rust Async: Working with Tokio runtime and async/await patterns
cargo testcargo fmtcargo clippyMIT License