Enum ProxyProtocol
pub enum ProxyProtocol {
Http {
version: Option<Version>,
secure: bool,
path_template: Option<ProxyPathTemplate>,
},
Socks5 {
remote_dns: bool,
transport: Option<TransportProtocol>,
secure: bool,
},
Custom(SmolStr),
}net only.Expand description
How to reach a proxy and what to ask it.
Variants§
Http
An HTTP proxy: CONNECT for TCP, and MASQUE for UDP or IP when it has a template.
Fields
version: Option<Version>The HTTP version spoken to it. None over TLS lets the client pick one as it
does for an origin: HTTP/3 when the proxy advertises it (HTTPS record or
Alt-Svc), else ALPN over TCP. None in plaintext means HTTP/1.1. A plaintext proxy with None is dialed the same
as ProxyProtocol::HTTP (Some(HTTP_11)), but does not compare equal to it.
path_template: Option<ProxyPathTemplate>Where its MASQUE tunnels live; None offers CONNECT only.
Socks5
A SOCKS5 proxy: CONNECT for TCP, UDP ASSOCIATE for UDP.
Fields
transport: Option<TransportProtocol>Only CONNECT (+tcp) or only UDP ASSOCIATE (+udp); None is whichever
the traffic needs.
Custom(SmolStr)
A scheme rama does not interpret.
Implementations§
§impl ProxyProtocol
impl ProxyProtocol
pub fn try_from_scheme(
scheme: &str,
) -> Result<ProxyProtocol, Box<dyn Error + Send + Sync>>
pub fn try_from_scheme( scheme: &str, ) -> Result<ProxyProtocol, Box<dyn Error + Send + Sync>>
Parse the scheme of a proxy address, such as https, h3+udp or socks5h+tls.
A scheme is a base protocol, followed by options after + in any order:
| base | proxy |
|---|---|
http | HTTP/1.1, plaintext |
h2c | HTTP/2, plaintext |
https | HTTP over TLS: HTTP/3 when the proxy advertises it, else ALPN over TCP |
h1, h2 | HTTP/1.1 or HTTP/2 over TLS, over TCP |
h3 | HTTP/3, over QUIC |
socks5 | SOCKS5, target names resolved locally |
socks5h | SOCKS5, target names resolved by the proxy |
| option | on | meaning |
|---|---|---|
+udp | HTTP | also CONNECT-UDP, on the default template |
+udp | SOCKS5 | UDP ASSOCIATE only |
+tcp | SOCKS5 | CONNECT only |
+tls | SOCKS5 | TLS to the proxy; with UDP ASSOCIATE only the control connection |
A protocol with a secure name of its own uses that name, so an HTTP proxy has no
+tls: it is https, h1, h2 or h3. An HTTP proxy carries TCP with CONNECT,
and UDP or IP with MASQUE only when its address says where the tunnels are: +udp,
or a path as the template (see Self::try_from_scheme_and_path).
Any other scheme is a Self::Custom protocol, kept as is and not interpreted.
Not every protocol round-trips through its scheme: a plaintext HTTP proxy with no
version prints as http, which parses back as HTTP/1.1, and a custom template
lives in the path of the address, not in its scheme.
pub fn try_from_scheme_and_path(
scheme: &str,
path: &str,
) -> Result<ProxyProtocol, Box<dyn Error + Send + Sync>>
pub fn try_from_scheme_and_path( scheme: &str, path: &str, ) -> Result<ProxyProtocol, Box<dyn Error + Send + Sync>>
Self::try_from_scheme with the path of the proxy address: the template an HTTP
proxy offers its MASQUE tunnels on.
§impl ProxyProtocol
impl ProxyProtocol
pub const HTTP: ProxyProtocol
pub const HTTP: ProxyProtocol
A plaintext HTTP/1.1 proxy (http://).
pub const HTTPS: ProxyProtocol
pub const HTTPS: ProxyProtocol
An HTTP proxy over TLS, version picked as for an origin (https://).
pub const H1: ProxyProtocol
pub const H1: ProxyProtocol
An HTTP/1.1 proxy over TLS (h1://).
pub const H2: ProxyProtocol
pub const H2: ProxyProtocol
An HTTP/2 proxy over TLS (h2://).
pub const H2C: ProxyProtocol
pub const H2C: ProxyProtocol
A plaintext HTTP/2 proxy (h2c://).
pub const H3: ProxyProtocol
pub const H3: ProxyProtocol
An HTTP/3 proxy over QUIC (h3://).
pub const SOCKS5: ProxyProtocol
pub const SOCKS5: ProxyProtocol
A SOCKS5 proxy which resolves target names locally (socks5://).
pub const SOCKS5H: ProxyProtocol
pub const SOCKS5H: ProxyProtocol
A SOCKS5 proxy which resolves target names itself (socks5h://).
pub const SOCKS5_TCP: ProxyProtocol
pub const SOCKS5_TCP: ProxyProtocol
A SOCKS5 proxy for CONNECT only (socks5+tcp).
pub const SOCKS5_UDP: ProxyProtocol
pub const SOCKS5_UDP: ProxyProtocol
A SOCKS5 proxy for UDP ASSOCIATE only (socks5+udp).
pub const SOCKS5H_TCP: ProxyProtocol
pub const SOCKS5H_TCP: ProxyProtocol
A SOCKS5 proxy for CONNECT only, which resolves target names itself (socks5h+tcp).
pub const SOCKS5H_UDP: ProxyProtocol
pub const SOCKS5H_UDP: ProxyProtocol
A SOCKS5 proxy for UDP ASSOCIATE only, which resolves target names itself
(socks5h+udp).
pub const SOCKS5_TLS: ProxyProtocol
pub const SOCKS5_TLS: ProxyProtocol
A SOCKS5 proxy over TLS (socks5+tls).
pub const SOCKS5H_TLS: ProxyProtocol
pub const SOCKS5H_TLS: ProxyProtocol
A SOCKS5 proxy over TLS, which resolves target names itself (socks5h+tls).
pub const SOCKS5_TCP_TLS: ProxyProtocol
pub const SOCKS5_TCP_TLS: ProxyProtocol
A SOCKS5 proxy over TLS for CONNECT only (socks5+tcp+tls).
pub const SOCKS5_UDP_TLS: ProxyProtocol
pub const SOCKS5_UDP_TLS: ProxyProtocol
A SOCKS5 proxy over TLS for UDP ASSOCIATE only; the UDP relay stays plaintext (socks5+udp+tls).
pub const SOCKS5H_TCP_TLS: ProxyProtocol
pub const SOCKS5H_TCP_TLS: ProxyProtocol
A SOCKS5 proxy over TLS for CONNECT only, which resolves target names itself (socks5h+tcp+tls).
pub const SOCKS5H_UDP_TLS: ProxyProtocol
pub const SOCKS5H_UDP_TLS: ProxyProtocol
A SOCKS5 proxy over TLS for UDP ASSOCIATE only, which resolves target names itself; the UDP relay stays plaintext (socks5h+udp+tls).
pub fn connect_udp(version: Version) -> ProxyProtocol
pub fn connect_udp(version: Version) -> ProxyProtocol
An HTTP proxy over TLS speaking version, which offers CONNECT-UDP on the default
template (h3+udp for HTTP/3).
pub fn is_http(&self) -> bool
pub fn is_socks5(&self) -> bool
pub fn path_template(&self) -> Option<&ProxyPathTemplate>
pub fn connect_udp_template(&self) -> Option<ProxyPathTemplate>
pub fn connect_udp_template(&self) -> Option<ProxyPathTemplate>
The template to open CONNECT-UDP tunnels on, if this proxy offers them.
An HTTP proxy offers them only where its address says so, with +udp or a
CONNECT-UDP path template.
pub fn carries(&self, transport: TransportProtocol) -> bool
pub fn carries(&self, transport: TransportProtocol) -> bool
Whether this protocol can carry traffic of the given transport.
A Self::Custom protocol carries nothing rama knows of.
pub fn http_version(&self) -> Option<Version>
pub fn as_protocol(&self) -> Option<Protocol>
pub fn as_protocol(&self) -> Option<Protocol>
The URI scheme naming this protocol, None for a Self::Custom one.
Trait Implementations§
§impl Clone for ProxyProtocol
impl Clone for ProxyProtocol
§fn clone(&self) -> ProxyProtocol
fn clone(&self) -> ProxyProtocol
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 ProxyProtocol
impl Debug for ProxyProtocol
§impl Default for ProxyProtocol
impl Default for ProxyProtocol
§fn default() -> ProxyProtocol
fn default() -> ProxyProtocol
§impl Display for ProxyProtocol
Writes the scheme naming this protocol in a proxy address; see
ProxyProtocol::try_from_scheme.
impl Display for ProxyProtocol
Writes the scheme naming this protocol in a proxy address; see
ProxyProtocol::try_from_scheme.
impl Eq for ProxyProtocol
§impl From<Protocol> for ProxyProtocol
impl From<Protocol> for ProxyProtocol
§fn from(protocol: Protocol) -> ProxyProtocol
fn from(protocol: Protocol) -> ProxyProtocol
§impl FromIterator<ProxyProtocol> for ProxyProtocols
impl FromIterator<ProxyProtocol> for ProxyProtocols
§fn from_iter<I>(iter: I) -> ProxyProtocolswhere
I: IntoIterator<Item = ProxyProtocol>,
fn from_iter<I>(iter: I) -> ProxyProtocolswhere
I: IntoIterator<Item = ProxyProtocol>,
§impl Hash for ProxyProtocol
impl Hash for ProxyProtocol
§impl PartialEq for ProxyProtocol
impl PartialEq for ProxyProtocol
impl StructuralPartialEq for ProxyProtocol
Auto Trait Implementations§
impl Forget for ProxyProtocol
impl Freeze for ProxyProtocol
impl Move for ProxyProtocol
impl RefUnwindSafe for ProxyProtocol
impl Send for ProxyProtocol
impl Sync for ProxyProtocol
impl Unpin for ProxyProtocol
impl UnsafeUnpin for ProxyProtocolwhere
*const ArcInner<Inner> is !null: UnsafeUnpin,
PhantomData<ArcInner<Inner>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
impl UnwindSafe for ProxyProtocol
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.