1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 21:51:28 +00:00
This commit is contained in:
david
2009-02-24 00:23:54 +00:00
parent a173fe6ce1
commit 486ff13e3a
6 changed files with 59 additions and 0 deletions

View File

@@ -1,5 +1,10 @@
# Nmap Changelog ($Id$); -*-text-*- # Nmap Changelog ($Id$); -*-text-*-
o The new --stats-every option takes a time interval that controls how
often timing status updates are printed. It's intended to be used
when Nmap is run by another program as a subprocess. Thanks to
Aleksandar Petrinic for the initial implementation. [David]
o [Ncat] The syntax accepted by the --allow, --deny, --allowfile, and o [Ncat] The syntax accepted by the --allow, --deny, --allowfile, and
--denyfile options is now the same as Nmap's target specifications. --denyfile options is now the same as Nmap's target specifications.
Additionally any errors in the allow or deny specifications are Additionally any errors in the allow or deny specifications are

View File

@@ -222,6 +222,7 @@ void NmapOps::Initialize() {
verbose = 0; verbose = 0;
min_packet_send_rate = 0.0; /* Unset. */ min_packet_send_rate = 0.0; /* Unset. */
max_packet_send_rate = 0.0; /* Unset. */ max_packet_send_rate = 0.0; /* Unset. */
stats_interval = 0.0; /* Unset. */
randomize_hosts = 0; randomize_hosts = 0;
sendpref = PACKET_SEND_NOPREF; sendpref = PACKET_SEND_NOPREF;
spoofsource = 0; spoofsource = 0;

View File

@@ -184,6 +184,8 @@ class NmapOps {
float min_packet_send_rate; float min_packet_send_rate;
/* The requested maximum packet sending rate, or 0.0 if unset. */ /* The requested maximum packet sending rate, or 0.0 if unset. */
float max_packet_send_rate; float max_packet_send_rate;
/* The requested auto stats printing interval, or 0.0 if unset. */
float stats_interval;
int randomize_hosts; int randomize_hosts;
int spoofsource; /* -S used */ int spoofsource; /* -S used */
int fastscan; int fastscan;

View File

@@ -3402,6 +3402,23 @@ even if this option is not specified.
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<option>--stats-every <replaceable>time</replaceable></option> (Print periodic timing stats)
<indexterm><primary><option>--stats-every</option></primary></indexterm>
</term>
<listitem>
<para>
Periodically prints a timing status message after each
interval of <replaceable>time</replaceable>. The time is a
specification of the kind described in
<xref linkend="man-performance"/>; so for example, use
<command>--stats-every 10s</command> to get a status update
every 10 seconds. Updates are printed to interactive output
(the screen) and XML output.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>

View File

@@ -674,6 +674,8 @@ int nmap_main(int argc, char *argv[]) {
{"min-rate", required_argument, 0, 0}, {"min-rate", required_argument, 0, 0},
{"max_rate", required_argument, 0, 0}, {"max_rate", required_argument, 0, 0},
{"max-rate", required_argument, 0, 0}, {"max-rate", required_argument, 0, 0},
{"stats_every", required_argument, 0, 0},
{"stats-every", required_argument, 0, 0},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@@ -937,6 +939,10 @@ int nmap_main(int argc, char *argv[]) {
} else if(optcmp(long_options[option_index].name, "max-rate") == 0) { } else if(optcmp(long_options[option_index].name, "max-rate") == 0) {
if (sscanf(optarg, "%f", &o.max_packet_send_rate) != 1 || o.max_packet_send_rate <= 0.0) if (sscanf(optarg, "%f", &o.max_packet_send_rate) != 1 || o.max_packet_send_rate <= 0.0)
fatal("Argument to --max-rate must be a positive floating-point number"); fatal("Argument to --max-rate must be a positive floating-point number");
} else if(optcmp(long_options[option_index].name, "stats-every") == 0) {
l = tval2msecs(optarg);
if (l < 0) fatal("Argument to --stats-every cannot be negative.");
o.stats_interval = (double) l / 1000.0;
} else { } else {
fatal("Unknown long option (%s) given@#!$#$", long_options[option_index].name); fatal("Unknown long option (%s) given@#!$#$", long_options[option_index].name);
} }

View File

@@ -116,6 +116,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "nmap_tty.h" #include "nmap_tty.h"
#include "utils.h"
#include "NmapOps.h" #include "NmapOps.h"
extern NmapOps o; extern NmapOps o;
@@ -240,6 +241,8 @@ void tty_init()
print a status message */ print a status message */
bool keyWasPressed() bool keyWasPressed()
{ {
/* Where we keep the automatic stats printing schedule. */
static struct timeval stats_time = { 0 };
int c; int c;
if (o.noninteractive) if (o.noninteractive)
@@ -282,5 +285,30 @@ bool keyWasPressed()
return true; return true;
} }
} }
/* Check if we need to print a status update according to the --stats-every
option. */
if (o.stats_interval != 0.0) {
struct timeval now;
gettimeofday(&now, NULL);
if (stats_time.tv_sec == 0) {
/* Initialize the scheduled stats time. */
stats_time = *o.getStartTime();
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
}
if (TIMEVAL_AFTER(now, stats_time)) {
/* Advance to the next print time. */
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
/* If it's still in the past, catch it up to the present. */
if (TIMEVAL_AFTER(now, stats_time))
stats_time = now;
printStatusMessage();
/* Instruct the caller to print status too. */
return true;
}
}
return false; return false;
} }