Skip to main content

ProxyProtocol

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),
}
Available on crate feature 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.

§secure: bool

TLS to the proxy itself (https://).

§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

§remote_dns: bool

The proxy resolves target names (socks5h://).

§transport: Option<TransportProtocol>

Only CONNECT (+tcp) or only UDP ASSOCIATE (+udp); None is whichever the traffic needs.

§secure: bool

TLS to the proxy itself (+tls). With UDP ASSOCIATE this secures the TCP control connection only: the UDP relay stays plaintext.

§

Custom(SmolStr)

A scheme rama does not interpret.

Implementations§

§

impl ProxyProtocol

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:

baseproxy
httpHTTP/1.1, plaintext
h2cHTTP/2, plaintext
httpsHTTP over TLS: HTTP/3 when the proxy advertises it, else ALPN over TCP
h1, h2HTTP/1.1 or HTTP/2 over TLS, over TCP
h3HTTP/3, over QUIC
socks5SOCKS5, target names resolved locally
socks5hSOCKS5, target names resolved by the proxy
optiononmeaning
+udpHTTPalso CONNECT-UDP, on the default template
+udpSOCKS5UDP ASSOCIATE only
+tcpSOCKS5CONNECT only
+tlsSOCKS5TLS 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>>

Self::try_from_scheme with the path of the proxy address: the template an HTTP proxy offers its MASQUE tunnels on.

§

impl ProxyProtocol

pub const HTTP: ProxyProtocol

A plaintext HTTP/1.1 proxy (http://).

pub const HTTPS: ProxyProtocol

An HTTP proxy over TLS, version picked as for an origin (https://).

pub const H1: ProxyProtocol

An HTTP/1.1 proxy over TLS (h1://).

pub const H2: ProxyProtocol

An HTTP/2 proxy over TLS (h2://).

pub const H2C: ProxyProtocol

A plaintext HTTP/2 proxy (h2c://).

pub const H3: ProxyProtocol

An HTTP/3 proxy over QUIC (h3://).

pub const SOCKS5: ProxyProtocol

A SOCKS5 proxy which resolves target names locally (socks5://).

pub const SOCKS5H: ProxyProtocol

A SOCKS5 proxy which resolves target names itself (socks5h://).

pub const SOCKS5_TCP: ProxyProtocol

A SOCKS5 proxy for CONNECT only (socks5+tcp).

pub const SOCKS5_UDP: ProxyProtocol

A SOCKS5 proxy for UDP ASSOCIATE only (socks5+udp).

pub const SOCKS5H_TCP: ProxyProtocol

A SOCKS5 proxy for CONNECT only, which resolves target names itself (socks5h+tcp).

pub const SOCKS5H_UDP: ProxyProtocol

A SOCKS5 proxy for UDP ASSOCIATE only, which resolves target names itself (socks5h+udp).

pub const SOCKS5_TLS: ProxyProtocol

A SOCKS5 proxy over TLS (socks5+tls).

pub const SOCKS5H_TLS: ProxyProtocol

A SOCKS5 proxy over TLS, which resolves target names itself (socks5h+tls).

pub const SOCKS5_TCP_TLS: ProxyProtocol

A SOCKS5 proxy over TLS for CONNECT only (socks5+tcp+tls).

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

A SOCKS5 proxy over TLS for CONNECT only, which resolves target names itself (socks5h+tcp+tls).

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

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 is_secure(&self) -> bool

Whether the connection to the proxy itself is TLS.

pub fn path_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

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>

The URI scheme naming this protocol, None for a Self::Custom one.

Trait Implementations§

§

impl Clone for ProxyProtocol

§

fn clone(&self) -> ProxyProtocol

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
§

impl Debug for ProxyProtocol

§

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

Formats the value using the given formatter. Read more
§

impl Default for ProxyProtocol

§

fn default() -> ProxyProtocol

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

impl Display for ProxyProtocol

Writes the scheme naming this protocol in a proxy address; see ProxyProtocol::try_from_scheme.

§

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

Formats the value using the given formatter. Read more
§

impl Eq for ProxyProtocol

§

impl From<Protocol> for ProxyProtocol

§

fn from(protocol: Protocol) -> ProxyProtocol

Converts to this type from the input type.
§

impl FromIterator<ProxyProtocol> for ProxyProtocols

§

fn from_iter<I>(iter: I) -> ProxyProtocols
where I: IntoIterator<Item = ProxyProtocol>,

Creates a value from an iterator. Read more
§

impl Hash for ProxyProtocol

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for ProxyProtocol

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for ProxyProtocol

Auto Trait Implementations§

§

impl Forget for ProxyProtocol

§

impl Freeze for ProxyProtocol
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze, &'static str: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze,

§

impl Move for ProxyProtocol

§

impl RefUnwindSafe for ProxyProtocol

§

impl Send for ProxyProtocol
where Arc<Inner>: Send, &'static str: Send, Arc<str>: Send,

§

impl Sync for ProxyProtocol
where Arc<Inner>: Sync, Arc<str>: Sync,

§

impl Unpin for ProxyProtocol
where Arc<Inner>: Unpin, &'static str: Unpin, Arc<str>: Unpin,

§

impl UnsafeUnpin for ProxyProtocol
where *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
where Arc<Inner>: UnwindSafe, &'static str: UnwindSafe, Arc<str>: UnwindSafe,

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a rama_grpc::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

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

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryFrom<T> for U
where 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 T
where 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 T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
§

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