Skip to content

Commit 2098a31

Browse files
committed
Release 0.14.0 with fix
1 parent e17dcf4 commit 2098a31

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "arp-scan"
33
description = "A minimalistic ARP scan tool"
44
license = "AGPL-3.0-or-later"
5-
version = "0.13.2"
5+
version = "0.14.0"
66
authors = ["Saluki"]
77
edition = "2021"
88
readme = "README.md"

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,15 @@ The features below will be shipped in the next releases of the project.
224224
- Change verbose options (for debug, network details, quiet mode, ...)
225225
- Avoid packet copy in userspace for faster scans (BPF filtering)
226226

227-
## Building
228-
#### Linux / Mac
229-
Simply run `cargo build`
227+
## Building the project
228+
229+
#### Linux and Mac
230+
231+
Run the `cargo build` command.
230232

231233
#### Windows
232-
See [github.com/libpnet/libpnet#windows](https://github.com/libpnet/libpnet#windows)
234+
235+
See [github.com/libpnet/libpnet#windows](https://github.com/libpnet/libpnet#windows).
233236
In additional for what they described there,
234237
for linking `Packet.lib` you can just place it in the root of this project.
235238

src/args.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,7 @@ impl ScanOptions {
565565
}
566566

567567
pub fn has_vlan(&self) -> bool {
568-
569-
matches!(&self.vlan_id, Some(_))
568+
self.vlan_id.is_some()
570569
}
571570

572571
pub fn request_protocol_print(&self) -> bool {

src/network.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use pnet::packet::vlan::{ClassOfService, MutableVlanPacket};
1717
use rand::prelude::*;
1818

1919
use crate::args::ScanOptions;
20-
use crate::vendor::Vendor;
2120
use crate::utils;
21+
use crate::vendor::Vendor;
2222
use crate::args::ScanTiming;
2323

2424
pub const DATALINK_RCV_TIMEOUT: u64 = 500;
@@ -69,18 +69,25 @@ pub struct TargetDetails {
6969
* specific network on a network interfaces.
7070
*/
7171
pub fn compute_network_configuration<'a>(interfaces: &'a [NetworkInterface], scan_options: &'a Arc<ScanOptions>) -> (&'a NetworkInterface, Vec<&'a IpNetwork>) {
72-
let selected_interface = match (&scan_options.interface_name, &scan_options.interface_index) {
72+
73+
let mut interface_name = scan_options.interface_name.clone();
74+
if scan_options.interface_name.is_none() && scan_options.interface_index.is_none() {
75+
let default_name = utils::select_default_interface(interfaces).map(|interface| interface.name);
76+
interface_name = default_name;
77+
}
78+
79+
let selected_interface = match (interface_name, &scan_options.interface_index) {
7380
(Some(interface_name), _) => {
74-
find_interface_by_name(interfaces, interface_name)
81+
find_interface_by_name(interfaces, &interface_name)
7582
},
7683
(None, Some(interface_index)) => {
7784
find_interface_by_index(interfaces, *interface_index)
7885
},
7986
_ => {
80-
eprintln!("Could not find a default network interface");
81-
eprintln!("Use 'arp scan -l' to list available interfaces");
82-
process::exit(1);
83-
}
87+
eprintln!("Could not find a default network interface");
88+
eprintln!("Use 'arp scan -l' to list available interfaces");
89+
process::exit(1);
90+
}
8491
};
8592

8693
let selected_interface = selected_interface.unwrap_or_else(|| {
@@ -97,12 +104,12 @@ pub fn compute_network_configuration<'a>(interfaces: &'a [NetworkInterface], sca
97104
(selected_interface, ip_networks)
98105
}
99106

100-
fn find_interface_by_name<'a>(interfaces: &'a [NetworkInterface], interface_name: &str) -> Option<&'a NetworkInterface> {
107+
fn find_interface_by_name<'a>(interfaces: &'a [NetworkInterface], interface_name: &String) -> Option<&'a NetworkInterface> {
101108
interfaces.iter()
102-
.find(|interface| interface.name == interface_name && (cfg!(windows) || interface.is_up()) && !interface.is_loopback())
109+
.find(|interface| &interface.name == interface_name && (cfg!(windows) || interface.is_up()) && !interface.is_loopback())
103110
}
104111

105-
fn find_interface_by_index<'a>(interfaces: &'a [NetworkInterface], interface_index: u32) -> Option<&'a NetworkInterface> {
112+
fn find_interface_by_index(interfaces: &[NetworkInterface], interface_index: u32) -> Option<&NetworkInterface> {
106113
interfaces.iter()
107114
.find(|interface| interface.index == interface_index && (cfg!(windows) || interface.is_up()) && !interface.is_loopback())
108115
}

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn show_interfaces(interfaces: &[NetworkInterface]) {
3838
Some(mac_address) => format!("{}", mac_address),
3939
None => "No MAC address".to_string()
4040
};
41-
let first_ip = match interface.ips.get(0) {
41+
let first_ip = match interface.ips.first() {
4242
Some(ip_address) => format!("{}", ip_address),
4343
None => "".to_string()
4444
};

0 commit comments

Comments
 (0)