Commit 2ae0422
committed
fix(egress): switch mitmproxy to connection_strategy=eager
Lazy was originally chosen so denied requests could short-circuit before
touching upstream, but in practice the egress policy defaults to allow and
denies only a small minority of requests. The savings on the deny path do
not justify the cost on the allow path: lazy checks the upstream connection
pool per-request, and on h1 keepalive sessions this exposes a stale-conn
race where the second request (e.g. POST /git-upload-pack right after
GET /info/refs) picks an upstream conn the peer has already closed,
surfacing as a silent transport error with no fatal output on the client.
Eager opens the upstream connection alongside the client connection, so
mitm's IO loop continuously observes upstream FIN/RST and a stale conn is
detected before the client's next request arrives. The cost is a wasted
TCP/TLS handshake for the small fraction of denied requests — acceptable
because a denied flow still short-circuits with `flow.response = ...`
before any HTTP write reaches upstream, so upstream sees no path / method /
headers, only an unfinished handshake.
Audited the bundled addons (system.py, custom.py): no hook depends on
lazy-only behavior (no server_connect routing, no flow.request.host
modification, no client-SNI-based upstream decisions).1 parent 2a91287 commit 2ae0422
1 file changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| |||
0 commit comments