pub struct ProxyConnectorBuilder<C = (), S = (), D = ()> { /* private fields */ }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
impl ProxyConnectorBuilder
Sourcepub fn new(scope: impl Into<WeakScope>) -> Self
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>
impl<C, S, D> ProxyConnectorBuilder<C, S, D>
Sourcepub fn with_custom_connector<L: Layer<C>>(
self,
connector_layer: L,
) -> ProxyConnectorBuilder<L::Service, S, D>
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.
Sourcepub fn map_connector<C2>(
self,
map_fn: impl FnOnce(C) -> C2,
) -> ProxyConnectorBuilder<C2, S, D>
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>
impl<D> ProxyConnectorBuilder<(), (), D>
Sourcepub fn with_default_transport_connector(
self,
) -> ProxyConnectorBuilder<TcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>
Available on crate feature quic and (crate features boring or rustls) only.
pub fn with_default_transport_connector( self, ) -> ProxyConnectorBuilder<TcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>
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.
Sourcepub fn with_default_quic_connector(
self,
) -> ProxyConnectorBuilder<NoTcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>
Available on crate feature quic and (crate features boring or rustls) only.
pub fn with_default_quic_connector( self, ) -> ProxyConnectorBuilder<NoTcpConnector, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>
quic and (crate features boring or rustls) only.Dial proxies over QUIC only, which makes every proxy but an h3:// one unreachable.
Sourcepub fn with_default_tcp_connector(
self,
) -> ProxyConnectorBuilder<TcpConnector, TransportStage, D>
pub fn with_default_tcp_connector( self, ) -> ProxyConnectorBuilder<TcpConnector, TransportStage, D>
Dial proxies over TCP only, which makes an h3:// proxy unreachable.
Sourcepub fn with_custom_tcp_connector<T>(
self,
connector: T,
) -> ProxyConnectorBuilder<T, TransportStage, D>
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.
Sourcepub 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.
pub fn with_custom_quic_connector<E>( self, endpoints: E, ) -> ProxyConnectorBuilder<NoTcpConnector, TransportStage<QuicLeg<E>>, D>
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>
impl<T, E, D> ProxyConnectorBuilder<T, TransportStage<QuicLeg<E>>, D>
Sourcepub fn with_quic_transport_config(self, transport: TransportConfig) -> Self
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>
impl<T, Q, D> ProxyConnectorBuilder<T, TransportStage<Q>, D>
Sourcepub fn with_custom_quic_connector<E>(
self,
endpoints: E,
) -> ProxyConnectorBuilder<T, TransportStage<QuicLeg<E>>, D>
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.
Sourcepub fn with_default_quic_connector(
self,
) -> ProxyConnectorBuilder<T, TransportStage<QuicLeg<SharedQuicEndpoint>>, D>
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>
impl<T, Q, D> ProxyConnectorBuilder<T, TransportStage<Q>, D>
Sourcepub fn with_custom_tcp_connector<T2>(
self,
connector: T2,
) -> ProxyConnectorBuilder<T2, TransportStage<Q>, D>
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.
Sourcepub fn with_default_dns_connector(
self,
) -> ProxyConnectorBuilder<DnsConnector<T>, DnsStage<Q>, DnsConnectorLayer>
pub fn with_default_dns_connector( self, ) -> ProxyConnectorBuilder<DnsConnector<T>, DnsStage<Q>, DnsConnectorLayer>
Resolve the addresses of proxies with the default resolver.
Sourcepub fn with_dns_address_resolver<R: DnsAddressResolver + Clone>(
self,
resolver: R,
) -> ProxyConnectorBuilder<DnsConnector<T, R>, DnsStage<Q>, DnsConnectorLayer<R>>
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.
Sourcepub fn without_dns_connector(self) -> ProxyConnectorBuilder<T, DnsStage<Q>, ()>
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>
impl<T, Q, D> ProxyConnectorBuilder<T, DnsStage<Q>, D>
Sourcepub fn with_tls_support_using_boringssl(
self,
config: TlsClientConfig,
) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>
Available on crate feature boring only.
pub fn with_tls_support_using_boringssl( self, config: TlsClientConfig, ) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>
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.
Sourcepub fn with_tls_support_using_rustls(
self,
config: TlsClientConfig,
) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>
Available on crate feature rustls only.
pub fn with_tls_support_using_rustls( self, config: TlsClientConfig, ) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>
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.
Sourcepub fn with_custom_tls_connector<L: Layer<T>>(
self,
connector_layer: L,
) -> ProxyConnectorBuilder<L::Service, TlsStage<false, (), Q>, D>
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.
Sourcepub fn with_default_tls_support(
self,
config: TlsClientConfig,
) -> ProxyConnectorBuilder<TlsConnector<T>, TlsStage<false, TlsClientConfig, Q>, D>
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.
Sourcepub fn without_tls_support(
self,
) -> ProxyConnectorBuilder<PlaintextProxyOnly<T>, TlsStage<false, (), Q>, D>
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>
impl<T: Clone, Tls, Q, D> ProxyConnectorBuilder<T, TlsStage<false, Tls, Q>, D>
Sourcepub fn with_custom_http_connector<B, L: Layer<T>>(
self,
connector_layer: L,
) -> ProxyConnectorBuilder<L::Service, ProxyHttpStage<T, B>, D>
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>
impl<T: Clone, Q, D> ProxyConnectorBuilder<T, TlsStage<false, (), Q>, D>
Sourcepub fn with_default_http_connector<B>(
self,
) -> ProxyConnectorBuilder<HttpConnector<T, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>
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>
impl<T: Clone, D> ProxyConnectorBuilder<T, TlsStage<false, TlsClientConfig, ()>, D>
Sourcepub fn with_default_http_connector<B>(
self,
) -> ProxyConnectorBuilder<HttpConnector<T, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>
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>
impl<T: Clone, D, E> ProxyConnectorBuilder<T, TlsStage<false, TlsClientConfig, QuicLeg<E>>, D>
Sourcepub fn with_quic_tls_provider(
self,
provider: Arc<dyn QuicClientConfigProvider>,
) -> Self
Available on crate feature quic only.
pub fn with_quic_tls_provider( self, provider: Arc<dyn QuicClientConfigProvider>, ) -> Self
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.
Sourcepub fn with_default_http_connector<B>(
self,
) -> ProxyConnectorBuilder<HttpConnector<HttpTransportConnector<T, D::Service>, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>where
E: ConnectorService<ConnectRequest, Connection = ClientEndpoint> + Clone,
D: Layer<Http3Connector<E>>,
D::Service: Service<ConnectRequest, Output = EstablishedClientConnection<Http3Transport, ConnectRequest>, Error = ConnectionError> + Send + Sync + 'static,
Available on crate feature quic only.
pub fn with_default_http_connector<B>(
self,
) -> ProxyConnectorBuilder<HttpConnector<HttpTransportConnector<T, D::Service>, ProxyRequestBody<B>>, ProxyHttpStage<T, B>, D>where
E: ConnectorService<ConnectRequest, Connection = ClientEndpoint> + Clone,
D: Layer<Http3Connector<E>>,
D::Service: Service<ConnectRequest, Output = EstablishedClientConnection<Http3Transport, ConnectRequest>, Error = ConnectionError> + Send + Sync + 'static,
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>where
C: ConnectorService<ConnectRequest>,
impl<T, C, B, D> ProxyConnectorBuilder<C, ProxyHttpStage<T, B>, D>where
C: ConnectorService<ConnectRequest>,
Sourcepub fn with_default_connection_pool(
self,
) -> ProxyMethodBuilder<T, ProxyServiceConnector<HttpPooledConnector<C>>, B>
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.
Sourcepub fn with_connection_pool(
self,
config: HttpPooledConnectorConfig,
) -> ProxyMethodBuilder<T, ProxyServiceConnector<HttpPooledConnector<C>>, B>
pub fn with_connection_pool( self, config: HttpPooledConnectorConfig, ) -> ProxyMethodBuilder<T, ProxyServiceConnector<HttpPooledConnector<C>>, B>
Self::with_default_connection_pool, with the given pool configuration.
Sourcepub fn without_connection_pool(
self,
) -> ProxyMethodBuilder<T, ProxyServiceConnector<C>, B>
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§
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>
impl<C, S, D> Move for ProxyConnectorBuilder<C, S, D>
impl<C, S, D> Send for ProxyConnectorBuilder<C, S, D>
impl<C, S, D> Sync for ProxyConnectorBuilder<C, S, D>
impl<C, S, D> Unpin for ProxyConnectorBuilder<C, S, D>
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§
§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
§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