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

@ -54,19 +54,19 @@ impl IPv4 {
}
}
pub struct IPv4_Range {
pub struct IPv4Range {
pub id_start: u32,
pub id_end: u32,
pub id_ignore: Vec<u32>,
}
impl IPv4_Range {
impl IPv4Range {
pub fn new(from: u32, to: u32, id_ignore: Option<Vec<u32>>) -> Self {
to = to.clamp(0, u32::max_value());
if from >= to {
panic!("Range size must be >= 1! from: {} >= to: {}", from, to);
}
}
Self {
id_start: from,
@ -76,7 +76,7 @@ impl IPv4_Range {
}
}
impl Iterator for IPv4_Range {
impl Iterator for IPv4Range {
type Item = 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 log::info;
use std::net::TcpStream;
@ -17,7 +17,11 @@ fn tcp_scan(mut target: IPv4, target_port: u16) -> bool {
// 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 || {
info!("Starting thread worker #{}", thread_id);
let mut results: Vec<bool> = Vec::new();
@ -55,9 +59,9 @@ pub fn start_scan(
(thread_id * 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);
threads.push(worker);
}

Loading…
Cancel
Save