Struct SocksProxyHandshake

Source
pub struct SocksProxyHandshake {
    state: State,
    socks5_auth: Option<SocksAuth>,
    handshake: Option<SocksRequest>,
}
Available on crate feature proxy-handshake only.
Expand description

The Proxy (responder) side of an ongoing SOCKS handshake.

Create you have one of these with SocksProxyHandshake::new(), and then use Handshake::step to drive it.

Eventually you will hopefully obtain a SocksRequest, on which you should call .reply(), and send the resulting data to the peer.

Fields§

§state: State

Current state of the handshake. Each completed message advances the state.

§socks5_auth: Option<SocksAuth>

SOCKS5 authentication that has been received (but not yet put in a SocksRequest object.)

§handshake: Option<SocksRequest>

Completed SOCKS handshake.

Implementations§

Source§

impl SocksProxyHandshake

Source

pub fn new() -> Self

Construct a new SocksProxyHandshake in its initial state

Source

fn s4(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>

Complete a socks4 or socks4a handshake.

Source

fn s5_initial(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>

Socks5: initial handshake to negotiate authentication method.

Source

fn s5_uname(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>

Socks5: second step for username/password authentication.

Source

fn s5(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>

Socks5: final step, to receive client’s request.

Source

pub fn finished(&self) -> bool

Return true if this handshake is finished.

Source

pub fn into_request(self) -> Option<SocksRequest>

Consume this handshake’s state; if it finished successfully, return a SocksRequest.

Trait Implementations§

Source§

impl Clone for SocksProxyHandshake

Source§

fn clone(&self) -> SocksProxyHandshake

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SocksProxyHandshake

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SocksProxyHandshake

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Handshake for SocksProxyHandshake

Source§

type Output = <Option<SocksRequest> as IntoIterator>::Item

Available on crate features proxy-handshake or client-handshake only.
Output from the handshake: the meaning, as we understand it
Source§

fn step<'b, P: ReadPrecision>( &mut self, buffer: &'b mut Buffer<P>, ) -> Result<NextStep<'b, <Self as Handshake>::Output, P>, Error>

Available on crate features proxy-handshake or client-handshake only.
Drive a handshake forward, determining what the next step is Read more
Source§

fn handshake(&mut self, input: &[u8]) -> TResult<Action>

👎Deprecated: use the new Handshake::step API instead
Available on crate features proxy-handshake or client-handshake only.
Try to advance the handshake, given some peer input in input. Read more
Source§

impl HandshakeImpl for SocksProxyHandshake

Source§

fn handshake_impl(&mut self, input: &mut Reader<'_>) -> Result<ImplNextStep>

Available on crate features proxy-handshake or client-handshake only.
Actual implementation, to be provided Read more
Source§

fn call_handshake_impl(&mut self, input: &[u8]) -> (usize, Result<ImplNextStep>)

Available on crate features proxy-handshake or client-handshake only.
Helper, used by public API implementations to call handshake_impl. Read more
Source§

impl HasHandshakeOutput<<Option<SocksRequest> as IntoIterator>::Item> for SocksProxyHandshake

Source§

fn take_output( &mut self, ) -> Option<<Option<SocksRequest> as IntoIterator>::Item>

Available on crate features proxy-handshake or client-handshake only.
Obtain the output from a handshake completed with .handshake Read more
Source§

impl HasHandshakeState for SocksProxyHandshake

Source§

fn set_failed(&mut self)

Available on crate features proxy-handshake or client-handshake only.
Set the state to Failed

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T