main
E. Almqvist 2 years ago
parent d6760bf800
commit cc2d6cbfa5
  1. 1
      src/cli.rs
  2. 3
      src/ipv4.rs
  3. 11
      src/scanner.rs

@ -22,7 +22,6 @@ pub struct Args {
// default_value = "ignore-ips-list.txt"
// )]
// pub ignorelist: PathBuf,
#[clap(
help = "Enable verbose (debug) output",
short = 'v',

@ -43,7 +43,8 @@ impl IPv4 {
Self { id, ip }
}
pub fn to_ipaddr(self: &mut Self) -> Result<IpAddr> { // TODO: remove unneeded Result returns
pub fn to_ipaddr(self: &mut Self) -> Result<IpAddr> {
// TODO: remove unneeded Result returns
if let [a, b, c, d] = self.ip[0..4] {
Ok(IpAddr::V4(Ipv4Addr::new(a, b, c, d)))
} else {

@ -1,6 +1,6 @@
use crate::ipv4::{IPv4, IPv4Range};
use core::time::Duration;
use log::{warn, debug, info};
use log::{debug, info, warn};
use std::net::TcpStream;
use std::thread::JoinHandle;
use std::{panic, thread};
@ -44,7 +44,6 @@ fn create_scan_worker(
ips_per_thread: u64,
target_port: u16,
) -> JoinHandle<Vec<(u32, bool)>> {
let ignorelist = range.id_ignore;
let (f, t) = (
@ -86,12 +85,7 @@ fn get_scan_workers(
// Clean up the rest
warn!("Number of IPv4 addresses is not divisible by the amount of threads! Creating extra thread...");
let worker = create_scan_worker(
range,
threads.len() as u64 + 1,
ips_left,
target_port
);
let worker = create_scan_worker(range, threads.len() as u64 + 1, ips_left, target_port);
threads.push(worker);
};
@ -136,7 +130,6 @@ pub fn start_scan(range: IPv4Range, target_port: u16, num_threads: u64) -> Vec<S
results.append(&mut worker_results);
}
println!("Scan finished with {} result(s).", results.len());
results
}

Loading…
Cancel
Save