Simplify SSH tunneling and honor system HTTPS proxies (#61975)

## What changed

- Make `codex tcp-tunnel` an SSH stdio helper, removing the loopback listener, stdin control protocol, and JSON diagnostics.
- Add `--token-file` for one-use credentials, consumed only after gateway verification, with environment-based OAuth routing or a legacy IPv4 `--target`.
- Honor system HTTPS proxy settings without attempting direct QUIC, and keep gateway credentials inside verified TLS.
- Race direct TCP addresses through TLS and HTTP/2 readiness so stalled peers do not block a working address.

## Testing

Add coverage for proxy credential isolation and stalled TLS peers, plus an opt-in Linux OpenSSH integration test for complete uploads and remote exit while local stdin remains open.

GitOrigin-RevId: 62423c8a8267842c9e401b3f9094c7278c47a490
This commit is contained in:
richardopenai
2026-11-17 06:03:45 +00:00
committed by copyberry
parent 9a5a78925d
commit 98323eddf9
16 changed files with 597 additions and 1697 deletions
+8 -22
View File
@@ -1164,8 +1164,8 @@ async fn dispatch_cli(
arg0_paths,
)));
}
Some(Subcommand::TcpTunnel(args)) if args.auth_token_stdin => {
codex_tcp_tunnel::run(args).await?;
Some(Subcommand::TcpTunnel(args)) if args.token_file.is_some() => {
codex_tcp_tunnel::run_ssh_proxy_from_file(args, tokio::io::stdout()).await?;
}
Some(Subcommand::TcpTunnel(args)) => {
let config =
@@ -3516,32 +3516,18 @@ enabled = true
}
#[test]
fn tcp_tunnel_is_hidden_and_accepts_its_control_input_contract() {
fn tcp_tunnel_is_hidden_and_accepts_an_ssh_proxy_route() {
let root_help = help_from_args(&["codex", "--help"]);
assert!(!root_help.contains("tcp-tunnel"), "{root_help}");
let help = help_from_args(&["codex", "tcp-tunnel", "--help"]);
for option in [
"--target",
"--auth-token-stdin",
"--auth-token-updates-stdin",
"--connect-headers-stdin",
] {
assert!(help.contains(option), "{help}");
}
let cli = MultitoolCli::try_parse_from([
"codex",
"tcp-tunnel",
"--proxy-url",
"https://proxy.example.org",
"--proxy-origins-file",
"/tmp/approved-origins",
"--target",
"[::1]:22",
"--auth-token-stdin",
"--auth-token-updates-stdin",
"--connect-headers-stdin",
"--environment-id",
"ccarenv_test",
"--token-file",
"/private/token",
])
.expect("generic tunnel should parse");
.expect("SSH proxy route should parse");
assert!(matches!(cli.subcommand, Some(Subcommand::TcpTunnel(_))));
}