Skip to main content

ChainExecutor

Struct ChainExecutor 

Source
pub struct ChainExecutor { /* private fields */ }
Expand description

Executor for proxy chains.

Establishes a connection through a series of proxy hops, performing the appropriate protocol handshake at each step.

§Chain Execution Flow

Transport to hop 1
→ TLS wrap (if hop.tls)
→ protocol handshake requesting hop 2
→ TLS wrap (if hop.tls)
→ protocol handshake requesting hop 3
→ final protocol handshake requesting destination

Implementations§

Source§

impl ChainExecutor

Source

pub fn new(handlers: Vec<Box<dyn HopHandler>>) -> Self

Creates a new ChainExecutor with the given protocol handlers.

Source

pub fn with_tls_wrapper(self, wrapper: TlsWrapper) -> Self

Set a TLS wrapper for upstream hops with tls: true.

Source

pub fn with_shared_tls_config(self, config: Option<Arc<ClientConfig>>) -> Self

Set a shared TLS client config for protocols that need their own TLS handshake (e.g., Trojan).

Source

pub fn shared_tls_config(&self) -> Option<&Arc<ClientConfig>>

Get the shared TLS client config, if set.

Source

pub async fn execute( &self, chain: &[ProxyHopSpec], target: &TargetAddr, ) -> Result<BoxStream, ChainError>

Execute a proxy chain to connect to the target.

§Arguments
  • chain - The ordered list of proxy hops
  • target - The final destination to connect to
§Returns

A connected stream ready for data transfer, or a ChainError.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.