mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Honor configured proxies for realtime WebSocket connections (#47101)
## Why Realtime WebSockets connected directly, bypassing the configured proxy policy for Voice's WebRTC sideband. ## What changed Pass the configured `HttpClientFactory` into `RealtimeWebsocketClient` and connect through the shared `WebSocketConnector`. Add support for supplying an existing Rustls configuration to preserve custom CA handling and Windows platform trust. ## Testing Add an integration test that enables `respect_system_proxy`, starts a WebRTC conversation, and verifies that the sideband establishes its session through an HTTP `CONNECT` proxy and closes successfully. GitOrigin-RevId: d974c9275d7fe29f388d56a9d5d8ce0c483eb8d0
This commit is contained in:
@@ -43,11 +43,13 @@ pub struct WebSocketConnector {
|
||||
tcp_nodelay: TcpNodelay,
|
||||
}
|
||||
|
||||
/// Selects whether WebSocket TLS follows Codex custom-CA policy or Tungstenite defaults.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
/// Selects the TLS configuration used for WebSocket connections.
|
||||
#[derive(Clone)]
|
||||
pub enum WebSocketTlsMode {
|
||||
/// Build an explicit TLS configuration from native roots and configured Codex custom CAs.
|
||||
ExplicitCodexTls,
|
||||
/// Use an existing Rustls configuration.
|
||||
Rustls(Arc<ClientConfig>),
|
||||
/// Let Tungstenite build its default TLS configuration when the target requires TLS.
|
||||
TungsteniteDefault,
|
||||
}
|
||||
@@ -66,10 +68,10 @@ impl WebSocketConnector {
|
||||
Self::new_with_tls_mode(http_client_factory, WebSocketTlsMode::ExplicitCodexTls)
|
||||
}
|
||||
|
||||
/// Creates a connector with explicit Codex TLS or the transport's existing TLS defaults.
|
||||
/// Creates a connector with the selected WebSocket TLS configuration.
|
||||
///
|
||||
/// HTTPS proxy connections still build Codex TLS configuration when they establish their
|
||||
/// proxy tunnel; default-mode target connections otherwise remain entirely with Tungstenite.
|
||||
/// With [`WebSocketTlsMode::TungsteniteDefault`], HTTPS proxy connections still build Codex
|
||||
/// TLS configuration when they establish their proxy tunnel.
|
||||
pub fn new_with_tls_mode(
|
||||
http_client_factory: &HttpClientFactory,
|
||||
tls_mode: WebSocketTlsMode,
|
||||
@@ -78,6 +80,7 @@ impl WebSocketConnector {
|
||||
WebSocketTlsMode::ExplicitCodexTls => {
|
||||
Some(build_rustls_client_config_with_custom_ca()?)
|
||||
}
|
||||
WebSocketTlsMode::Rustls(config) => Some(config),
|
||||
WebSocketTlsMode::TungsteniteDefault => None,
|
||||
};
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user