Skip to content

feat(client): add iOS system proxy detection via CFNetworkCopySystemProxySettings#291

Open
trypsynth wants to merge 1 commit into
hyperium:masterfrom
trypsynth:feat/ios-system-proxy
Open

feat(client): add iOS system proxy detection via CFNetworkCopySystemProxySettings#291
trypsynth wants to merge 1 commit into
hyperium:masterfrom
trypsynth:feat/ios-system-proxy

Conversation

@trypsynth
Copy link
Copy Markdown

iOS system proxy support

from_system() already reads system proxy settings on macOS (via SCDynamicStore) and Windows (via the registry). This PR adds a parallel implementation for iOS using CFNetworkCopySystemProxySettings() from CFNetwork.framework, so that callers get the same automatic proxy pickup on iOS that they already get on macOS.

What changed

  • Added ios::with_system(&mut builder) call in from_system(), gated on #[cfg(all(feature = "client-proxy-system", target_os = "ios"))].
  • Added mod ios, which declares CFNetworkCopySystemProxySettings and the kCFNetworkProxies* key constants via unsafe extern "C" linking against CFNetwork.framework.

Testing

  • cargo check --features client-proxy,client-proxy-system (macOS host): clean.
  • cargo check --target aarch64-apple-ios --features client-proxy,client-proxy-system: clean.
  • Built the test suite for aarch64-apple-ios-sim with cargo test --target aarch64-apple-ios-sim --features client-proxy,client-proxy-system --no-run, then ran the binary on a booted iPhone 15 Pro simulator via xcrun simctl spawn. All 12 proxy matcher unit tests passed.

Note: CFNetworkCopySystemProxySettings returns null when no proxy is configured, which the implementation handles by returning early. Since the simulator has no proxy configured, the system path is exercised but returns early. The unit tests confirm the parsing and matching logic is correct beyond just linking cleanly. Also verified on a real device (iPad mini 6th gen) with a proxy configured -- CFNetworkCopySystemProxySettings returned the expected host and port.

…roxySettings

Adds a `mod ios` in `src/client/proxy/matcher.rs`, gated on
`#[cfg(all(feature = "client-proxy-system", target_os = "ios"))]`,
that reads HTTP/HTTPS proxy settings using `CFNetworkCopySystemProxySettings()`
from CFNetwork.framework. Wires it into `from_system()` alongside the
existing macOS and Windows paths.

Adds `core-foundation = { version = "0.9", optional = true }` as a
target-specific dependency for iOS and includes it in the
`client-proxy-system` feature.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant