async fn initialize_attack(
        &mut self,
        socket: Option<Socket>,
    ) -> Result<SwanlingAttackRunState, SwanlingError> {
        trace!("initialize_attack");

        // Create a single channel used to send metrics from SwanlingUser threads
        // to parent thread.
        let (all_threads_metrics_tx, metrics_rx): (
            flume::Sender<SwanlingMetric>,
            flume::Receiver<SwanlingMetric>,
        ) = flume::unbounded();

        // Optionally spawn a telnet and/or Websocket Controller thread.
        let controller_channel_rx = self.setup_controllers().await;

        // Grab now() once from the standard library, used by multiple timers in
        // the run state.
        let std_now = std::time::Instant::now();

        let swanling_attack_run_state = SwanlingAttackRunState {
            spawn_user_timer: std_now,
            spawn_user_in_ms: 0,
            spawn_user_counter: 0,
            drift_timer: tokio::time::Instant::now(),
            all_threads_metrics_tx,
            metrics_rx,
            logger_handle: None,
            all_threads_logger_tx: None,
            throttle_threads_tx: None,
            parent_to_throttle_tx: None,
            controller_channel_rx,
            report_file: None,
            metrics_header_displayed: false,
            idle_status_displayed: false,
            users: Vec::new(),
            user_channels: Vec::new(),
            running_metrics_timer: std_now,
            display_running_metrics: false,
            all_users_spawned: false,
            shutdown_after_stop: !self.configuration.no_autostart,
            canceled: Arc::new(AtomicBool::new(false)),
            socket,
        };

        // Access socket to avoid errors.
        trace!("socket: {:?}", &swanling_attack_run_state.socket);

        // Catch ctrl-c to allow clean shutdown to display metrics.
        util::setup_ctrlc_handler(&swanling_attack_run_state.canceled);

        Ok(swanling_attack_run_state)
    }
// Create a SwanlingAttackRunState object and do all initialization required
// to start a [`SwanlingAttack`](./struct.SwanlingAttack.html).
Create a SwanlingAttackRunState object and do all initialization required
to start a [`SwanlingAttack`](./struct.SwanlingAttack.html).
Create a SwanlingAttackRunState object and do all initialization required to start a [ ` SwanlingAttack ` ] ( . / struct . SwanlingAttack . html ) .
async fn initialize_attack(
        &mut self,
        socket: Option<Socket>,
    ) -> Result<SwanlingAttackRunState, SwanlingError> {
        trace!("initialize_attack");
        // Create a single channel used to send metrics from SwanlingUser threads
        // to parent thread.
        let (all_threads_metrics_tx, metrics_rx): (
            flume::Sender<SwanlingMetric>,
            flume::Receiver<SwanlingMetric>,
        ) = flume::unbounded();
        // Optionally spawn a telnet and/or Websocket Controller thread.
        let controller_channel_rx = self.setup_controllers().await;
        // Grab now() once from the standard library, used by multiple timers in
        // the run state.
        let std_now = std::time::Instant::now();
        let swanling_attack_run_state = SwanlingAttackRunState {
            spawn_user_timer: std_now,
            spawn_user_in_ms: 0,
            spawn_user_counter: 0,
            drift_timer: tokio::time::Instant::now(),
            all_threads_metrics_tx,
            metrics_rx,
            logger_handle: None,
            all_threads_logger_tx: None,
            throttle_threads_tx: None,
            parent_to_throttle_tx: None,
            controller_channel_rx,
            report_file: None,
            metrics_header_displayed: false,
            idle_status_displayed: false,
            users: Vec::new(),
            user_channels: Vec::new(),
            running_metrics_timer: std_now,
            display_running_metrics: false,
            all_users_spawned: false,
            shutdown_after_stop: !self.configuration.no_autostart,
            canceled: Arc::new(AtomicBool::new(false)),
            socket,
        };
        // Access socket to avoid errors.
        trace!("socket: {:?}", &swanling_attack_run_state.socket);
        // Catch ctrl-c to allow clean shutdown to display metrics.
        util::setup_ctrlc_handler(&swanling_attack_run_state.canceled);
        Ok(swanling_attack_run_state)
    }
async fn initialize_attack ( & mut self , socket : Option < Socket > , ) -> Result < SwanlingAttackRunState , SwanlingError > { trace ! ( " " ) ; // Create a single channel used to send metrics from SwanlingUser threads // to parent thread. let ( all_threads_metrics_tx , metrics_rx ) : ( flume :: Sender < SwanlingMetric > , flume :: Receiver < SwanlingMetric > , ) = flume :: unbounded ( ) ; // Optionally spawn a telnet and/or Websocket Controller thread. let controller_channel_rx = self . setup_controllers ( ) . await ; // Grab now() once from the standard library, used by multiple timers in // the run state. let std_now = std :: time :: Instant :: now ( ) ; let swanling_attack_run_state = SwanlingAttackRunState { spawn_user_timer : std_now , spawn_user_in_ms : 0 , spawn_user_counter : 0 , drift_timer : tokio :: time :: Instant :: now ( ) , all_threads_metrics_tx , metrics_rx , logger_handle : None , all_threads_logger_tx : None , throttle_threads_tx : None , parent_to_throttle_tx : None , controller_channel_rx , report_file : None , metrics_header_displayed : false , idle_status_displayed : false , users : Vec :: new ( ) , user_channels : Vec :: new ( ) , running_metrics_timer : std_now , display_running_metrics : false , all_users_spawned : false , shutdown_after_stop : ! self . configuration . no_autostart , canceled : Arc :: new ( AtomicBool :: new ( false ) ) , socket , } ; // Access socket to avoid errors. trace ! ( " " swanling_attack_run_state socket ) ; // Catch ctrl-c to allow clean shutdown to display metrics. util :: setup_ctrlc_handler ( & swanling_attack_run_state . canceled ) ; Ok ( swanling_attack_run_state ) }
Create a SwanlingAttackRunState object and do all initialization required
to start a [`SwanlingAttack`](./struct.SwanlingAttack.html).
Create a SwanlingAttackRunState object and do all initialization required to start a [ ` SwanlingAttack ` ] ( . / struct . SwanlingAttack . html ) .
&mut self
socket
Option<Socket>