Struct Connector
pub struct Connector<C, S> { /* private fields */ }socks5 only.Expand description
Proxy Forward Socks5Connector implementation,
which actually is able to accept connect requests and process them.
The Default implementation establishes a connection for the requested
destination HostWithPort and pipes the incoming Io with the established
outgoing Io by copying the bytes without doing anything else with them.
You can customise the Connector fully by creating it using
Connector::new or overwrite any of the default components using either or both of
Connector::with_connector and Connector::with_service.
§Lazy Connectors
Use LazyConnector only when application bytes are required before the
egress target can be selected. MITM proxies with a target from the SOCKS5
handshake should normally use this connector and inspect the resulting
BridgeIo with Rama’s Relay/Peek services.
Connection policy belongs in the connector stack. Wrap a custom connector
in TimeoutLayer when its connection attempts should be bounded.
Implementations§
§impl<C, S> Connector<C, S>
impl<C, S> Connector<C, S>
pub fn new(connector: C, service: S) -> Connector<C, S>
pub fn new(connector: C, service: S) -> Connector<C, S>
Create a new Connector.
In case you only wish to overwrite one of these components
you can also use a Default Connector and overwrite the specific component
using Connector::with_connector or Connector::with_service.
pub fn with_hide_local_address(self, hide: bool) -> Connector<C, S>
pub fn with_hide_local_address(self, hide: bool) -> Connector<C, S>
Define whether or not the local address is exposed as the bind address in the reply, by default it is exposed.
pub fn set_hide_local_address(&mut self, hide: bool) -> &mut Connector<C, S>
pub fn set_hide_local_address(&mut self, hide: bool) -> &mut Connector<C, S>
Define whether or not the local address is exposed as the bind address in the reply, by default it is exposed.
§impl<C, S> Connector<C, S>
impl<C, S> Connector<C, S>
pub fn with_connector<T>(self, connector: T) -> Connector<T, S>
pub fn with_connector<T>(self, connector: T) -> Connector<T, S>
Overwrite the Connector’s connector Service
used to establish the egress Io in the direction from target to source.
Any Service can be used as long as it has the signature:
(ConnectRequest)
-> (EstablishedConnection<T, ConnectRequest>, Into<BoxError>)Replacing a DefaultConnector’s connector removes its default
connect timeout. Wrap the new connector in TimeoutLayer when its
connection attempts should be bounded.
§impl Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
impl Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
pub fn default_with_exec(
exec: Executor,
) -> Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
pub fn default_with_exec( exec: Executor, ) -> Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
Create a DefaultConnector whose forward bridge observes graceful
shutdown via the given Executor.
Trait Implementations§
§impl Default for Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
impl Default for Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
§fn default() -> Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
fn default() -> Connector<Timeout<DnsConnector<TcpConnector>, LayerErrorStatic<Elapsed>>, IoForwardService>
Auto Trait Implementations§
impl<C, S> Freeze for Connector<C, S>
impl<C, S> RefUnwindSafe for Connector<C, S>where
C: RefUnwindSafe,
S: RefUnwindSafe,
impl<C, S> Send for Connector<C, S>
impl<C, S> Sync for Connector<C, S>
impl<C, S> Unpin for Connector<C, S>
impl<C, S> UnsafeUnpin for Connector<C, S>where
C: UnsafeUnpin,
S: UnsafeUnpin,
impl<C, S> UnwindSafe for Connector<C, S>where
C: UnwindSafe,
S: 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<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