|
|
@ -2,10 +2,7 @@ use crate::ipv4; |
|
|
|
use anyhow::Result; |
|
|
|
use anyhow::Result; |
|
|
|
use log::info; |
|
|
|
use log::info; |
|
|
|
//use std::thread;
|
|
|
|
//use std::thread;
|
|
|
|
use std::{ |
|
|
|
use std::net::{SocketAddr, TcpStream}; |
|
|
|
net::{SocketAddr, TcpStream}, |
|
|
|
|
|
|
|
//thread::JoinHandle,
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn tcp_scan(dest: &SocketAddr) -> bool { |
|
|
|
fn tcp_scan(dest: &SocketAddr) -> bool { |
|
|
|
if let Ok(res) = TcpStream::connect(dest) { |
|
|
|
if let Ok(res) = TcpStream::connect(dest) { |
|
|
@ -39,18 +36,18 @@ pub fn start_scan(target_port: u16, num_threads: u32, ignorelist: Option<Vec<u64 |
|
|
|
let ip_list = ipv4::get_all(ignorelist)?; |
|
|
|
let ip_list = ipv4::get_all(ignorelist)?; |
|
|
|
|
|
|
|
|
|
|
|
// casting hell
|
|
|
|
// casting hell
|
|
|
|
// let ips_per_thread = ((ip_list.len() as f32) / num_threads as f32) as u32;
|
|
|
|
// let ips_per_thread = ((ip_list.len() as f32) / num_threads as f32) as u32;
|
|
|
|
// let ips_left = num_threads * ips_per_thread; // how many IPs we have left after the first threads
|
|
|
|
// let ips_left = num_threads * ips_per_thread; // how many IPs we have left after the first threads
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// // Container for all of our threads
|
|
|
|
// // Container for all of our threads
|
|
|
|
// let mut threads: Vec<JoinHandle<()>> = Vec::new();
|
|
|
|
// let mut threads: Vec<JoinHandle<()>> = Vec::new();
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// // Create all of our threads
|
|
|
|
// // Create all of our threads
|
|
|
|
// for thread_id in 0..num_threads {
|
|
|
|
// for thread_id in 0..num_threads {
|
|
|
|
// threads.push( create_scan_thread(ip_list.borrow().clone(), thread_id, ips_per_thread) );
|
|
|
|
// threads.push( create_scan_thread(ip_list.borrow().clone(), thread_id, ips_per_thread) );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// // Create the last thread to do the job
|
|
|
|
// // Create the last thread to do the job
|
|
|
|
|
|
|
|
|
|
|
|
let mut results: Vec<bool> = Vec::new(); |
|
|
|
let mut results: Vec<bool> = Vec::new(); |
|
|
|
|
|
|
|
|
|
|
|