Struct SniRouter
pub struct SniRouter<S, F = RejectService<(), NoTlsRejectError>> { /* private fields */ }
Expand description
A Service
router that can be used to support
routing of tls traffic as well as non-tls traffic.
The difference with [TlsPeekRouter
] is that the SniRouter
continues to parse after the initial couple of bytes,
in order to learn more about underlying traffic. This allowing
you to route based on the SNI from the client hello,
among other capabilities.
By default non-tls traffic is rejected using RejectService
.
Use SniRouter::with_fallback
to configure the fallback service.
Implementations§
Trait Implementations§
§impl<Stream, Response, S, F> Service<Stream> for SniRouter<S, F>where
Stream: Stream + Unpin,
Response: Send + 'static,
S: Service<SniRequest<Stream>, Response = Response>,
<S as Service<SniRequest<Stream>>>::Error: Into<Box<dyn Error + Sync + Send>>,
F: Service<PeekStream<StackReader<rama_net::::tls::server::peek::TlsPeekStream::{constant#0}>, Stream>, Response = Response>,
<F as Service<PeekStream<StackReader<rama_net::::tls::server::peek::TlsPeekStream::{constant#0}>, Stream>>>::Error: Into<Box<dyn Error + Sync + Send>>,
impl<Stream, Response, S, F> Service<Stream> for SniRouter<S, F>where
Stream: Stream + Unpin,
Response: Send + 'static,
S: Service<SniRequest<Stream>, Response = Response>,
<S as Service<SniRequest<Stream>>>::Error: Into<Box<dyn Error + Sync + Send>>,
F: Service<PeekStream<StackReader<rama_net::::tls::server::peek::TlsPeekStream::{constant#0}>, Stream>, Response = Response>,
<F as Service<PeekStream<StackReader<rama_net::::tls::server::peek::TlsPeekStream::{constant#0}>, Stream>>>::Error: Into<Box<dyn Error + Sync + Send>>,
§async fn serve(
&self,
ctx: Context,
stream: Stream,
) -> Result<<SniRouter<S, F> as Service<Stream>>::Response, <SniRouter<S, F> as Service<Stream>>::Error>
async fn serve( &self, ctx: Context, stream: Stream, ) -> Result<<SniRouter<S, F> as Service<Stream>>::Response, <SniRouter<S, F> as Service<Stream>>::Error>
Serve a response or error for the given request,
using the given context.
§fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>
Box this service to allow for dynamic dispatch.
Auto Trait Implementations§
impl<S, F> Freeze for SniRouter<S, F>
impl<S, F> RefUnwindSafe for SniRouter<S, F>where
S: RefUnwindSafe,
F: RefUnwindSafe,
impl<S, F> Send for SniRouter<S, F>
impl<S, F> Sync for SniRouter<S, F>
impl<S, F> Unpin for SniRouter<S, F>
impl<S, F> UnwindSafe for SniRouter<S, F>where
S: UnwindSafe,
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<S, Request, Connection> ConnectorService<Request> for S
impl<S, Request, Connection> ConnectorService<Request> for S
§type Connection = Connection
type Connection = Connection
Connection returned by the
ConnectorService
§fn connect(
&self,
ctx: Context,
req: Request,
) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Request>>::Connection, Request>, <S as ConnectorService<Request>>::Error>> + Send
fn connect( &self, ctx: Context, req: Request, ) -> impl Future<Output = Result<EstablishedClientConnection<<S as ConnectorService<Request>>::Connection, Request>, <S as ConnectorService<Request>>::Error>> + Send
Establish a connection, which often involves some kind of handshake,
or connection revival.
§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> ⓘ
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 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> ⓘ
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> 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>
Create a new
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
impl<T, U> RamaTryInto<U> for Twhere
U: RamaTryFrom<T>,
type Error = <U as RamaTryFrom<T>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<S, RequestIn, RequestOut> RequestInspector<RequestIn> for S
impl<S, RequestIn, RequestOut> RequestInspector<RequestIn> for S
type RequestOut = RequestOut
§fn inspect_request(
&self,
ctx: Context,
req: RequestIn,
) -> impl Future<Output = Result<(Context, <S as RequestInspector<RequestIn>>::RequestOut), <S as RequestInspector<RequestIn>>::Error>> + Send
fn inspect_request( &self, ctx: Context, req: RequestIn, ) -> impl Future<Output = Result<(Context, <S as RequestInspector<RequestIn>>::RequestOut), <S as RequestInspector<RequestIn>>::Error>> + Send
Inspect the request, modify it if needed or desired, and return it.