Struct tor_socksproto::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.

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

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

Try to advance a SocksProxyHandshake, given some proxy input in input.

If there isn’t enough input, gives a Truncated. In this case, the caller must retain the input, and pass it to a later invocation of handshake. Input should only be regarded as consumed when the Action::drain field is nonzero.

Other errors (besides Truncated) indicate a failure.

On success, return an Action describing what to tell the proxy, and how much of its input to consume.

source

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

Send the client side of the socks 4 handshake.

source

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

Handle a SOCKSv4 response.

source

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

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

source

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

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, input: &[u8]) -> Result<Action>

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, input: &[u8]) -> Result<Action>

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

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.

§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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