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

@ -15,14 +15,13 @@ pub struct Args {
)] )]
pub threads: u64, pub threads: u64,
// #[clap( // #[clap(
// help = "A file containing ignored IPv4 addresses (seperated by linebreaks).", // help = "A file containing ignored IPv4 addresses (seperated by linebreaks).",
// short = 'i', // short = 'i',
// long = "ignore-ip-list", // long = "ignore-ip-list",
// default_value = "ignore-ips-list.txt" // default_value = "ignore-ips-list.txt"
// )] // )]
// pub ignorelist: PathBuf, // pub ignorelist: PathBuf,
#[clap( #[clap(
help = "Enable verbose (debug) output", help = "Enable verbose (debug) output",
short = 'v', short = 'v',

@ -43,7 +43,8 @@ impl IPv4 {
Self { id, ip } 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] { if let [a, b, c, d] = self.ip[0..4] {
Ok(IpAddr::V4(Ipv4Addr::new(a, b, c, d))) Ok(IpAddr::V4(Ipv4Addr::new(a, b, c, d)))
} else { } else {

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

Loading…
Cancel
Save