Struct SocksClientHandshake

Source
pub struct SocksClientHandshake {
    request: SocksRequest,
    state: State,
    reply: Option<SocksReply>,
}
Available on crate feature client-handshake only.
Expand description

The client (initiator) side of a SOCKS handshake.

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

Fields§

§request: SocksRequest

The request that we are currently trying to negotiate with the proxy.

§state: State

Our current state in negotiating that request.

§reply: Option<SocksReply>

If present, the return message that we received from the proxy.

Implementations§

Source§

impl SocksClientHandshake

Source

pub fn new(request: SocksRequest) -> Self

Construct a new SocksClientHandshake that will attempt to negotiate with a peer using request.

Source

pub fn into_reply(self) -> Option<SocksReply>

Consume this handshake’s state; if it finished successfully, return the SocksReply that we got from the proxy..

Source

fn send_v4(&mut self) -> Result<ImplNextStep>

Send the client side of the socks 4 handshake.

Source

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

Handle a SOCKSv4 response.

Source

fn send_v5_initial(&mut self) -> Result<ImplNextStep>

Send our initial socks5 message (which negotiates our authentication methods).

Source

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

Try to handle a socks5 reply telling us what authentication method to use, and reply as appropriate.

Source

fn generate_v5_username_auth(&self) -> Result<Vec<u8>>

Return a message to perform username/password authentication.

Source

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

Try to handle a reply from the socks5 proxy to acknowledge our username/password authentication, and reply as appropriate.

Source

fn generate_v5_command(&self) -> Result<Vec<u8>>

Return a message to encode our final socks5 request.

(This can be done either in response getting an ACK for our authentication, or in response to being told that we don’t need to authenticate.)

Source

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

Handle a final socks5 reply.

Trait Implementations§

Source§

impl Clone for SocksClientHandshake

Source§

fn clone(&self) -> SocksClientHandshake

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 SocksClientHandshake

Source§

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

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

impl Handshake for SocksClientHandshake

Source§

type Output = <Option<SocksReply> 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 SocksClientHandshake

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<SocksReply> as IntoIterator>::Item> for SocksClientHandshake

Source§

fn take_output(&mut self) -> Option<<Option<SocksReply> 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 SocksClientHandshake

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