From 0ead50c0c7581cd250158ca1b420a77771e55d6b Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 11 Aug 2022 21:04:14 +0200 Subject: [PATCH] Formatting --- src/ipv4.rs | 8 ++++---- src/scanner.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/ipv4.rs b/src/ipv4.rs index 6decc6c..96db3ae 100644 --- a/src/ipv4.rs +++ b/src/ipv4.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, } -impl IPv4_Range { +impl IPv4Range { pub fn new(from: u32, to: u32, id_ignore: Option>) -> 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 { diff --git a/src/scanner.rs b/src/scanner.rs index d384868..abcb893 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -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> { +fn create_scan_thread( + thread_id: u32, + ip_range: IPv4Range, + target_port: u16, +) -> JoinHandle> { thread::spawn(move || { info!("Starting thread worker #{}", thread_id); let mut results: Vec = 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); }