Skip to content

Commit

Permalink
Release 0.14.0 with fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Saluki committed Jan 13, 2024
1 parent e17dcf4 commit 2098a31
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "arp-scan"
description = "A minimalistic ARP scan tool"
license = "AGPL-3.0-or-later"
version = "0.13.2"
version = "0.14.0"
authors = ["Saluki"]
edition = "2021"
readme = "README.md"
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,15 @@ The features below will be shipped in the next releases of the project.
- Change verbose options (for debug, network details, quiet mode, ...)
- Avoid packet copy in userspace for faster scans (BPF filtering)

## Building
#### Linux / Mac
Simply run `cargo build`
## Building the project

#### Linux and Mac

Run the `cargo build` command.

#### Windows
See [github.com/libpnet/libpnet#windows](https://github.com/libpnet/libpnet#windows)

See [github.com/libpnet/libpnet#windows](https://github.com/libpnet/libpnet#windows).
In additional for what they described there,
for linking `Packet.lib` you can just place it in the root of this project.

Expand Down
3 changes: 1 addition & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,7 @@ impl ScanOptions {
}

pub fn has_vlan(&self) -> bool {

matches!(&self.vlan_id, Some(_))
self.vlan_id.is_some()
}

pub fn request_protocol_print(&self) -> bool {
Expand Down
27 changes: 17 additions & 10 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use pnet::packet::vlan::{ClassOfService, MutableVlanPacket};
use rand::prelude::*;

use crate::args::ScanOptions;
use crate::vendor::Vendor;
use crate::utils;
use crate::vendor::Vendor;
use crate::args::ScanTiming;

pub const DATALINK_RCV_TIMEOUT: u64 = 500;
Expand Down Expand Up @@ -69,18 +69,25 @@ pub struct TargetDetails {
* specific network on a network interfaces.
*/
pub fn compute_network_configuration<'a>(interfaces: &'a [NetworkInterface], scan_options: &'a Arc<ScanOptions>) -> (&'a NetworkInterface, Vec<&'a IpNetwork>) {
let selected_interface = match (&scan_options.interface_name, &scan_options.interface_index) {

let mut interface_name = scan_options.interface_name.clone();
if scan_options.interface_name.is_none() && scan_options.interface_index.is_none() {
let default_name = utils::select_default_interface(interfaces).map(|interface| interface.name);
interface_name = default_name;
}

let selected_interface = match (interface_name, &scan_options.interface_index) {
(Some(interface_name), _) => {
find_interface_by_name(interfaces, interface_name)
find_interface_by_name(interfaces, &interface_name)
},
(None, Some(interface_index)) => {
find_interface_by_index(interfaces, *interface_index)
},
_ => {
eprintln!("Could not find a default network interface");
eprintln!("Use 'arp scan -l' to list available interfaces");
process::exit(1);
}
eprintln!("Could not find a default network interface");
eprintln!("Use 'arp scan -l' to list available interfaces");
process::exit(1);
}
};

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

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

fn find_interface_by_index<'a>(interfaces: &'a [NetworkInterface], interface_index: u32) -> Option<&'a NetworkInterface> {
fn find_interface_by_index(interfaces: &[NetworkInterface], interface_index: u32) -> Option<&NetworkInterface> {
interfaces.iter()
.find(|interface| interface.index == interface_index && (cfg!(windows) || interface.is_up()) && !interface.is_loopback())
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn show_interfaces(interfaces: &[NetworkInterface]) {
Some(mac_address) => format!("{}", mac_address),
None => "No MAC address".to_string()
};
let first_ip = match interface.ips.get(0) {
let first_ip = match interface.ips.first() {
Some(ip_address) => format!("{}", ip_address),
None => "".to_string()
};
Expand Down

0 comments on commit 2098a31

Please sign in to comment.