mirror of
https://github.com/openai/codex.git
synced 2026-04-28 00:25:56 +00:00
feat: retain NetworkProxy, when appropriate (#11207)
As of this PR, `SessionServices` retains a `Option<StartedNetworkProxy>`, if appropriate. Now the `network` field on `Config` is `Option<NetworkProxySpec>` instead of `Option<NetworkProxy>`. Over in `Session::new()`, we invoke `NetworkProxySpec::start_proxy()` to create the `StartedNetworkProxy`, which is a new struct that retains the `NetworkProxy` as well as the `NetworkProxyHandle`. (Note that `Drop` is implemented for `NetworkProxyHandle` to ensure the proxies are shutdown when it is dropped.) The `NetworkProxy` from the `StartedNetworkProxy` is threaded through to the appropriate places. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/11207). * #11285 * __->__ #11207
This commit is contained in:
@@ -8,11 +8,31 @@ use codex_core::config_loader::RequirementSource;
|
||||
use codex_core::config_loader::ResidencyRequirement;
|
||||
use codex_core::config_loader::SandboxModeRequirement;
|
||||
use codex_core::config_loader::WebSearchModeRequirement;
|
||||
use codex_core::protocol::SessionNetworkProxyRuntime;
|
||||
use ratatui::style::Stylize;
|
||||
use ratatui::text::Line;
|
||||
|
||||
pub(crate) fn new_debug_config_output(config: &Config) -> PlainHistoryCell {
|
||||
PlainHistoryCell::new(render_debug_config_lines(&config.config_layer_stack))
|
||||
pub(crate) fn new_debug_config_output(
|
||||
config: &Config,
|
||||
session_network_proxy: Option<&SessionNetworkProxyRuntime>,
|
||||
) -> PlainHistoryCell {
|
||||
let mut lines = render_debug_config_lines(&config.config_layer_stack);
|
||||
|
||||
if let Some(proxy) = session_network_proxy {
|
||||
lines.push("".into());
|
||||
lines.push("Session runtime:".bold().into());
|
||||
lines.push(" - network_proxy".into());
|
||||
let SessionNetworkProxyRuntime {
|
||||
http_addr,
|
||||
socks_addr,
|
||||
admin_addr,
|
||||
} = proxy;
|
||||
lines.push(format!(" - HTTP_PROXY = http://{http_addr}").into());
|
||||
lines.push(format!(" - ALL_PROXY = socks5h://{socks_addr}").into());
|
||||
lines.push(format!(" - ADMIN_PROXY = http://{admin_addr}").into());
|
||||
}
|
||||
|
||||
PlainHistoryCell::new(lines)
|
||||
}
|
||||
|
||||
fn render_debug_config_lines(stack: &ConfigLayerStack) -> Vec<Line<'static>> {
|
||||
|
||||
Reference in New Issue
Block a user