async fn start(&mut self, tx_stats: CommandSender) -> Result<()> {
        log::trace!("enter: start({:?})", tx_stats);

        while let Some(command) = self.receiver.recv().await {
            match command {
                Command::Report(mut resp) => {
                    let contains_sentry =
                        self.config.status_codes.contains(&resp.status().as_u16());
                    let unknown_sentry = !RESPONSES.contains(&resp); // !contains == unknown
                    let should_process_response = contains_sentry && unknown_sentry;

                    if should_process_response {
                        // print to stdout
                        ferox_print(&resp.as_str(), &PROGRESS_PRINTER);

                        send_command!(tx_stats, AddToUsizeField(ResourcesDiscovered, 1));

                        if self.file_task.is_some() {
                            // -o used, need to send the report to be written out to disk
                            self.tx_file
                                .send(Command::Report(resp.clone()))
                                .with_context(|| {
                                    fmt_err(&format!("Could not send {} to file handler", resp))
                                })?;
                        }
                    }
                    log::trace!("report complete: {}", resp.url());

                    if self.config.replay_client.is_some() && should_process_response {
                        // replay proxy specified/client created and this response's status code is one that
                        // should be replayed; not using logged_request due to replay proxy client
                        make_request(
                            self.config.replay_client.as_ref().unwrap(),
                            resp.url(),
                            self.config.output_level,
                            &self.config,
                            tx_stats.clone(),
                        )
                        .await
                        .with_context(|| "Could not replay request through replay proxy")?;
                    }

                    if should_process_response {
                        // add response to RESPONSES for serialization in case of ctrl+c
                        // placed all by its lonesome like this so that RESPONSES can take ownership
                        // of the FeroxResponse

                        // before ownership is transferred, there's no real reason to keep the body anymore
                        // so we can free that piece of data, reducing memory usage
                        resp.drop_text();

                        RESPONSES.insert(*resp);
                    }
                }
                Command::Sync(sender) => {
                    sender.send(true).unwrap_or_default();
                }
                Command::Exit => {
                    if self.file_task.is_some() && self.tx_file.send(Command::Exit).is_ok() {
                        self.file_task.as_mut().unwrap().await??; // wait for death
                    }
                    break;
                }
                _ => {} // no more commands needed
            }
        }
        log::trace!("exit: start");
        Ok(())
    }
/// Start a single consumer task (sc side of mpsc)
///
/// The consumer simply receives `Command` and acts accordingly
Start a single consumer task (sc side of mpsc)
The consumer simply receives `Command` and acts accordingly
Start a single consumer task ( sc side of mpsc ) The consumer simply receives ` Command ` and acts accordingly
async fn start(&mut self, tx_stats: CommandSender) -> Result<()> {
        log::trace!("enter: start({:?})", tx_stats);
        while let Some(command) = self.receiver.recv().await {
            match command {
                Command::Report(mut resp) => {
                    let contains_sentry =
                        self.config.status_codes.contains(&resp.status().as_u16());
                    let unknown_sentry = !RESPONSES.contains(&resp); // !contains == unknown
                    let should_process_response = contains_sentry && unknown_sentry;
                    if should_process_response {
                        // print to stdout
                        ferox_print(&resp.as_str(), &PROGRESS_PRINTER);
                        send_command!(tx_stats, AddToUsizeField(ResourcesDiscovered, 1));
                        if self.file_task.is_some() {
                            // -o used, need to send the report to be written out to disk
                            self.tx_file
                                .send(Command::Report(resp.clone()))
                                .with_context(|| {
                                    fmt_err(&format!("Could not send {} to file handler", resp))
                                })?;
                        }
                    }
                    log::trace!("report complete: {}", resp.url());
                    if self.config.replay_client.is_some() && should_process_response {
                        // replay proxy specified/client created and this response's status code is one that
                        // should be replayed; not using logged_request due to replay proxy client
                        make_request(
                            self.config.replay_client.as_ref().unwrap(),
                            resp.url(),
                            self.config.output_level,
                            &self.config,
                            tx_stats.clone(),
                        )
                        .await
                        .with_context(|| "Could not replay request through replay proxy")?;
                    }
                    if should_process_response {
                        // add response to RESPONSES for serialization in case of ctrl+c
                        // placed all by its lonesome like this so that RESPONSES can take ownership
                        // of the FeroxResponse
                        // before ownership is transferred, there's no real reason to keep the body anymore
                        // so we can free that piece of data, reducing memory usage
                        resp.drop_text();
                        RESPONSES.insert(*resp);
                    }
                }
                Command::Sync(sender) => {
                    sender.send(true).unwrap_or_default();
                }
                Command::Exit => {
                    if self.file_task.is_some() && self.tx_file.send(Command::Exit).is_ok() {
                        self.file_task.as_mut().unwrap().await??; // wait for death
                    }
                    break;
                }
                _ => {} // no more commands needed
            }
        }
        log::trace!("exit: start");
        Ok(())
    }
async fn start ( & mut self , tx_stats : CommandSender ) -> Result < ( ) > { log :: trace ! ( " " tx_stats ) ; while let Some ( command ) = self . receiver . recv ( ) . await { match command { Command :: Report ( mut resp ) => { let contains_sentry = self . config . status_codes . contains ( & resp . status ( ) . as_u16 ( ) ) ; let unknown_sentry = ! RESPONSES . contains ( & resp ) ; // !contains == unknown let should_process_response = contains_sentry && unknown_sentry ; if should_process_response { // print to stdout ferox_print ( & resp . as_str ( ) , & PROGRESS_PRINTER ) ; send_command ! ( tx_stats AddToUsizeField ( ResourcesDiscovered 1 ) ) ; if self . file_task . is_some ( ) { // -o used, need to send the report to be written out to disk self . tx_file . send ( Command :: Report ( resp . clone ( ) ) ) . with_context ( | | { fmt_err ( & format ! ( " " resp ) ) } ) ? ; } } log :: trace ! ( " " resp url ( ) ) ; if self . config . replay_client . is_some ( ) && should_process_response { // replay proxy specified/client created and this response's status code is one that // should be replayed; not using logged_request due to replay proxy client make_request ( self . config . replay_client . as_ref ( ) . unwrap ( ) , resp . url ( ) , self . config . output_level , & self . config , tx_stats . clone ( ) , ) . await . with_context ( | | " " ) ? ; } if should_process_response { // add response to RESPONSES for serialization in case of ctrl+c // placed all by its lonesome like this so that RESPONSES can take ownership // of the FeroxResponse // before ownership is transferred, there's no real reason to keep the body anymore // so we can free that piece of data, reducing memory usage resp . drop_text ( ) ; RESPONSES . insert ( * resp ) ; } } Command :: Sync ( sender ) => { sender . send ( true ) . unwrap_or_default ( ) ; } Command :: Exit => { if self . file_task . is_some ( ) && self . tx_file . send ( Command :: Exit ) . is_ok ( ) { self . file_task . as_mut ( ) . unwrap ( ) . await ? ? ; // wait for death } break ; } _ => { } // no more commands needed } } log :: trace ! ( " " ) ; Ok ( ( ) ) }
Start a single consumer task (sc side of mpsc)
The consumer simply receives `Command` and acts accordingly
Start a single consumer task ( sc side of mpsc ) The consumer simply receives ` Command ` and acts accordingly
&mut self
tx_stats
CommandSender