Skip to main content

ProxyConnectorBuilder

Struct ProxyConnectorBuilder 

Source
pub struct ProxyConnectorBuilder<C = (), S = (), D = ()> { /* private fields */ }
Available on crate features dns and http-backend and http and std and tcp only.
Expand description

Builds the connections towards proxies of a client, which are client connections of their own and share nothing with the connections to origins.

Its stages are those of EasyHttpConnectorBuilder up to the HTTP connections, which is all a proxy needs: a proxy is never reached through another proxy. The proxy methods spoken on those connections follow, see ProxyMethodBuilder.

Implementations§

Source§

impl ProxyConnectorBuilder

Source

pub fn new(scope: impl Into<WeakScope>) -> Self

Create a new ProxyConnectorBuilder whose connections and tunnels run in scope; see ProxyConnector::builder.

Source§

impl<C, S, D> ProxyConnectorBuilder<C, S, D>

Source

pub fn with_custom_connector<L: Layer<C>>( self, connector_layer: L, ) -> ProxyConnectorBuilder<L::Service, S, D>

Add a custom connector around the connector built so far, keeping the stage.

Before the HTTP stage, that is the stream connector of the TCP-based proxy connections, SOCKS5 included. HTTP/3 proxies use the separate QUIC connector.

After the HTTP stage, the layer wraps the HTTP connector towards proxies. A pool added later sits above it, so the layer only runs when the pool opens a new connection. SOCKS5 keeps the stream connector from before and does not see this layer.

Source

pub fn map_connector<C2>( self, map_fn: impl FnOnce(C) -> C2, ) -> ProxyConnectorBuilder<C2, S, D>

Map the connector built so far, keeping the stage; see Self::with_custom_connector.

Right after the TLS stage, before HTTP, this is how every connection to a proxy is secured, also one whose address does not ask for TLS: .map_connector(|tls| tls.into_secure()).

Source§

impl<D> ProxyConnectorBuilder<(), (), D>

Source

pub fn with_default_transport_connector( self, ) -> ProxyConnectorBuilder<TcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>

Available on crate feature quic and (crate features boring or rustls) only.

Dial proxies over TCP, and over QUIC for an h3:// proxy where this build has a QUIC TLS backend.

Source

pub fn with_default_quic_connector( self, ) -> ProxyConnectorBuilder<NoTcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>

Available on crate feature quic and (crate features boring or rustls) only.

Dial proxies over QUIC only, which makes every proxy but an h3:// one unreachable.

Source

pub fn with_default_tcp_connector( self, ) -> ProxyConnectorBuilder<TcpConnector, TransportStage, D>

Dial proxies over TCP only, which makes an h3:// proxy unreachable.

Source

pub fn with_custom_tcp_connector<T>( self, connector: T, ) -> ProxyConnectorBuilder<T, TransportStage, D>

Dial proxies over connector only: this first call is the only transport leg, so no h3:// proxy is reachable unless a QUIC leg is added with ProxyConnectorBuilder::with_custom_quic_connector.

Source

pub fn with_custom_quic_connector<E>( self, endpoints: E, ) -> ProxyConnectorBuilder<NoTcpConnector, TransportStage<QuicLeg<E>>, D>

Available on crate feature quic and (crate features boring or rustls) only.

Dial proxies over the QUIC endpoints endpoints hands out only: this first call is the only transport leg, which makes every proxy but an h3:// one unreachable unless a TCP leg is added with ProxyConnectorBuilder::with_custom_tcp_connector.

Source§

impl<T, E, D> ProxyConnectorBuilder<T, TransportStage<QuicLeg<E>>, D>

Source

pub fn with_quic_transport_config(self, transport: TransportConfig) -> Self

Configure the QUIC transport of the connections to h3:// proxies, replacing the default one, which leaves a MASQUE proxy room for tunneled QUIC packets.

Source§

impl<T, Q, D> ProxyConnectorBuilder<T, TransportStage<Q>, D>

Source

pub fn with_custom_quic_connector<E>( self, endpoints: E, ) -> ProxyConnectorBuilder<T, TransportStage<QuicLeg<E>>, D>

Reach an h3:// proxy over the QUIC endpoints endpoints hands out, instead of the built-in ones or none: on a builder which already has a transport this swaps the QUIC leg and keeps the TCP leg.

Source

pub fn with_default_quic_connector( self, ) -> ProxyConnectorBuilder<T, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>

Reach an h3:// proxy over the built-in QUIC endpoints, keeping the TCP leg chosen before, such as a custom one.

Source§

impl<T, Q, D> ProxyConnectorBuilder<T, TransportStage<Q>, D>

Source

pub fn with_custom_tcp_connector<T2>( self, connector: T2, ) -> ProxyConnectorBuilder<T2, TransportStage<Q>, D>

Dial proxies over connector instead of the TCP leg chosen before, keeping the QUIC leg: with_default_transport_connector().with_custom_tcp_connector(c) dials every proxy over c and keeps rama’s default QUIC endpoints for an h3:// one.

Source

pub fn with_default_dns_connector( self, ) -> ProxyConnectorBuilder<DnsConnector<T>, DnsStage<Q>, DnsConnectorLayer>

Resolve the addresses of proxies with the default resolver.

Source

pub fn with_dns_address_resolver<R: DnsAddressResolver + Clone>( self, resolver: R, ) -> ProxyConnectorBuilder<DnsConnector<T, R>, DnsStage<Q>, DnsConnectorLayer<R>>

Resolve the addresses of proxies with resolver, on both legs.

Source

pub fn without_dns_connector(self) -> ProxyConnectorBuilder<T, DnsStage<Q>, ()>

Leave resolving the addresses of proxies to the transport connectors.

Source§

impl<T, Q, D> ProxyConnectorBuilder<T, DnsStage<Q>, D>

Source

pub fn with_tls_support_using_boringssl( self, config: TlsClientConfig, ) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>

Available on crate feature boring only.

Secure the connection to a proxy whose address asks for TLS, using boringssl.

config secures both legs, but its ALPN only applies to TCP: the QUIC leg always offers h3.

Source

pub fn with_tls_support_using_rustls( self, config: TlsClientConfig, ) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>

Available on crate feature rustls only.

Secure the connection to a proxy whose address asks for TLS, using rustls.

config secures both legs, but its ALPN only applies to TCP: the QUIC leg always offers h3.

Source

pub fn with_custom_tls_connector<L: Layer<T>>( self, connector_layer: L, ) -> ProxyConnectorBuilder<L::Service, TlsStage<false, (), Q>, D>

Secure the connection to a proxy with the given TLS connector; the QUIC leg gets no TLS from it, so no h3:// proxy is reachable.

It must attach rama_tls::client::NegotiatedTlsParameters to the connections it secures: rama uses this as positive proof that TLS was negotiated, and sends nothing to an https:// proxy without it.

Source

pub fn with_default_tls_support( self, config: TlsClientConfig, ) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>

Secure the connection to a proxy whose address asks for TLS, with the TLS implementation this build of rama prefers.

Source

pub fn without_tls_support( self, ) -> ProxyConnectorBuilder<PlaintextProxyOnly<T>, TlsStage<false, (), Q>, D>

Reach proxies in plaintext only: an https:// or h3:// proxy is refused before it is dialed.

Source§

impl<T: Clone, Tls, Q, D> ProxyConnectorBuilder<T, TlsStage<false, Tls, Q>, D>

Source

pub fn with_custom_http_connector<B, L: Layer<T>>( self, connector_layer: L, ) -> ProxyConnectorBuilder<L::Service, ProxyHttpStage<T, B>, D>

Speak HTTP to a proxy over a connector of your own, built on the connections dialed so far, instead of the one Self::with_default_http_connector builds; the QUIC leg is left out.

B is the body type sent to a proxy, which is the one the client serves origins with. Its connections report the HTTP version they speak in a TargetHttpVersion, as HttpConnector does: a proxy address that names a version is checked against it.

Source§

impl<T: Clone, Q, D> ProxyConnectorBuilder<T, TlsStage<false, (), Q>, D>

Source

pub fn with_default_http_connector<B>( self, ) -> ProxyConnectorBuilder<HttpConnector<T, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>

Speak HTTP to a proxy over the TCP leg, in the version its ProxyAddress asks for. Without TLS there is no HTTP/3 proxy: that runs over QUIC, which is always secure.

B is the body type sent to a proxy, which is the one the client serves origins with.

Source§

impl<T: Clone, D> ProxyConnectorBuilder<T, TlsStage<false, TlsClientConfig, ()>, D>

Source

pub fn with_default_http_connector<B>( self, ) -> ProxyConnectorBuilder<HttpConnector<T, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>

Speak HTTP to a proxy over the TCP leg, in the version its ProxyAddress asks for; there is no QUIC leg for an h3:// proxy.

B is the body type sent to a proxy, which is the one the client serves origins with.

Source§

impl<T: Clone, D, E> ProxyConnectorBuilder<T, TlsStage<false, TlsClientConfig, QuicLeg<E>>, D>

Source

pub fn with_quic_tls_provider( self, provider: Arc<dyn QuicClientConfigProvider>, ) -> Self

Available on crate feature quic only.

Build the QUIC TLS configurations through provider instead of the backend the TLS stage selected, so the QUIC leg can use another backend than the TCP leg.

Source

pub fn with_default_http_connector<B>( self, ) -> ProxyConnectorBuilder<HttpConnector<HttpTransportConnector<T, D::Service>, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>

Available on crate feature quic only.

Speak HTTP to a proxy in the version its ProxyAddress asks for: over the TCP leg, or over the QUIC leg for an h3:// proxy, on the TLS of the stage before this one and the same DNS policy for both.

B is the body type sent to a proxy, which is the one the client serves origins with.

Source§

impl<T, C, B, D> ProxyConnectorBuilder<C, ProxyHttpStage<T, B>, D>

Source

pub fn with_default_connection_pool( self, ) -> ProxyMethodBuilder<T, ProxyServiceConnector<HttpPooledConnector<C>>, B>

Pool the HTTP connections to a proxy with rama’s defaults, so the tunnels and forwarded requests through one proxy share its HTTP/2 and HTTP/3 connections.

Outside the pool sit HTTPS-record discovery and Alt-Svc, as on an origin, so an https:// proxy without a version is reached over HTTP/3 when it advertises it.

Source

pub fn with_connection_pool( self, config: HttpPooledConnectorConfig, ) -> ProxyMethodBuilder<T, ProxyServiceConnector<HttpPooledConnector<C>>, B>

Self::with_default_connection_pool, with the given pool configuration.

Source

pub fn without_connection_pool( self, ) -> ProxyMethodBuilder<T, ProxyServiceConnector<C>, B>

Give every tunnel and forwarded request a connection to the proxy of its own, with the discovery and Alt-Svc of Self::with_default_connection_pool.

Trait Implementations§

Source§

impl<C: Debug, S: Debug, D: Debug> Debug for ProxyConnectorBuilder<C, S, D>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C = (), S = (), D = ()> !RefUnwindSafe for ProxyConnectorBuilder<C, S, D>

§

impl<C = (), S = (), D = ()> !UnwindSafe for ProxyConnectorBuilder<C, S, D>

§

impl<C, S, D> Forget for ProxyConnectorBuilder<C, S, D>

§

impl<C, S, D> Freeze for ProxyConnectorBuilder<C, S, D>
where C: Freeze, S: Freeze, D: Freeze, *const ArcInner<Node> is !null: Freeze, PhantomData<ArcInner<Node>>: Freeze, *const ArcInner<Composite> is !null: Freeze, PhantomData<ArcInner<Composite>>: Freeze,

§

impl<C, S, D> Move for ProxyConnectorBuilder<C, S, D>

§

impl<C, S, D> Send for ProxyConnectorBuilder<C, S, D>
where D: Send, S: Send, C: Send, Arc<Node>: Send, Arc<Composite>: Send,

§

impl<C, S, D> Sync for ProxyConnectorBuilder<C, S, D>
where D: Sync, S: Sync, C: Sync, Arc<Node>: Sync, Arc<Composite>: Sync,

§

impl<C, S, D> Unpin for ProxyConnectorBuilder<C, S, D>
where D: Unpin, S: Unpin, C: Unpin, Arc<Node>: Unpin, Arc<Composite>: Unpin,

§

impl<C, S, D> UnsafeUnpin for ProxyConnectorBuilder<C, S, D>
where C: UnsafeUnpin, S: UnsafeUnpin, D: UnsafeUnpin, *const ArcInner<Node> is !null: UnsafeUnpin, PhantomData<ArcInner<Node>>: UnsafeUnpin, *const ArcInner<Composite> is !null: UnsafeUnpin, PhantomData<ArcInner<Composite>>: UnsafeUnpin,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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, 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