Building a Transparent Proxy in Rust: The Foundation Behind Lens
When debugging distributed applications locally, understanding how requests move between services can be surprisingly difficult.
A single request may involve an API server, authentication service, database, cache, and external APIs. Reconstructing that path often means piecing together logs from multiple places.
That's the motivation behind Lens, an open-source Rust project I'm building.
Why a Transparent Proxy?
Rather than requiring instrumentation in every application, Lens is designed around a transparent proxy architecture.
This approach allows it to observe requests and responses while remaining independent of application logic.
The long-term goals include:
- Visualizing request flows
- Decoding application protocols
- Measuring latency
- Redacting sensitive information
- Supporting multiple protocols through a modular architecture
Why Rust?
Rust provides the combination of performance, memory safety, and async networking support that a project like Lens needs.
Tokio, Cargo workspaces, and Rust's type system have made it possible to design the project around small, focused crates.
Current Progress
The project currently includes:
- Transparent proxy architecture
- HTTP/1.1 support
- PostgreSQL protocol decoding
- Secret redaction
- Cross-platform architecture
- Interactive terminal UI (in progress)
The next milestone is implementing additional protocol support and expanding the runtime.
Looking for Feedback
If you've built networking tools, proxies, or protocol parsers in Rust, I'd genuinely appreciate feedback on the architecture.
Repository:
Top comments (0)