Skip to content

Commit 27f3417

Browse files
committed
refactor(config): move network proxy mapping out of ConfigToml
1 parent af4fc96 commit 27f3417

File tree

1 file changed

+19
-11
lines changed
  • codex-rs/core/src/config

1 file changed

+19
-11
lines changed

codex-rs/core/src/config/mod.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,23 @@ impl NetworkToml {
12111211
config.network.allow_local_binding = allow_local_binding;
12121212
}
12131213
}
1214+
1215+
pub(crate) fn to_network_proxy_config(&self) -> NetworkProxyConfig {
1216+
let mut config = NetworkProxyConfig::default();
1217+
self.apply_to_network_proxy_config(&mut config);
1218+
config
1219+
}
1220+
}
1221+
1222+
fn network_proxy_config_from_permissions(
1223+
permissions: Option<&PermissionsToml>,
1224+
) -> NetworkProxyConfig {
1225+
permissions
1226+
.and_then(|permissions| permissions.network.as_ref())
1227+
.map_or_else(
1228+
NetworkProxyConfig::default,
1229+
NetworkToml::to_network_proxy_config,
1230+
)
12141231
}
12151232

12161233
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema)]
@@ -1302,16 +1319,6 @@ pub struct GhostSnapshotToml {
13021319
}
13031320

13041321
impl ConfigToml {
1305-
pub(crate) fn network_proxy_config(&self) -> NetworkProxyConfig {
1306-
let mut config = NetworkProxyConfig::default();
1307-
if let Some(permissions) = self.permissions.as_ref()
1308-
&& let Some(network) = permissions.network.as_ref()
1309-
{
1310-
network.apply_to_network_proxy_config(&mut config);
1311-
}
1312-
config
1313-
}
1314-
13151322
/// Derive the effective sandbox policy from the configuration.
13161323
fn derive_sandbox_policy(
13171324
&self,
@@ -1604,7 +1611,8 @@ impl Config {
16041611
.clone(),
16051612
None => ConfigProfile::default(),
16061613
};
1607-
let configured_network_proxy_config = cfg.network_proxy_config();
1614+
let configured_network_proxy_config =
1615+
network_proxy_config_from_permissions(cfg.permissions.as_ref());
16081616

16091617
let feature_overrides = FeatureOverrides {
16101618
include_apply_patch_tool: include_apply_patch_tool_override,

0 commit comments

Comments
 (0)