Struct SystemProxyConfig
pub struct SystemProxyConfig { /* private fields */ }net only.Expand description
A snapshot of the operating system’s proxy configuration.
HTTP and HTTPS identify the destination scheme, not necessarily the transport protocol used to reach the proxy. A SOCKS5 proxy is used as a fallback when no scheme-specific proxy is configured. A PAC URI takes precedence over fixed proxies because it can make a per-request decision; each platform reader records whether its bypass entries apply before PAC. System proxy routing always bypasses loopback hosts, including before PAC evaluation, matching native proxy stacks.
Implementations§
§impl SystemProxyConfig
impl SystemProxyConfig
pub async fn try_from_system() -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
pub async fn try_from_system() -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
Read the current platform proxy snapshot.
- Windows uses the active user’s WinINET/Internet Options settings;
- macOS and iOS use CFNetwork’s system proxy dictionary;
- Android uses
ConnectivityManager.getDefaultProxy(), with the legacyProxyAPI on Android versions before API 23; - Linux and BSD prefer KDE’s
kioslavercon KDE desktops, otherwise reading GNOMEgsettingsbefore falling back to KDE.
This deliberately does not inspect http_proxy or related environment
variables. Those are application configuration and are handled by
ProxyEnvLayer and
NoProxyEnvLayer instead.
Automatic discovery such as WPAD is recorded by Self::auto_detect
but is not attempted when the platform does not provide a concrete PAC
URI. Malformed non-empty proxy values are reported as errors rather
than silently bypassing a configured system policy.
Platform operations that have asynchronous APIs are awaited directly. Native platforms that only expose a synchronous snapshot call keep that call narrowly isolated inside their platform reader.
pub async fn try_from_system_with_invalid_bypass_rule_policy(
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
pub async fn try_from_system_with_invalid_bypass_rule_policy( policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
Read the current platform proxy snapshot with an explicit invalid bypass-rule policy.
Ignore is the default
used by Self::try_from_system. Selecting
Reject returns an error
instead of accepting a snapshot with one or more discarded rules.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return whether this snapshot contains no automatic, PAC, or fixed proxy settings.
pub const fn http_proxy(&self) -> Option<&ProxyAddress>
pub const fn http_proxy(&self) -> Option<&ProxyAddress>
The proxy for HTTP destinations.
pub const fn https_proxy(&self) -> Option<&ProxyAddress>
pub const fn https_proxy(&self) -> Option<&ProxyAddress>
The proxy for HTTPS destinations.
pub const fn socks5_proxy(&self) -> Option<&ProxyAddress>
pub const fn socks5_proxy(&self) -> Option<&ProxyAddress>
The SOCKS5 fallback proxy.
pub const fn auto_detect(&self) -> bool
pub const fn auto_detect(&self) -> bool
Whether the platform requested automatic proxy discovery (for example, WPAD) without necessarily supplying a concrete PAC URI.
pub const fn exclude_simple_hostnames(&self) -> bool
pub const fn exclude_simple_hostnames(&self) -> bool
Whether names without a dot bypass fixed proxies.
pub const fn reversed_bypass(&self) -> bool
pub const fn reversed_bypass(&self) -> bool
Whether fixed proxies are used only for hosts matching bypass.
KDE exposes this uncommon inverted exception-list mode. The default is
false, where matching hosts bypass the proxy in the usual way.
pub fn maybe_with_http_proxy(
self,
proxy: Option<ProxyAddress>,
) -> SystemProxyConfig
pub fn maybe_with_http_proxy( self, proxy: Option<ProxyAddress>, ) -> SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn maybe_set_http_proxy(
&mut self,
proxy: Option<ProxyAddress>,
) -> &mut SystemProxyConfig
pub fn maybe_set_http_proxy( &mut self, proxy: Option<ProxyAddress>, ) -> &mut SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn with_http_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
pub fn with_http_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn set_http_proxy(&mut self, proxy: ProxyAddress) -> &mut SystemProxyConfig
pub fn set_http_proxy(&mut self, proxy: ProxyAddress) -> &mut SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn without_http_proxy(self) -> SystemProxyConfig
pub fn without_http_proxy(self) -> SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn unset_http_proxy(&mut self) -> &mut SystemProxyConfig
pub fn unset_http_proxy(&mut self) -> &mut SystemProxyConfig
Set the proxy used for HTTP destinations.
pub fn maybe_with_https_proxy(
self,
proxy: Option<ProxyAddress>,
) -> SystemProxyConfig
pub fn maybe_with_https_proxy( self, proxy: Option<ProxyAddress>, ) -> SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn maybe_set_https_proxy(
&mut self,
proxy: Option<ProxyAddress>,
) -> &mut SystemProxyConfig
pub fn maybe_set_https_proxy( &mut self, proxy: Option<ProxyAddress>, ) -> &mut SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn with_https_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
pub fn with_https_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn set_https_proxy(&mut self, proxy: ProxyAddress) -> &mut SystemProxyConfig
pub fn set_https_proxy(&mut self, proxy: ProxyAddress) -> &mut SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn without_https_proxy(self) -> SystemProxyConfig
pub fn without_https_proxy(self) -> SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn unset_https_proxy(&mut self) -> &mut SystemProxyConfig
pub fn unset_https_proxy(&mut self) -> &mut SystemProxyConfig
Set the proxy used for HTTPS destinations.
pub fn maybe_with_socks5_proxy(
self,
proxy: Option<ProxyAddress>,
) -> SystemProxyConfig
pub fn maybe_with_socks5_proxy( self, proxy: Option<ProxyAddress>, ) -> SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn maybe_set_socks5_proxy(
&mut self,
proxy: Option<ProxyAddress>,
) -> &mut SystemProxyConfig
pub fn maybe_set_socks5_proxy( &mut self, proxy: Option<ProxyAddress>, ) -> &mut SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn with_socks5_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
pub fn with_socks5_proxy(self, proxy: ProxyAddress) -> SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn set_socks5_proxy(
&mut self,
proxy: ProxyAddress,
) -> &mut SystemProxyConfig
pub fn set_socks5_proxy( &mut self, proxy: ProxyAddress, ) -> &mut SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn without_socks5_proxy(self) -> SystemProxyConfig
pub fn without_socks5_proxy(self) -> SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn unset_socks5_proxy(&mut self) -> &mut SystemProxyConfig
pub fn unset_socks5_proxy(&mut self) -> &mut SystemProxyConfig
Set the SOCKS5 fallback proxy.
pub fn maybe_with_pac_uri(self, pac_uri: Option<Uri>) -> SystemProxyConfig
pub fn maybe_with_pac_uri(self, pac_uri: Option<Uri>) -> SystemProxyConfig
Set the PAC script URI.
pub fn maybe_set_pac_uri(
&mut self,
pac_uri: Option<Uri>,
) -> &mut SystemProxyConfig
pub fn maybe_set_pac_uri( &mut self, pac_uri: Option<Uri>, ) -> &mut SystemProxyConfig
Set the PAC script URI.
pub fn with_pac_uri(self, pac_uri: Uri) -> SystemProxyConfig
pub fn with_pac_uri(self, pac_uri: Uri) -> SystemProxyConfig
Set the PAC script URI.
pub fn set_pac_uri(&mut self, pac_uri: Uri) -> &mut SystemProxyConfig
pub fn set_pac_uri(&mut self, pac_uri: Uri) -> &mut SystemProxyConfig
Set the PAC script URI.
pub fn without_pac_uri(self) -> SystemProxyConfig
pub fn without_pac_uri(self) -> SystemProxyConfig
Set the PAC script URI.
pub fn unset_pac_uri(&mut self) -> &mut SystemProxyConfig
pub fn unset_pac_uri(&mut self) -> &mut SystemProxyConfig
Set the PAC script URI.
pub fn with_auto_detect(self, auto_detect: bool) -> SystemProxyConfig
pub fn with_auto_detect(self, auto_detect: bool) -> SystemProxyConfig
Record whether automatic proxy discovery is enabled.
Rama exposes this signal but does not perform WPAD itself.
pub fn set_auto_detect(&mut self, auto_detect: bool) -> &mut SystemProxyConfig
pub fn set_auto_detect(&mut self, auto_detect: bool) -> &mut SystemProxyConfig
Record whether automatic proxy discovery is enabled.
Rama exposes this signal but does not perform WPAD itself.
pub fn with_bypass(
self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
) -> SystemProxyConfig
pub fn with_bypass( self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, ) -> SystemProxyConfig
Replace the fixed-proxy bypass patterns, ignoring invalid entries.
Use Self::try_set_bypass with
Reject when an invalid
entry should reject the complete update. Boxed strings transfer
directly into snapshot storage; borrowed strings are copied because
the snapshot owns its rules.
pub fn set_bypass(
&mut self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
) -> &mut SystemProxyConfig
pub fn set_bypass( &mut self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, ) -> &mut SystemProxyConfig
Replace the fixed-proxy bypass patterns, ignoring invalid entries.
Use Self::try_set_bypass with
Reject when an invalid
entry should reject the complete update. Boxed strings transfer
directly into snapshot storage; borrowed strings are copied because
the snapshot owns its rules.
pub fn try_with_bypass(
self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
pub fn try_with_bypass( self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<SystemProxyConfig, Box<dyn Error + Sync + Send>>
Replace the fixed-proxy bypass patterns using an explicit invalid-rule policy.
The update is atomic: when Reject
encounters an invalid rule, this returns an error and leaves the prior
bypass list unchanged. Boxed strings transfer directly into snapshot
storage; borrowed strings are copied because the snapshot owns its
rules.
pub fn try_set_bypass(
&mut self,
bypass: impl IntoIterator<Item = impl Into<Box<str>>>,
policy: SystemProxyInvalidBypassRulePolicy,
) -> Result<&mut SystemProxyConfig, Box<dyn Error + Sync + Send>>
pub fn try_set_bypass( &mut self, bypass: impl IntoIterator<Item = impl Into<Box<str>>>, policy: SystemProxyInvalidBypassRulePolicy, ) -> Result<&mut SystemProxyConfig, Box<dyn Error + Sync + Send>>
Replace the fixed-proxy bypass patterns using an explicit invalid-rule policy.
The update is atomic: when Reject
encounters an invalid rule, this returns an error and leaves the prior
bypass list unchanged. Boxed strings transfer directly into snapshot
storage; borrowed strings are copied because the snapshot owns its
rules.
pub fn with_exclude_simple_hostnames(self, exclude: bool) -> SystemProxyConfig
pub fn with_exclude_simple_hostnames(self, exclude: bool) -> SystemProxyConfig
Configure whether names without a dot bypass fixed proxies.
pub fn set_exclude_simple_hostnames(
&mut self,
exclude: bool,
) -> &mut SystemProxyConfig
pub fn set_exclude_simple_hostnames( &mut self, exclude: bool, ) -> &mut SystemProxyConfig
Configure whether names without a dot bypass fixed proxies.
pub fn with_reversed_bypass(self, reversed: bool) -> SystemProxyConfig
pub fn with_reversed_bypass(self, reversed: bool) -> SystemProxyConfig
Invert the meaning of fixed-proxy bypass patterns.
pub fn set_reversed_bypass(&mut self, reversed: bool) -> &mut SystemProxyConfig
pub fn set_reversed_bypass(&mut self, reversed: bool) -> &mut SystemProxyConfig
Invert the meaning of fixed-proxy bypass patterns.
Trait Implementations§
§impl Clone for SystemProxyConfig
impl Clone for SystemProxyConfig
§fn clone(&self) -> SystemProxyConfig
fn clone(&self) -> SystemProxyConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for SystemProxyConfig
impl Debug for SystemProxyConfig
§impl Default for SystemProxyConfig
impl Default for SystemProxyConfig
§fn default() -> SystemProxyConfig
fn default() -> SystemProxyConfig
Auto Trait Implementations§
impl !Freeze for SystemProxyConfig
impl RefUnwindSafe for SystemProxyConfig
impl Send for SystemProxyConfig
impl Sync for SystemProxyConfig
impl Unpin for SystemProxyConfig
impl UnsafeUnpin for SystemProxyConfig
impl UnwindSafe for SystemProxyConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more