From fdf95c63bb647de16b9a9e7a08fb498b402b4aeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Sep 2022 00:31:34 +0000 Subject: [PATCH 1/2] Update clap requirement from 3.1.12 to 4.0.4 Updates the requirements on [clap](https://github.com/clap-rs/clap) to permit the latest version. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v3.2.0...v4.0.4) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2311ae6..ab4b5a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ edition = "2018" bitflags = "1.2.1" byteorder = "1.4.3" chrono = "0.4.19" -clap = "3.1.12" +clap = "4.0.4" dns-parser = "0.8.0" flate2 = "1.0" itertools = "0.10.3" From ce4ac2858d72f010f3690fe0b152fcf7c36ac0c2 Mon Sep 17 00:00:00 2001 From: Pierre Lalet Date: Fri, 30 Sep 2022 13:08:44 +0200 Subject: [PATCH 2/2] Fixes for clap v4 See https://github.com/clap-rs/clap/blob/master/CHANGELOG.md --- src/masscanned.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/masscanned.rs b/src/masscanned.rs index 202325e..2ea4014 100644 --- a/src/masscanned.rs +++ b/src/masscanned.rs @@ -1,5 +1,5 @@ // This file is part of masscanned. -// Copyright 2021 - The IVRE project +// Copyright 2021 - 2022 The IVRE project // // Masscanned is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ use std::fs::File; use std::net::IpAddr; use std::str::FromStr; -use clap::{Arg, Command}; +use clap::{Arg, ArgAction, Command}; use log::*; use pnet::{ datalink::{self, Channel::Ethernet, DataLinkReceiver, DataLinkSender, NetworkInterface}, @@ -112,42 +112,41 @@ fn main() { .value_name("iface") .help("the interface to use for receiving/sending packets") .required(true) - .takes_value(true), + .num_args(1), ) .arg( Arg::new("mac") .short('m') .long("mac-addr") .help("MAC address to use in the response packets") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("ipfile") .long("ip-addr-file") .help("File with the list of IP addresses to impersonate") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("iplist") .long("ip-addr") .help("Inline list of IP addresses to impersonate, comma-separated") - .takes_value(true), + .num_args(1), ) .arg( Arg::new("verbosity") .short('v') - .multiple_occurrences(true) + .action(ArgAction::Count) .help("Increase message verbosity"), ) .arg( Arg::new("quiet") .long("quiet") .short('q') - .help("Quiet mode: do not output anything on stdout") - .takes_value(false), + .help("Quiet mode: do not output anything on stdout"), ) .get_matches(); - let verbose = args.occurrences_of("verbosity") as usize; + let verbose = args.value_source("verbosity").unwrap() as usize; /* initialise logger */ stderrlog::new() .module(module_path!()) @@ -160,14 +159,14 @@ fn main() { trace!("trace messages enabled"); info!("Command line arguments:"); let iface = if let Some(i) = get_interface( - args.value_of("interface") + args.get_one::("interface") .expect("error parsing iface argument"), ) { i } else { error!( "Cannot open interface \"{}\" - are you sure it exists?", - args.value_of("interface") + args.get_one::("interface") .expect("error parsing iface argument") ); return; @@ -176,7 +175,7 @@ fn main() { error!("specified interface is DOWN"); return; } - let mac = if let Some(m) = args.value_of("mac") { + let mac = if let Some(m) = args.get_one::("mac") { MacAddr::from_str(m).expect("error parsing provided MAC address") } else if let Some(m) = iface.mac { m @@ -185,7 +184,7 @@ fn main() { }; /* Parse ip address file specified */ /* FIXME: .and_then(|path| File::open(path).map(|file| )).unwrap_or_default() ? */ - let mut ip_list = if let Some(ref path) = args.value_of("ipfile") { + let mut ip_list = if let Some(ref path) = args.get_one::("ipfile") { if let Ok(file) = File::open(path) { info!("parsing ip address file: {}", &path); file.extract_ip_addresses_only(None) @@ -195,7 +194,7 @@ fn main() { } else { HashSet::new() }; - if let Some(ip_inline_list) = args.value_of("iplist") { + if let Some(ip_inline_list) = args.get_one::("iplist") { ip_list.extend(ip_inline_list.extract_ip_addresses_only(None)); } let ip_addresses = if !ip_list.is_empty() {