Notes & stuff

main
E. Almqvist 2 years ago
parent 29bca92cf1
commit ca4a570046
  1. 14
      src/scanner.rs

@ -16,6 +16,7 @@ fn tcp_scan(mut target: IPv4, target_port: u16, timeout: Duration) -> bool {
TCP_SCANS_ISSUED += 1; TCP_SCANS_ISSUED += 1;
} }
// TODO: Fix closed port viewed as "open"
if let Ok(_res) = TcpStream::connect_timeout(&dest, timeout) { if let Ok(_res) = TcpStream::connect_timeout(&dest, timeout) {
println!("{:?}", dest); println!("{:?}", dest);
true true
@ -126,17 +127,20 @@ impl ScanResult {
unsafe fn print_progress() { unsafe fn print_progress() {
let percent_done = (TCP_SCANS_ISSUED as f64 / TARGET_SCAN_TOTAL as f64) * 100_f64; let percent_done = (TCP_SCANS_ISSUED as f64 / TARGET_SCAN_TOTAL as f64) * 100_f64;
println!("* Progress: {}/{} [{:.2}%]", TCP_SCANS_ISSUED, TARGET_SCAN_TOTAL, percent_done); println!(
"* Progress: {}/{} [{:.2}%]",
TCP_SCANS_ISSUED, TARGET_SCAN_TOTAL, percent_done
);
} }
fn create_progress_worker() -> JoinHandle<()> { fn create_progress_worker() -> JoinHandle<()> {
thread::spawn(move || { thread::spawn(move || loop {
loop { unsafe {
unsafe { print_progress(); } print_progress();
}
let dur = Duration::new(5, 0); let dur = Duration::new(5, 0);
thread::sleep(dur); thread::sleep(dur);
}
}) })
} }

Loading…
Cancel
Save