Yaak Proxy: dial the server before answering a CONNECT

The engine now opens the TCP connection to a CONNECT's server before it
answers. When the server can't be reached, the CONNECT gets a 502 (or a
504 on a timeout) and the client reports its own connection error, rather
than a 200 followed by a 502 inside the decrypted session or a silent
hang-up in a tunnel. The failure is recorded as one error flow.

The dialled connection is handed to the tunnel, or to the first upstream
connection of a decrypted one, so nothing is dialled twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gregory SchierandClaude Opus 5.5 authored and Stetta task tk_mwi0jnakj4erard0 committed 2026-11-15 09:25:53 -07:00
1 parent 649549482c
commit ea288ec074
14 files changed
+889 -106

No files matched your search

+14 -1
View File
@@ -4,7 +4,7 @@ import { fixtures } from "./fixtures";
/**
* Dev only: traffic for HTTPS decryption's states, by `?scene=`: `encrypted`, the first minute
* with nothing decrypted, and `mixed`, some decrypted, a refused handshake and the tunnel passed
* through after it.
* through after it, and a server that could not be reached.
*/
export type HttpsScene = "encrypted" | "mixed";
@@ -169,6 +169,19 @@ function mixedScene(): Flow[] {
}),
decrypted(9, 0, "https://api.typefully.com/v1/drafts", apps.dia),
tunnel(10, "www.google.com", apps.dia, { elapsedMs: null }),
{
...tunnel(11, "jig3d.com", apps.dia),
method: "",
url: "https://jig3d.com",
tunnelled: false,
tunnelReason: null,
error:
"DNS lookup failed: failed to lookup address information: nodename nor servname provided, or not known",
elapsedMs: 3,
remoteAddr: null,
requestSize: 0,
responseSize: 0,
},
];
}