# Code review: terminal TLS MITM proxy in Rust (ratatui, tokio, rcgen, rustls)

**URL:** <https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027>\
**Category:** code review\
**Created:** [June 30, 2026, 9:32pm UTC](https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027 "2026-06-30T21:32:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingkongcastle](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kingkongcastle/32/53119_2.png) [@kingkongcastle](https://users.rust-lang.org/u/kingkongcastle)\
**Post date:** [June 30, 2026, 9:32pm UTC](https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027/1 "2026-06-30T21:32:48Z")

</div>

I've been building Cogitator, a terminal-based TLS MITM intercepting  
proxy in Rust, primarily as a learning project for both network security  
and the language itself. Would appreciate any feedback on architecture  
and Rust-specific decisions.

**Core stack:**

- `tokio 1` (full) — async runtime for the proxy core
- `ratatui 0.26` + `crossterm` — TUI with 6 screens
- `rcgen 0.13` — on-the-fly per-domain leaf certificate signing
- `rustls 0.23` + `tokio-rustls 0.26` + `webpki-roots` — TLS stack
- `hyper 1.0` + `hyper-util` + `http-body-util` — HTTP layer
- `reqwest 0.12` — outbound requests (brotli/gzip/deflate)
- `libloading` + `inventory` — external `.so` plugin system
- `tracing` + `tracing-subscriber` (json) — structured logging
- `hickory-client` — DNS queries

**Decisions I'm unsure about and would love feedback on:**

- Coexisting the async proxy core with the synchronous ratatui event  
loop via `block_in_place` / `spawn_blocking` — is there a cleaner  
pattern for this?
- Per-domain `TlsAcceptor` cache behind `Arc<Mutex<HashMap>>` —  
worth switching to `DashMap`?
- Using `hyper 1.0` directly alongside `reqwest 0.12` (which uses  
hyper internally) — is there redundancy here worth cleaning up?
- `SiteAnalyzer` trait for DI in the proxy pipeline — does this feel  
idiomatic or over-engineered for this scale?

**What it does:**

- TLS MITM with ALPN/HTTP2, WebSocket interception (RFC 6455)
- Frozen mode — pause live requests, edit headers/body, forward/drop
- Active scanner: SQLi (error-based), XSS (reflected/stored),  
Path Traversal
- Repeater, Intruder (Sniper/BatteringRam/Pitchfork/ClusterBomb),  
BFS Spider
- Plugin system with versioned ABI via `cogitator-plugin-api` crate

GitHub: [GitHub - LeechoShoop/cogitator: Terminal TLS MITM intercepting proxy and web security toolkit written in Rust · GitHub](https://github.com/LeechoShoop/cogitator)

---

<div class="post-metadata">

**Author:** ![seantiz](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/seantiz/32/53128_2.png) [@seantiz](https://users.rust-lang.org/u/seantiz)\
**Post date:** [July 1, 2026, 6:26am UTC](https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027/2 "2026-07-01T06:26:45Z")

</div>

I'll be honest, I don't know what those acronyms mean and I can't comment on the stack. I'd done a lot of work on mitm proxies a while back and the biggest feature gap between MITM Proxy (in Python) and building in Rust is the scripting.

It's a problem that the Proxelar crate ran into and decided to solve by bringing in Lua scripts. So my advice would be to build the well-covered territory until you get to that point, then decide what you want to do about scripting. Have fun!

---

<div class="post-metadata">

**Author:** ![kingkongcastle](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kingkongcastle/32/53119_2.png) [@kingkongcastle](https://users.rust-lang.org/u/kingkongcastle)\
**Post date:** [July 1, 2026, 8:38am UTC](https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027/3 "2026-07-01T08:38:08Z")

</div>

Thanks for taking a look at my project, seantiz! It's more of a  
research exploration into what Rust can do for this kind of tooling  
than a finished product.

Scripting and plugins are actually already on my roadmap — Cogitator  
has a plugin system via a separate `cogitator-plugin-api` crate with  
a versioned ABI and dynamic `.so` loading. Not as frictionless as  
Python scripts yet, but the foundation is there.

The Lua idea is interesting — a much lighter path for quick request  
manipulation without writing a full Rust plugin. I'll definitely keep  
it in mind for a future release. Appreciate the insight!

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [September 29, 2026, 8:38am UTC](https://users.rust-lang.org/t/code-review-terminal-tls-mitm-proxy-in-rust-ratatui-tokio-rcgen-rustls/141027/4 "2026-09-29T08:38:27Z")

</div>

Closed on September 29, 2026, 8:38am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
