async fn execute_command(&mut self) -> Result<()> {
        // async-std's ToSocketAddrs doesn't supports external trait implementation
        // @see https://github.com/async-rs/async-std/issues/539
        let addr = self
            .target_addr
            .as_ref()
            .context("target_addr empty")?
            .to_socket_addrs()?
            .next()
            .context("unreachable")?;

        let fut = TcpStream::connect(addr);
        let limit = Duration::from_secs(self.config.request_timeout);

        // TCP connect with timeout, to avoid memory leak for connection that takes forever
        let outbound = match timeout(limit, fut).await {
            Ok(e) => match e {
                Ok(o) => o,
                Err(e) => match e.kind() {
                    // Match other TCP errors with ReplyError
                    io::ErrorKind::ConnectionRefused => {
                        return Err(ReplyError::ConnectionRefused.into())
                    }
                    io::ErrorKind::ConnectionAborted => {
                        return Err(ReplyError::ConnectionNotAllowed.into())
                    }
                    io::ErrorKind::ConnectionReset => {
                        return Err(ReplyError::ConnectionNotAllowed.into())
                    }
                    io::ErrorKind::NotConnected => {
                        return Err(ReplyError::NetworkUnreachable.into())
                    }
                    _ => return Err(e.into()), // #[error("General failure")] ?
                },
            },
            // Wrap timeout error in a proper ReplyError
            Err(_) => return Err(ReplyError::TtlExpired.into()),
        };

        debug!("Connected to remote destination");

        // TODO: convert this to the real address
        self.inner
            .write(&[
                consts::SOCKS5_VERSION,
                consts::SOCKS5_REPLY_SUCCEEDED,
                0x00, // reserved
                1,    // address type (ipv4, v6, domain)
                127,  // ip
                0,
                0,
                1,
                0, // port
                0,
            ])
            .await
            .context("Can't write successful reply")?;

        self.inner.flush().await.context("Can't flush the reply!")?;

        debug!("Wrote success");

        transfer(&mut self.inner, outbound).await
    }
/// Connect to the target address that the client wants,
/// then forward the data between them (client <=> target address).
Connect to the target address that the client wants,
then forward the data between them (client <=> target address).
Connect to the target address that the client wants then forward the data between them ( client < = > target address ) .
async fn execute_command(&mut self) -> Result<()> {
        // async-std's ToSocketAddrs doesn't supports external trait implementation
        // @see https://github.com/async-rs/async-std/issues/539
        let addr = self
            .target_addr
            .as_ref()
            .context("target_addr empty")?
            .to_socket_addrs()?
            .next()
            .context("unreachable")?;
        let fut = TcpStream::connect(addr);
        let limit = Duration::from_secs(self.config.request_timeout);
        // TCP connect with timeout, to avoid memory leak for connection that takes forever
        let outbound = match timeout(limit, fut).await {
            Ok(e) => match e {
                Ok(o) => o,
                Err(e) => match e.kind() {
                    // Match other TCP errors with ReplyError
                    io::ErrorKind::ConnectionRefused => {
                        return Err(ReplyError::ConnectionRefused.into())
                    }
                    io::ErrorKind::ConnectionAborted => {
                        return Err(ReplyError::ConnectionNotAllowed.into())
                    }
                    io::ErrorKind::ConnectionReset => {
                        return Err(ReplyError::ConnectionNotAllowed.into())
                    }
                    io::ErrorKind::NotConnected => {
                        return Err(ReplyError::NetworkUnreachable.into())
                    }
                    _ => return Err(e.into()), // #[error("General failure")] ?
                },
            },
            // Wrap timeout error in a proper ReplyError
            Err(_) => return Err(ReplyError::TtlExpired.into()),
        };
        debug!("Connected to remote destination");
        // TODO: convert this to the real address
        self.inner
            .write(&[
                consts::SOCKS5_VERSION,
                consts::SOCKS5_REPLY_SUCCEEDED,
                0x00, // reserved
                1,    // address type (ipv4, v6, domain)
                127,  // ip
                0,
                0,
                1,
                0, // port
                0,
            ])
            .await
            .context("Can't write successful reply")?;
        self.inner.flush().await.context("Can't flush the reply!")?;
        debug!("Wrote success");
        transfer(&mut self.inner, outbound).await
    }
async fn execute_command ( & mut self ) -> Result < ( ) > { // async-std's ToSocketAddrs doesn't supports external trait implementation // @see https://github.com/async-rs/async-std/issues/539 let addr = self . target_addr . as_ref ( ) . context ( " " ) ? . to_socket_addrs ( ) ? . next ( ) . context ( " " ) ? ; let fut = TcpStream :: connect ( addr ) ; let limit = Duration :: from_secs ( self . config . request_timeout ) ; // TCP connect with timeout, to avoid memory leak for connection that takes forever let outbound = match timeout ( limit , fut ) . await { Ok ( e ) => match e { Ok ( o ) => o , Err ( e ) => match e . kind ( ) { // Match other TCP errors with ReplyError io :: ErrorKind :: ConnectionRefused => { return Err ( ReplyError :: ConnectionRefused . into ( ) ) } io :: ErrorKind :: ConnectionAborted => { return Err ( ReplyError :: ConnectionNotAllowed . into ( ) ) } io :: ErrorKind :: ConnectionReset => { return Err ( ReplyError :: ConnectionNotAllowed . into ( ) ) } io :: ErrorKind :: NotConnected => { return Err ( ReplyError :: NetworkUnreachable . into ( ) ) } _ => return Err ( e . into ( ) ) , // #[error("General failure")] ? } , } , // Wrap timeout error in a proper ReplyError Err ( _ ) => return Err ( ReplyError :: TtlExpired . into ( ) ) , } ; debug ! ( " " ) ; // TODO: convert this to the real address self . inner . write ( & [ consts :: SOCKS5_VERSION , consts :: SOCKS5_REPLY_SUCCEEDED , 0x00 , // reserved 1 , // address type (ipv4, v6, domain) 127 , // ip 0 , 0 , 1 , 0 , // port 0 , ] ) . await . context ( " " ) ? ; self . inner . flush ( ) . await . context ( " " ) ? ; debug ! ( " " ) ; transfer ( & mut self . inner , outbound ) . await }
Connect to the target address that the client wants,
then forward the data between them (client <=> target address).
Connect to the target address that the client wants then forward the data between them ( client < = > target address ) .
&mut self
&mut self