Struct tor_socksproto::msg::SocksRequest

source ·
pub struct SocksRequest {
    version: SocksVersion,
    cmd: SocksCmd,
    addr: SocksAddr,
    port: u16,
    auth: SocksAuth,
}
Expand description

A completed SOCKS request, as negotiated on a SOCKS connection.

Once this request is done, we know where to connect. Don’t discard this object immediately: Use it to report success or failure.

Fields§

§version: SocksVersion

Negotiated SOCKS protocol version.

§cmd: SocksCmd

The command requested by the SOCKS client.

§addr: SocksAddr

The target address.

§port: u16

The target port.

§auth: SocksAuth

Authentication information.

(Tor doesn’t believe in SOCKS authentication, since it cannot possibly secure. Instead, we use it for circuit isolation.)

Implementations§

source§

impl SocksRequest

source

pub fn reply( &self, status: SocksStatus, addr: Option<&SocksAddr> ) -> EncodeResult<Vec<u8>>

Available on crate feature proxy-handshake only.

Format a reply to this request, indicating success or failure.

Note that an address should be provided only when the request was for a RESOLVE.

source

fn s4( &self, status: SocksStatus, addr: Option<&SocksAddr> ) -> EncodeResult<Vec<u8>>

Available on crate feature proxy-handshake only.

Format a SOCKS4 reply.

source

fn s5( &self, status: SocksStatus, addr: Option<&SocksAddr> ) -> EncodeResult<Vec<u8>>

Available on crate feature proxy-handshake only.

Format a SOCKS5 reply.

source§

impl SocksRequest

source

pub fn new( version: SocksVersion, cmd: SocksCmd, addr: SocksAddr, port: u16, auth: SocksAuth ) -> Result<Self>

Create a SocksRequest with a given set of fields.

Return an error if the inputs aren’t supported or valid.

source

pub fn version(&self) -> SocksVersion

Return the negotiated version (4 or 5).

source

pub fn command(&self) -> SocksCmd

Return the command that the client requested.

source

pub fn auth(&self) -> &SocksAuth

Return the ‘authentication’ information from this request.

source

pub fn port(&self) -> u16

Return the requested port.

source

pub fn addr(&self) -> &SocksAddr

Return the requested address.

Trait Implementations§

source§

impl<'a> Arbitrary<'a> for SocksRequest

Available on crate feature arbitrary only.
source§

fn arbitrary(u: &mut Unstructured<'a>) -> ArbitraryResult<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for SocksRequest

source§

fn clone(&self) -> SocksRequest

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 SocksRequest

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