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.
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
impl ProxyError
Sourcepub fn fields_with_next_hop(self, next_hop: Option<SocketAddr>) -> Fields
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.
Sourcepub fn from_connect_error(error: &Error) -> Self
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.
Sourcepub fn recommended_status(self) -> Status
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
impl Clone for ProxyError
Source§fn clone(&self) -> ProxyError
fn clone(&self) -> ProxyError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ProxyError
Source§impl Debug for ProxyError
impl Debug for ProxyError
impl Eq for ProxyError
Source§impl PartialEq for ProxyError
impl PartialEq for ProxyError
Source§fn eq(&self, other: &ProxyError) -> bool
fn eq(&self, other: &ProxyError) -> bool
self and other values to be equal, and is used by ==.