Struct PeekTlsClientHelloService
pub struct PeekTlsClientHelloService<S, F = RejectService<(), NoTlsRejectError>, Pol = PeekPolicy> { /* private fields */ }tls only.Expand description
A peek Service which returns the ClientHello to the inner
service for tls-detected traffic, and otherwise make use of the Reject service.
The difference with SniRouter is that the entire
ClientHello is parsed and returned instead of just the SNI. Use the router
in case all you care about is the SNI. Both use the same validated hello.
By default non-tls traffic is rejected using RejectService.
Use PeekTlsClientHelloService::with_fallback to configure the fallback service.
Non-TLS traffic invokes that fallback. By default malformed, over-limit, or
EOF-truncated TLS also invokes it, with a ClientHelloPeekStatus extension
identifying the failure. Use PeekTlsClientHelloService::with_malformed_tls_policy
to opt into rejection. With the default PeekPolicy::FAIL_OPEN, a
prefix cut off by a cancelled scope also invokes the fallback. Strict SNI routing should select
MalformedTlsPolicy::Reject and a PeekPolicy that never falls back on
partial input, see PeekTlsClientHelloService::with_peek_policy.
Use the standalone peek_client_hello_from_input function if you prefer
this is as a standalone function instead.
Implementations§
§impl<S> PeekTlsClientHelloService<S>
impl<S> PeekTlsClientHelloService<S>
pub fn new(service: S) -> PeekTlsClientHelloService<S>
pub fn new(service: S) -> PeekTlsClientHelloService<S>
Create a new PeekTlsClientHelloService.
§impl<S, Pol> PeekTlsClientHelloService<S, RejectService<(), NoTlsRejectError>, Pol>
impl<S, Pol> PeekTlsClientHelloService<S, RejectService<(), NoTlsRejectError>, Pol>
pub fn with_fallback<F>(
self,
fallback: F,
) -> PeekTlsClientHelloService<S, F, Pol>
pub fn with_fallback<F>( self, fallback: F, ) -> PeekTlsClientHelloService<S, F, Pol>
Attach a fallback Service to this PeekTlsClientHelloService.
Used for non-TLS traffic and whenever the configured peek policies select fallback.
§impl<S, F, Pol> PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> PeekTlsClientHelloService<S, F, Pol>
pub fn with_malformed_tls_policy(
self,
policy: MalformedTlsPolicy,
) -> PeekTlsClientHelloService<S, F, Pol>
pub fn with_malformed_tls_policy( self, policy: MalformedTlsPolicy, ) -> PeekTlsClientHelloService<S, F, Pol>
Choose whether unparseable, over-limit, or EOF-truncated TLS is sent to the fallback (the default) or rejected. This does not change the reassembly bounds or peek policy.
pub fn set_malformed_tls_policy(
&mut self,
policy: MalformedTlsPolicy,
) -> &mut PeekTlsClientHelloService<S, F, Pol>
pub fn set_malformed_tls_policy( &mut self, policy: MalformedTlsPolicy, ) -> &mut PeekTlsClientHelloService<S, F, Pol>
Choose whether unparseable, over-limit, or EOF-truncated TLS is sent to the fallback (the default) or rejected. This does not change the reassembly bounds or peek policy.
pub fn with_reassembly_config(
self,
config: ClientHelloReassemblyConfig,
) -> PeekTlsClientHelloService<S, F, Pol>
pub fn with_reassembly_config( self, config: ClientHelloReassemblyConfig, ) -> PeekTlsClientHelloService<S, F, Pol>
Configure ClientHello size, record count, and legacy-version checks. Defaults to 256 KiB across 256 records with tolerant legacy versions.
pub fn set_reassembly_config(
&mut self,
config: ClientHelloReassemblyConfig,
) -> &mut PeekTlsClientHelloService<S, F, Pol>
pub fn set_reassembly_config( &mut self, config: ClientHelloReassemblyConfig, ) -> &mut PeekTlsClientHelloService<S, F, Pol>
Configure ClientHello size, record count, and legacy-version checks. Defaults to 256 KiB across 256 records with tolerant legacy versions.
pub fn with_max_egress_peek_size(
self,
max_egress_peek_size: NonZero<usize>,
) -> PeekTlsClientHelloService<S, F, Pol>
pub fn with_max_egress_peek_size( self, max_egress_peek_size: NonZero<usize>, ) -> PeekTlsClientHelloService<S, F, Pol>
Set the byte limit for peeking the egress.
pub fn set_max_egress_peek_size(
&mut self,
max_egress_peek_size: NonZero<usize>,
) -> &mut PeekTlsClientHelloService<S, F, Pol>
pub fn set_max_egress_peek_size( &mut self, max_egress_peek_size: NonZero<usize>, ) -> &mut PeekTlsClientHelloService<S, F, Pol>
Set the byte limit for peeking the egress.
pub fn with_peek_policy<Pol2>(
self,
peek_policy: Pol2,
) -> PeekTlsClientHelloService<S, F, Pol2>
pub fn with_peek_policy<Pol2>( self, peek_policy: Pol2, ) -> PeekTlsClientHelloService<S, F, Pol2>
Set how a peek cutoff is handled, using a
static PeekPolicy or a PeekPolicyProvider that selects one per input.
Defaults to PeekPolicy::FAIL_OPEN. Non-TLS traffic invokes
the fallback; malformed TLS follows the separate malformed-TLS policy.
Trait Implementations§
§impl<S, F, Pol> Clone for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Clone for PeekTlsClientHelloService<S, F, Pol>
§fn clone(&self) -> PeekTlsClientHelloService<S, F, Pol>
fn clone(&self) -> PeekTlsClientHelloService<S, F, Pol>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<S, F, Pol> Debug for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Debug for PeekTlsClientHelloService<S, F, Pol>
§impl<S, F, Pol> ExtensionsRef for PeekTlsClientHelloService<S, F, Pol>where
S: ExtensionsRef,
impl<S, F, Pol> ExtensionsRef for PeekTlsClientHelloService<S, F, Pol>where
S: ExtensionsRef,
§fn extensions(&self) -> &Extensions
fn extensions(&self) -> &Extensions
Extensions store§impl<PeekableInput, Output, S, F, Pol> Service<PeekableInput> for PeekTlsClientHelloService<S, F, Pol>where
PeekableInput: PeekIoProvider + ExtensionsRef,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
<PeekableInput as PeekIoProvider>::PeekEgressIo: Unpin,
Output: Send + 'static,
Pol: PeekPolicyProvider<PeekableInput>,
S: Service<InputWithClientHello<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>, Output = Output>,
<S as Service<InputWithClientHello<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
impl<PeekableInput, Output, S, F, Pol> Service<PeekableInput> for PeekTlsClientHelloService<S, F, Pol>where
PeekableInput: PeekIoProvider + ExtensionsRef,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
<PeekableInput as PeekIoProvider>::PeekEgressIo: Unpin,
Output: Send + 'static,
Pol: PeekPolicyProvider<PeekableInput>,
S: Service<InputWithClientHello<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>, Output = Output>,
<S as Service<InputWithClientHello<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<HeapReader, <PeekableInput as PeekIoProvider>::PeekIo>, PrefixedIo<ReplayReader, <PeekableInput as PeekIoProvider>::PeekEgressIo>>>>::Error: Into<Box<dyn Error + Send + Sync>>,
§async fn serve(
&self,
input: PeekableInput,
) -> Result<<PeekTlsClientHelloService<S, F, Pol> as Service<PeekableInput>>::Output, <PeekTlsClientHelloService<S, F, Pol> as Service<PeekableInput>>::Error>
async fn serve( &self, input: PeekableInput, ) -> Result<<PeekTlsClientHelloService<S, F, Pol> as Service<PeekableInput>>::Output, <PeekTlsClientHelloService<S, F, Pol> as Service<PeekableInput>>::Error>
§fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
fn boxed(self) -> BoxService<Input, Self::Output, Self::Error>
Auto Trait Implementations§
impl<S, F, Pol> Forget for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Freeze for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Move for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> RefUnwindSafe for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Send for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Sync for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> Unpin for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> UnsafeUnpin for PeekTlsClientHelloService<S, F, Pol>
impl<S, F, Pol> UnwindSafe for PeekTlsClientHelloService<S, F, Pol>
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<S, Input, Connection> ConnectorService<Input> for Swhere
S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>,
<S as Service<Input>>::Error: Into<ConnectionError>,
Connection: Send + ExtensionsRef,
impl<S, Input, Connection> ConnectorService<Input> for Swhere
S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>,
<S as Service<Input>>::Error: Into<ConnectionError>,
Connection: Send + ExtensionsRef,
§type Connection = Connection
type Connection = Connection
ConnectorService§fn connect(
&self,
input: Input,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, ConnectionError>> + Send
fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Input>>::Connection, Input>, ConnectionError>> + Send
§impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
impl<T> ForwardedClientExt for Twhere
T: ExtensionsRef + ?Sized,
§fn trusted_forwarded(&self) -> Option<&Forwarded>
fn trusted_forwarded(&self) -> Option<&Forwarded>
§fn forwarded_client(&self) -> Option<&ForwardedElement>
fn forwarded_client(&self) -> Option<&ForwardedElement>
§fn forwarded_client_ip(&self) -> Option<IpAddr>
fn forwarded_client_ip(&self) -> Option<IpAddr>
for node.§fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
fn forwarded_client_socket_addr(&self) -> Option<SocketAddress>
for node.§fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
fn forwarded_client_host(&self) -> Option<&ForwardedAuthority>
§fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
fn forwarded_client_proto(&self) -> Option<ForwardedProtocol>
§fn forwarded_client_version(&self) -> Option<ForwardedVersion>
fn forwarded_client_version(&self) -> Option<ForwardedVersion>
§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