mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## What changed - Accept only `http://` and `https://` gRPC endpoints for app server `--code-mode-host` connections. - Limit the standalone code-mode host to stdio and gRPC listeners. - Remove the WebSocket session provider, dual-WebSocket negotiation, transport lanes, and related dependencies and tests. - Keep coverage for shared and prewarmed gRPC hosts and reject WebSocket host URLs in CLI parsing tests. GitOrigin-RevId: 8792604e79ffd54ce776074a4dc3f7d55e63752a
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
use std::net::SocketAddr;
|
|
|
|
use anyhow::Context;
|
|
use anyhow::Result;
|
|
|
|
use crate::grpc_transport;
|
|
|
|
/// The default transport retains the standalone host's original stdio behavior.
|
|
pub const DEFAULT_LISTEN_URL: &str = "stdio";
|
|
|
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
|
enum ListenTransport {
|
|
Stdio,
|
|
Grpc(SocketAddr),
|
|
}
|
|
|
|
pub(crate) async fn run_transport(listen_url: &str) -> Result<()> {
|
|
match parse_listen_url(listen_url)? {
|
|
ListenTransport::Stdio => crate::run_stdio().await,
|
|
ListenTransport::Grpc(bind_address) => grpc_transport::run_tcp_listener(bind_address).await,
|
|
}
|
|
}
|
|
|
|
fn parse_listen_url(listen_url: &str) -> Result<ListenTransport> {
|
|
if matches!(listen_url, "stdio" | "stdio://") {
|
|
return Ok(ListenTransport::Stdio);
|
|
}
|
|
|
|
if let Some(socket_addr) = listen_url.strip_prefix("grpc://") {
|
|
return socket_addr
|
|
.parse::<SocketAddr>()
|
|
.map(ListenTransport::Grpc)
|
|
.with_context(|| {
|
|
format!("invalid gRPC --listen URL `{listen_url}`; expected `grpc://IP:PORT`")
|
|
});
|
|
}
|
|
|
|
anyhow::bail!(
|
|
"unsupported --listen URL `{listen_url}`; expected `grpc://IP:PORT`, `stdio`, or `stdio://`"
|
|
);
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "transport_tests.rs"]
|
|
mod tests;
|