mirror of
https://github.com/nmap/nmap.git
synced 2026-02-15 01:46:35 +00:00
Limit the number of HostGroupState targets we will defer.
This prevents potentially reading (and buffering) every input host while looking for more targets to fill up the current hostgroup. One of the criteria that can split hostgroups is interface. Suppose you have an input list of targets whose interfaces are eth0 eth0 eth0 wlan0 wlan0 wlan0 wlan0 wlan0 wlan0... The first three eth0 will go in the first group, and then the following wlan0 will start to be buffered while we look for more eth0. But we will only look ahead 64 targets, then go ahead and scan the three eth0.
This commit is contained in:
@@ -401,9 +401,10 @@ HostGroupState::~HostGroupState() {
|
||||
free(hostbatch);
|
||||
}
|
||||
|
||||
/* Returns true iff the defer buffer is not yet full. */
|
||||
bool HostGroupState::defer(Target *t) {
|
||||
this->defer_buffer.push_back(t);
|
||||
return true;
|
||||
return this->defer_buffer.size() < HostGroupState::DEFER_LIMIT;
|
||||
}
|
||||
|
||||
void HostGroupState::undefer() {
|
||||
|
||||
@@ -157,6 +157,9 @@ public:
|
||||
|
||||
class HostGroupState {
|
||||
public:
|
||||
/* The maximum number of entries we want to allow storing in defer_buffer. */
|
||||
static const unsigned int DEFER_LIMIT = 64;
|
||||
|
||||
HostGroupState(int lookahead, int randomize, int argc, const char *argv[]);
|
||||
~HostGroupState();
|
||||
Target **hostbatch;
|
||||
@@ -180,6 +183,7 @@ public:
|
||||
at a time to the client program */
|
||||
TargetGroup current_group; /* For batch chunking -- targets in queue */
|
||||
|
||||
/* Returns true iff the defer buffer is not yet full. */
|
||||
bool defer(Target *t);
|
||||
void undefer();
|
||||
const char *next_expression();
|
||||
|
||||
Reference in New Issue
Block a user