Skip to content

Proxy engine: persistent CA, capped capture, upgrade tunnel - #750

Merged
gschier merged 2 commits into
mainfrom
t3code/proxy-engine-v1
Oct 14, 2026
Merged

gschier merged 2 commits into
mainfrom
t3code/proxy-engine-v1

Conversation

@gschier

@gschier gschier commented Oct 14, 2026

Copy link
Copy Markdown
Member

First engine PR for Yaak Proxy (crates/yaak-proxy).

  • CaStore::load_or_create(dir) persists the CA (ca.pem, ca.key at 0600, CN "Yaak Proxy CA", 10 years). Leaf certs are 365 days with serverAuth EKU, picked by SNI.
  • start_proxy(ProxyConfig { port, ca, capture_body_limit, upstream_root_certs }). Client-facing ALPN is http/1.1 only; upstream still negotiates h2 or h1.
  • Bodies stream in both directions. RequestBodyChunk / ResponseBodyChunk events carry each frame's bytes up to the cap (10 MB default); completion events carry size, truncated, timing and error. The engine stores nothing.
  • Upgrade requests inside CONNECT are spliced into a blind tunnel after the 101. Non-TLS CONNECT payloads, and hosts whose client rejected the TLS handshake (pinning), are tunneled without interception.
  • Flow metadata: started_at, elapsed to headers and to end, sizes, HTTP versions on both sides, remote address, error. log replaces eprintln!.
  • yaak-proxy-lib is only adapted to the new API.

CI already builds yaak-app-proxy (cargo test --all) and type-checks apps/yaak-proxy (npm run lint), so ci.yml is unchanged.

Tests (cargo test -p yaak-proxy), against a local HTTPS server signed by a throwaway CA:

  • CA persisted, reloaded, key mode 0600
  • HTTPS GET (upstream HTTP/2, remote address, timings)
  • POST with a body
  • 404
  • request and response bodies over the cap: truncated capture, full delivery
  • WebSocket upgrade passes through
  • pinned client falls back to passthrough
  • plain HTTP GET
  • unreachable upstream: 502 and an Error event

@gschier
gschier marked this pull request as ready for review October 14, 2026 17:30
@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge, with no new actionable issues or outstanding previous findings.

Summary

The PR adds a saved CA, streamed body capture with a size cap, and blind tunnels for upgrades and traffic that cannot be inspected.

  • Yaak Proxy keeps its certificate authority across restarts.
  • Proxy bodies stream through while captured copies stay capped.
  • CONNECT connections can pass through or switch to upgraded streams.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Client[Client] --> Proxy[Local proxy]
  Proxy --> Plain[Plain HTTP]
  Proxy --> Connect[CONNECT]
  Connect --> Inspect[Inspect HTTPS]
  Connect --> Blind[Blind tunnel]
  Inspect --> Upgrade[101 upgrade tunnel]
  Plain --> Capture[Capped body events]
  Inspect --> Capture
  Capture --> Adapter[Save exchange and errors]
Loading

Reviews (2) 路 Last reviewed commit: "Address review: server-first tunnels, pa..." 路 Reviewed by Greptile

Comment thread crates/yaak-proxy/src/request.rs Outdated
Comment thread crates/yaak-proxy/src/request.rs Outdated
Comment thread crates-proxy/yaak-proxy-lib/src/lib.rs Outdated
Comment thread crates-proxy/yaak-proxy-lib/src/lib.rs
Comment thread crates/yaak-proxy/src/cert.rs Outdated
@gschier

gschier commented Oct 14, 2026

Copy link
Copy Markdown
Member Author

@greptileai review

@gschier
gschier merged commit 694c027 into main Oct 14, 2026
6 checks passed
@gschier
gschier deleted the t3code/proxy-engine-v1 branch October 14, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant