pub async fn upgrade_to_socks5(mut self) -> Result<Socks5Socket<T>> {
        trace!("upgrading to socks5...");

        // Handshake
        if !self.config.skip_auth {
            let methods = self.get_methods().await?;

            self.can_accept_method(methods).await?;

            if self.config.auth.is_some() {
                let credentials = self.authenticate().await?;
                self.auth = AuthenticationMethod::Password {
                    username: credentials.0,
                    password: credentials.1,
                };
            }
        } else {
            debug!("skipping auth");
        }

        match self.request().await {
            Ok(_) => {}
            Err(SocksError::ReplyError(e)) => {
                // If a reply error has been returned, we send it to the client
                self.reply(&e).await?;
                return Err(e.into()); // propagate the error to end this connection's task
            }
            // if any other errors has been detected, we simply end connection's task
            Err(d) => return Err(d),
        };

        Ok(self)
    }
/// Process clients SOCKS requests
/// This is the entry point where a whole request is processed.
Process clients SOCKS requests
This is the entry point where a whole request is processed.
Process clients SOCKS requests This is the entry point where a whole request is processed .
pub async fn upgrade_to_socks5(mut self) -> Result<Socks5Socket<T>> {
        trace!("upgrading to socks5...");
        // Handshake
        if !self.config.skip_auth {
            let methods = self.get_methods().await?;
            self.can_accept_method(methods).await?;
            if self.config.auth.is_some() {
                let credentials = self.authenticate().await?;
                self.auth = AuthenticationMethod::Password {
                    username: credentials.0,
                    password: credentials.1,
                };
            }
        } else {
            debug!("skipping auth");
        }
        match self.request().await {
            Ok(_) => {}
            Err(SocksError::ReplyError(e)) => {
                // If a reply error has been returned, we send it to the client
                self.reply(&e).await?;
                return Err(e.into()); // propagate the error to end this connection's task
            }
            // if any other errors has been detected, we simply end connection's task
            Err(d) => return Err(d),
        };
        Ok(self)
    }
pub async fn upgrade_to_socks5 ( mut self ) -> Result < Socks5Socket < T > > { trace ! ( " " ) ; // Handshake if ! self . config . skip_auth { let methods = self . get_methods ( ) . await ? ; self . can_accept_method ( methods ) . await ? ; if self . config . auth . is_some ( ) { let credentials = self . authenticate ( ) . await ? ; self . auth = AuthenticationMethod :: Password { username : credentials . 0 , password : credentials . 1 , } ; } } else { debug ! ( " " ) ; } match self . request ( ) . await { Ok ( _ ) => { } Err ( SocksError :: ReplyError ( e ) ) => { // If a reply error has been returned, we send it to the client self . reply ( & e ) . await ? ; return Err ( e . into ( ) ) ; // propagate the error to end this connection's task } // if any other errors has been detected, we simply end connection's task Err ( d ) => return Err ( d ) , } ; Ok ( self ) }
Process clients SOCKS requests
This is the entry point where a whole request is processed.
Process clients SOCKS requests This is the entry point where a whole request is processed .
mut self
mut self