pub struct Scanner {Show 14 fields
pub if_index: u32,
pub if_name: String,
pub src_mac: [u8; 6],
pub dst_mac: [u8; 6],
pub src_ip: IpAddr,
pub src_port: u16,
pub destinations: Vec<Destination>,
pub scan_type: ScanType,
pub timeout: Duration,
pub wait_time: Duration,
pub send_rate: Duration,
pub scan_result: ScanResult,
pub tx: Arc<Mutex<Sender<SocketAddr>>>,
pub rx: Arc<Mutex<Receiver<SocketAddr>>>,
}Available on crate feature
sync only.Expand description
Host Scanner
§Example
fn main() -> Result<(), String> {
#[cfg(feature = "sync")]
{
use e_libscanner::sync_scan;
use e_libscanner::Opts;
use std::thread;
// more command information use: -h
let mut scanner = Opts::new(Some(&[
"e-libscanner",
"--ips",
"192.168.1.0/24",
"192.168.2-3.1-10",
"baidu.com",
"--model",
"sync",
"--scan",
"Icmp",
"--no-gui",
"--",
"-AS",
]))?
.init()?
.downcast::<sync_scan::Scanner>()
.unwrap();
let rx = scanner.get_progress_receiver();
// Run scan
let handle = thread::spawn(move || scanner.scan(None));
// Print progress
while let Ok(socket_addr) = rx.lock().unwrap().recv() {
println!("Check: {}", socket_addr);
}
let result = handle.join().unwrap();
// Print results
println!("Status: {:?}", result.scan_status);
println!("UP Hosts:");
let len = result.ips.len();
for host in result.ips {
println!("{:?}", host);
}
println!("Scan Time: {:?} count[ {} ]", result.scan_time, len);
}
Ok(())
}Fields§
§if_index: u32Index of network interface
if_name: StringName of network interface
src_mac: [u8; 6]MAC address of network interface
dst_mac: [u8; 6]MAC address of default gateway(or scan target host)
src_ip: IpAddrSource IP address
src_port: u16Source port
destinations: Vec<Destination>Destinations
scan_type: ScanTypeScan Type
timeout: DurationTimeout setting for entire scan task
wait_time: DurationWaiting time after packet sending task is completed
send_rate: DurationPacket sending interval(0 for unlimited)
scan_result: ScanResultScan Result
tx: Arc<Mutex<Sender<SocketAddr>>>Sender for progress messaging
rx: Arc<Mutex<Receiver<SocketAddr>>>Receiver for progress messaging
Implementations§
Source§impl Scanner
impl Scanner
Sourcepub fn new(src_ip: IpAddr) -> Result<Scanner, String>
pub fn new(src_ip: IpAddr) -> Result<Scanner, String>
Create new HostScanner with source IP address
Initialized with default value based on the specified IP address
Sourcepub fn set_src_ip(&mut self, src_ip: IpAddr)
pub fn set_src_ip(&mut self, src_ip: IpAddr)
Set source IP address
Sourcepub fn get_src_ip(&self) -> IpAddr
pub fn get_src_ip(&self) -> IpAddr
Get source IP address
Sourcepub fn add_destination(&mut self, dst: Destination)
pub fn add_destination(&mut self, dst: Destination)
Add Destination
Sourcepub fn set_destinations(&mut self, dst: Vec<Destination>)
pub fn set_destinations(&mut self, dst: Vec<Destination>)
Set Destinations
Sourcepub fn get_destinations(&self) -> Vec<Destination>
pub fn get_destinations(&self) -> Vec<Destination>
Get Destinations
Sourcepub fn set_scan_type(&mut self, scan_type: ScanType)
pub fn set_scan_type(&mut self, scan_type: ScanType)
Set ScanType
Sourcepub fn get_scan_type(&self) -> ScanType
pub fn get_scan_type(&self) -> ScanType
Get ScanType
Sourcepub fn set_timeout(&mut self, timeout: Duration)
pub fn set_timeout(&mut self, timeout: Duration)
Set timeout
Sourcepub fn get_timeout(&self) -> Duration
pub fn get_timeout(&self) -> Duration
Get timeout
Sourcepub fn set_wait_time(&mut self, wait_time: Duration)
pub fn set_wait_time(&mut self, wait_time: Duration)
Set wait time
Sourcepub fn get_wait_time(&self) -> Duration
pub fn get_wait_time(&self) -> Duration
Get wait time
Sourcepub fn set_send_rate(&mut self, send_rate: Duration)
pub fn set_send_rate(&mut self, send_rate: Duration)
Set send rate
Sourcepub fn get_send_rate(&self) -> Duration
pub fn get_send_rate(&self) -> Duration
Get send rate
Sourcepub fn get_scan_result(&self) -> ScanResult
pub fn get_scan_result(&self) -> ScanResult
Get scan result
Sourcepub fn get_progress_receiver(&self) -> Arc<Mutex<Receiver<SocketAddr>>>
pub fn get_progress_receiver(&self) -> Arc<Mutex<Receiver<SocketAddr>>>
Get progress receiver
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scanner
impl RefUnwindSafe for Scanner
impl Send for Scanner
impl Sync for Scanner
impl Unpin for Scanner
impl UnwindSafe for Scanner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more