Skip to main content

ProxyMode

Enum ProxyMode 

Source
pub enum ProxyMode {
    None,
    Environment,
    Explicit(String),
    System,
}
Expand description

How requests reach the network.

Threat model. A direct connection is the strongest case: this crate resolves the name, checks every address and connects to exactly those addresses. Through a proxy it cannot: the proxy resolves the destination name itself, so the address a connection reaches cannot be checked or pinned here. The guarantee through a proxy is therefore name- and literal-based, and weaker than a direct connection. ProxyMode::None stays the default for that reason.

With a proxy:

  • The proxy endpoint is trusted (it is user or administrator configuration, often on a private address such as http://10.0.0.5:3128). It gets no address-class denial. Only http and https proxies are accepted.
  • Every destination is still vetted: IP literals (and localhost) by class, hostnames by the name rules (localhost, *.localhost, *.local, *.internal and single-label names are refused unless an allow_if rule lists the host), cloud metadata names, and the first-party host pin. deny_ranges and deny_if apply to literals only, because a hostname’s address is not known. A hostname that resolves to a private address at the proxy is not caught.
  • Every redirect hop is vetted the same way.
  • Hosts that match NO_PROXY connect directly and get the full direct-connection check.
  • ClientConfig::proxy_bypass_first_party skips the proxy for a first-party client.

The proxy is trusted: it sees destinations and can forward anywhere. Credentials in a proxy URL never appear in Debug output or errors.

Variants§

§

None

No proxy. Environment proxy variables are ignored. This is the default.

§

Environment

ALL_PROXY, HTTPS_PROXY, HTTP_PROXY (first set, either case) and NO_PROXY.

§

Explicit(String)

A proxy URL such as http://proxy.corp:3128 or socks5://127.0.0.1:1080.

§

System

The proxy the operating system is configured with for the current user.

Windows: the static proxy and bypass list of the system proxy settings, followed exactly or not at all. One http or https proxy for both schemes with a bypass list of plain hosts (host, *.example.com) is used. Anything else (different routes per scheme, <local>, a scheme-limited or inner-wildcard bypass entry, a proxy auto-config script, automatic detection) is HttpError::SystemProxyUnsupported and nothing is sent; catch it and use the mode the app used before. When nothing is configured, and on other systems, this is ProxyMode::Environment.

Trait Implementations§

Source§

impl Clone for ProxyMode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProxyMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProxyMode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.