main
E. Almqvist 2 years ago
parent 87702bbdd0
commit 0ead50c0c7
  1. 6
      src/ipv4.rs
  2. 10
      src/scanner.rs

@ -54,13 +54,13 @@ impl IPv4 {
} }
} }
pub struct IPv4_Range { pub struct IPv4Range {
pub id_start: u32, pub id_start: u32,
pub id_end: u32, pub id_end: u32,
pub id_ignore: Vec<u32>, pub id_ignore: Vec<u32>,
} }
impl IPv4_Range { impl IPv4Range {
pub fn new(from: u32, to: u32, id_ignore: Option<Vec<u32>>) -> Self { pub fn new(from: u32, to: u32, id_ignore: Option<Vec<u32>>) -> Self {
to = to.clamp(0, u32::max_value()); to = to.clamp(0, u32::max_value());
@ -76,7 +76,7 @@ impl IPv4_Range {
} }
} }
impl Iterator for IPv4_Range { impl Iterator for IPv4Range {
type Item = u32; type Item = u32;
fn next(&mut self) -> Option<u32> { fn next(&mut self) -> Option<u32> {

@ -1,4 +1,4 @@
use crate::ipv4::{IPv4, IPv4_Range}; use crate::ipv4::{IPv4, IPv4Range};
use anyhow::Result; use anyhow::Result;
use log::info; use log::info;
use std::net::TcpStream; use std::net::TcpStream;
@ -17,7 +17,11 @@ fn tcp_scan(mut target: IPv4, target_port: u16) -> bool {
// false // false
} }
fn create_scan_thread(thread_id: u32, ip_range: IPv4_Range, target_port: u16) -> JoinHandle<Vec<bool>> { fn create_scan_thread(
thread_id: u32,
ip_range: IPv4Range,
target_port: u16,
) -> JoinHandle<Vec<bool>> {
thread::spawn(move || { thread::spawn(move || {
info!("Starting thread worker #{}", thread_id); info!("Starting thread worker #{}", thread_id);
let mut results: Vec<bool> = Vec::new(); let mut results: Vec<bool> = Vec::new();
@ -55,7 +59,7 @@ pub fn start_scan(
(thread_id * ips_per_thread), (thread_id * ips_per_thread),
((thread_id + 1) * ips_per_thread), ((thread_id + 1) * ips_per_thread),
); );
let range = IPv4_Range::new(f, t, ignorelist); let range = IPv4Range::new(f, t, ignorelist);
// Create a worker // Create a worker
let worker = create_scan_thread(thread_id, range, target_port); let worker = create_scan_thread(thread_id, range, target_port);

Loading…
Cancel
Save