Skip to main content

ProxyError

Enum ProxyError 

Source
pub enum ProxyError {
    DnsError,
    DnsTimeout,
    DestinationIpProhibited,
    DestinationUnavailable,
    ConnectionRefused,
    ConnectionTimeout,
    ProxyInternalError,
    ConnectionLimitReached,
    HttpRequestDenied,
}
Expand description

An RFC 9209 proxy error type, for the Proxy-Status field of a refusal.

Only registered types (RFC 9209 §2.3.2) appear here. There is no registered type for “that port is closed by policy”, so a denied port is reported as http_request_denied — the registry’s general “denied per policy” type — rather than stretching destination_ip_prohibited to cover something that is not about the address at all.

Variants§

§

DnsError

The target name could not be resolved.

§

DnsTimeout

The resolver did not answer inside the [limits] connect_timeout budget.

§

DestinationIpProhibited

Every address the target resolved to is prohibited by policy.

§

DestinationUnavailable

The target is a legal destination but could not be reached.

§

ConnectionRefused

The target actively refused the connection.

§

ConnectionTimeout

The connection attempt timed out.

§

ProxyInternalError

This host could not spare the resources to reach the target at all.

RFC 9209 §2.3.30 describes the type as “the intermediary encountered an internal error unrelated to the origin”, which is exactly the case: the descriptor, the buffer or the source port ran out here, and nothing at all was learned about the destination. See is_local_exhaustion.

§

ConnectionLimitReached

This connection already holds as many tunnels as it may.

§

HttpRequestDenied

The request is refused by policy.

Implementations§

Source§

impl ProxyError

Source

pub fn fields(self) -> Fields

This error as the field lines of a response.

Source

pub fn fields_with_next_hop(self, next_hop: Option<SocketAddr>) -> Fields

This error as the field lines of a response, naming the hop it happened on.

The address is dropped unless Self::discloses_next_hop allows it, so a caller cannot leak one by passing it to the wrong error type.

Source

pub fn from_connect_error(error: &Error) -> Self

The error type that best describes a failure to reach a target.

The local failures are separated out first, because everything below them is a statement about the target and they are not one: see is_local_exhaustion.

Source

pub fn recommended_status(self) -> Status

The HTTP status code RFC 9209 §2.3.2 recommends for this error type.

The registry pairs each type with a status, and following it costs nothing while telling an operator reading a log which failure it was: a 504 is a target that never answered, a 503 is one that could not be reached at all, and a 502 is one that actively refused.

One deliberate departure: destination_ip_prohibited is recommended as 502, and this server answers 403. Decision D11 made both policy refusals — denied port and denied address — a 403, because they are refusals by this proxy rather than reports about an upstream hop, and a client that sees 502 would reasonably retry.

One address refusal never arrives here at all (decision D49, a carve-out from D11 rather than a revision of it): a target whose every resolved address is the unspecified one is a name the upstream resolver filtered, so it is answered with a 200 that closes on the spot — see accept_then_close — and carries no Proxy-Status field, because nothing about it is this proxy’s verdict. Every refusal that is actually sent still follows the table below.

Trait Implementations§

Source§

impl Clone for ProxyError

Source§

fn clone(&self) -> ProxyError

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 Copy for ProxyError

Source§

impl Debug for ProxyError

Source§

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

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

impl Eq for ProxyError

Source§

impl PartialEq for ProxyError

Source§

fn eq(&self, other: &ProxyError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ProxyError

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more