Struct Socks5PeekRouter
pub struct Socks5PeekRouter<T, F = RejectService<(), NoSocks5RejectError>> { /* private fields */ }socks5 only.Expand description
A Service router that can be used to support
socks5 traffic as well as non-socks5 traffic.
By default non-socks5 traffic is rejected using RejectService.
Use Socks5PeekRouter::with_fallback to configure the fallback service.
A definitive non-SOCKS5 prefix invokes that fallback under either timeout
policy; an inconclusive timeout is fail-open by default and can be made
fail-closed with Socks5PeekRouter::with_peek_timeout_policy.
This kind of router can be useful in case you want to have a proxy which supports for example both HTTP proxy requests as well socks5 proxy requests.
Implementations§
§impl<T> Socks5PeekRouter<T>
impl<T> Socks5PeekRouter<T>
pub fn new(socks5_acceptor: T) -> Socks5PeekRouter<T>
pub fn new(socks5_acceptor: T) -> Socks5PeekRouter<T>
Create a new Socks5PeekRouter.
pub fn with_fallback<F>(self, fallback: F) -> Socks5PeekRouter<T, F>
pub fn with_fallback<F>(self, fallback: F) -> Socks5PeekRouter<T, F>
Attach a fallback Service tp this Socks5PeekRouter.
§impl<T, F> Socks5PeekRouter<T, F>
impl<T, F> Socks5PeekRouter<T, F>
pub fn maybe_with_peek_timeout(
self,
peek_timeout: Option<Duration>,
) -> Socks5PeekRouter<T, F>
pub fn maybe_with_peek_timeout( self, peek_timeout: Option<Duration>, ) -> Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn maybe_set_peek_timeout(
&mut self,
peek_timeout: Option<Duration>,
) -> &mut Socks5PeekRouter<T, F>
pub fn maybe_set_peek_timeout( &mut self, peek_timeout: Option<Duration>, ) -> &mut Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn with_peek_timeout(self, peek_timeout: Duration) -> Socks5PeekRouter<T, F>
pub fn with_peek_timeout(self, peek_timeout: Duration) -> Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn set_peek_timeout(
&mut self,
peek_timeout: Duration,
) -> &mut Socks5PeekRouter<T, F>
pub fn set_peek_timeout( &mut self, peek_timeout: Duration, ) -> &mut Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn without_peek_timeout(self) -> Socks5PeekRouter<T, F>
pub fn without_peek_timeout(self) -> Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn unset_peek_timeout(&mut self) -> &mut Socks5PeekRouter<T, F>
pub fn unset_peek_timeout(&mut self) -> &mut Socks5PeekRouter<T, F>
Set the maximum time spent peeking for a SOCKS5 greeting.
A timeout is inconclusive. Use
Socks5PeekRouter::with_peek_timeout_policy to choose whether it
invokes the fallback or rejects the connection.
pub fn with_peek_timeout_policy(
self,
peek_timeout_policy: PeekTimeoutPolicy,
) -> Socks5PeekRouter<T, F>
pub fn with_peek_timeout_policy( self, peek_timeout_policy: PeekTimeoutPolicy, ) -> Socks5PeekRouter<T, F>
Set how an inconclusive peek timeout is handled.
Defaults to PeekTimeoutPolicy::FailOpen. A definitive non-SOCKS5
prefix invokes the fallback under either policy.
pub fn set_peek_timeout_policy(
&mut self,
peek_timeout_policy: PeekTimeoutPolicy,
) -> &mut Socks5PeekRouter<T, F>
pub fn set_peek_timeout_policy( &mut self, peek_timeout_policy: PeekTimeoutPolicy, ) -> &mut Socks5PeekRouter<T, F>
Set how an inconclusive peek timeout is handled.
Defaults to PeekTimeoutPolicy::FailOpen. A definitive non-SOCKS5
prefix invokes the fallback under either policy.
Trait Implementations§
§impl<T, F> Clone for Socks5PeekRouter<T, F>
impl<T, F> Clone for Socks5PeekRouter<T, F>
§fn clone(&self) -> Socks5PeekRouter<T, F>
fn clone(&self) -> Socks5PeekRouter<T, F>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl<T, F> Debug for Socks5PeekRouter<T, F>
impl<T, F> Debug for Socks5PeekRouter<T, F>
§impl<PeekableInput, Output, T, F> Service<PeekableInput> for Socks5PeekRouter<T, F>where
PeekableInput: PeekIoProvider,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
Output: Send + 'static,
T: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<T as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Sync + Send>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Sync + Send>>,
impl<PeekableInput, Output, T, F> Service<PeekableInput> for Socks5PeekRouter<T, F>where
PeekableInput: PeekIoProvider,
<PeekableInput as PeekIoProvider>::PeekIo: Unpin,
Output: Send + 'static,
T: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<T as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Sync + Send>>,
F: Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>, Output = Output>,
<F as Service<<PeekableInput as PeekIoProvider>::Mapped<PrefixedIo<StackReader<rama_socks5::::server::peek::Socks5PrefixedIo::{constant#0}>, <PeekableInput as PeekIoProvider>::PeekIo>>>>::Error: Into<Box<dyn Error + Sync + Send>>,
§async fn serve(
&self,
input: PeekableInput,
) -> Result<<Socks5PeekRouter<T, F> as Service<PeekableInput>>::Output, <Socks5PeekRouter<T, F> as Service<PeekableInput>>::Error>
async fn serve( &self, input: PeekableInput, ) -> Result<<Socks5PeekRouter<T, F> as Service<PeekableInput>>::Output, <Socks5PeekRouter<T, F> 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<T, F> Freeze for Socks5PeekRouter<T, F>
impl<T, F> RefUnwindSafe for Socks5PeekRouter<T, F>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F> Send for Socks5PeekRouter<T, F>
impl<T, F> Sync for Socks5PeekRouter<T, F>
impl<T, F> Unpin for Socks5PeekRouter<T, F>
impl<T, F> UnsafeUnpin for Socks5PeekRouter<T, F>where
T: UnsafeUnpin,
F: UnsafeUnpin,
impl<T, F> UnwindSafe for Socks5PeekRouter<T, F>where
T: 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
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> 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