Add a hidden HTTP/3 TCP tunnel command (#45900)

## What changed

Add `codex tcp-tunnel` and the `codex-tcp-tunnel` crate to forward loopback TCP connections to an explicit target through a TLS-verified HTTP/3 CONNECT proxy.

- Require the proxy origin to match an approved HTTPS origin in a supplied policy file.
- Read bearer tokens and optional bounded, non-forwarding `x-` headers from stdin. Support token updates for new connections, `LISTENING` and `AUTH_UPDATED` notifications, and shutdown when the control pipe closes in token-update mode.
- Preserve the listener across proxy reconnects without replaying TCP streams, and let accepted streams continue while a proxy drains.

## Testing

Add tests for hidden CLI parsing, proxy and target validation, credential renewal, control-pipe closure, and invalid input without secret disclosure. A local HTTP/3 proxy test covers token replacement, transport recovery without stream replay, and graceful draining.

GitOrigin-RevId: c6af3025301c61e9fe90940cf5a6df0039465e69
This commit is contained in:
richardopenai authored and copyberry committed 2026-09-16 09:03:41 +00:00
1 parent 50d77959bf
commit 2aff7208fe
11 files changed
+1073

No files matched your search

+49
View File
@@ -2628,6 +2628,7 @@ dependencies = [
"codex-skills-extension",
"codex-state",
"codex-stdio-to-uds",
"codex-tcp-tunnel",
"codex-terminal-detection",
"codex-thread-store",
"codex-tui",
@@ -4634,6 +4635,27 @@ dependencies = [
"tokio",
]
[[package]]
name = "codex-tcp-tunnel"
version = "0.0.0"
dependencies = [
"anyhow",
"bytes",
"clap",
"h3",
"h3-quinn",
"http 1.4.0",
"pretty_assertions",
"quinn",
"rand 0.9.3",
"rcgen",
"rustls",
"rustls-native-certs",
"serde_json",
"tokio",
"url",
]
[[package]]
name = "codex-terminal-detection"
version = "0.0.0"
@@ -8468,6 +8490,32 @@ dependencies = [
"tracing",
]
[[package]]
name = "h3"
version = "0.0.8"
source = "git+https://github.com/hyperium/h3?rev=e07e69412876f7e26f026bd75a48b2704d8c8283#e07e69412876f7e26f026bd75a48b2704d8c8283"
dependencies = [
"bytes",
"fastrand",
"futures-util",
"http 1.4.0",
"pin-project-lite",
"tokio",
]
[[package]]
name = "h3-quinn"
version = "0.0.10"
source = "git+https://github.com/hyperium/h3?rev=e07e69412876f7e26f026bd75a48b2704d8c8283#e07e69412876f7e26f026bd75a48b2704d8c8283"
dependencies = [
"bytes",
"futures",
"h3",
"quinn",
"tokio",
"tokio-util",
]
[[package]]
name = "half"
version = "2.7.1"
@@ -12045,6 +12093,7 @@ checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20"
dependencies = [
"bytes",
"cfg_aliases 0.2.1",
"futures-io",
"pin-project-lite",
"quinn-proto",
"quinn-udp 0.5.14",