Fixed worker UI
This commit is contained in:
+3
-31
@@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{config::Config, scan::check_port_open, terminal::TerminalUi};
|
||||||
config::Config,
|
|
||||||
scan::check_port_open,
|
|
||||||
terminal::{ScreenState, TerminalUi},
|
|
||||||
};
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use std::{net::Ipv4Addr, sync::Arc};
|
use std::{net::Ipv4Addr, sync::Arc};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@@ -38,14 +34,8 @@ pub async fn run_worker(config: Config, ui: Arc<TerminalUi>) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let job = parse_job_line(&line)?;
|
let job = parse_job_line(&line)?;
|
||||||
let result = execute_job(
|
let result =
|
||||||
&job.ips,
|
execute_job(&job.ips, config.port, config.timeout_ms, config.concurrency).await?;
|
||||||
config.port,
|
|
||||||
config.timeout_ms,
|
|
||||||
config.concurrency,
|
|
||||||
&ui,
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let result_line = format!(
|
let result_line = format!(
|
||||||
"RESULT {} {} {} {} {}\n",
|
"RESULT {} {} {} {} {}\n",
|
||||||
@@ -58,15 +48,6 @@ pub async fn run_worker(config: Config, ui: Arc<TerminalUi>) -> Result<()> {
|
|||||||
write_half.write_all(result_line.as_bytes()).await?;
|
write_half.write_all(result_line.as_bytes()).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ui.is_enabled() {
|
|
||||||
ui.render(&ScreenState {
|
|
||||||
current_ip: "concluído".to_string(),
|
|
||||||
tested: 0,
|
|
||||||
total: 0,
|
|
||||||
});
|
|
||||||
ui.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +119,6 @@ async fn execute_job(
|
|||||||
port: u16,
|
port: u16,
|
||||||
timeout_ms: u64,
|
timeout_ms: u64,
|
||||||
concurrency: usize,
|
concurrency: usize,
|
||||||
ui: &TerminalUi,
|
|
||||||
) -> Result<JobOutcome> {
|
) -> Result<JobOutcome> {
|
||||||
let mut tested = 0usize;
|
let mut tested = 0usize;
|
||||||
let mut open_ips = Vec::new();
|
let mut open_ips = Vec::new();
|
||||||
@@ -159,14 +139,6 @@ async fn execute_job(
|
|||||||
if is_open {
|
if is_open {
|
||||||
open_ips.push(ip);
|
open_ips.push(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ui.is_enabled() {
|
|
||||||
ui.render(&ScreenState {
|
|
||||||
current_ip: ip.to_string(),
|
|
||||||
tested,
|
|
||||||
total: ips.len(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index = end;
|
index = end;
|
||||||
|
|||||||
Reference in New Issue
Block a user