1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 20:51:30 +00:00

Simplify boostScanDelay to make it clear what limits are in place.

This commit is contained in:
dmiller
2024-06-27 19:36:03 +00:00
parent eb21ac9ea0
commit f0fab247db
2 changed files with 11 additions and 7 deletions

View File

@@ -469,6 +469,9 @@ HostScanStats::HostScanStats(Target *t, UltraScanInfo *UltraSI) {
memset(&sdn, 0, sizeof(sdn)); memset(&sdn, 0, sizeof(sdn));
sdn.last_boost = USI->now; sdn.last_boost = USI->now;
sdn.delayms = o.scan_delay; sdn.delayms = o.scan_delay;
sdn.maxdelay = USI->tcp_scan ? o.maxTCPScanDelay() :
USI->udp_scan ? o.maxUDPScanDelay() :
o.maxSCTPScanDelay();
rld.max_tryno_sent = 0; rld.max_tryno_sent = 0;
rld.rld_waiting = false; rld.rld_waiting = false;
rld.rld_waittime = USI->now; rld.rld_waittime = USI->now;
@@ -1917,13 +1920,13 @@ static bool ultrascan_port_pspec_update(const UltraScanInfo *USI,
/* Boost the scan delay for this host, usually because too many packet /* Boost the scan delay for this host, usually because too many packet
drops were detected. */ drops were detected. */
void HostScanStats::boostScanDelay() { void HostScanStats::boostScanDelay() {
unsigned int maxAllowed = USI->tcp_scan ? o.maxTCPScanDelay() : if (sdn.delayms < 1000) {
USI->udp_scan ? o.maxUDPScanDelay() :
o.maxSCTPScanDelay();
if (sdn.delayms == 0) if (sdn.delayms == 0)
sdn.delayms = (USI->udp_scan) ? 50 : 5; // In many cases, a pcap wait takes a minimum of 80ms, so this matters little :( sdn.delayms = (USI->udp_scan) ? 50 : 5; // In many cases, a pcap wait takes a minimum of 80ms, so this matters little :(
else sdn.delayms = MIN(sdn.delayms * 2, MAX(sdn.delayms, 1000)); else
sdn.delayms = MIN(sdn.delayms, maxAllowed); sdn.delayms = MIN(sdn.delayms * 2, 1000);
}
sdn.delayms = MIN(sdn.delayms, sdn.maxdelay);
sdn.last_boost = USI->now; sdn.last_boost = USI->now;
sdn.droppedRespSinceDelayChanged = 0; sdn.droppedRespSinceDelayChanged = 0;
sdn.goodRespSinceDelayChanged = 0; sdn.goodRespSinceDelayChanged = 0;

View File

@@ -320,6 +320,7 @@ struct send_delay_nfo {
unsigned int goodRespSinceDelayChanged; unsigned int goodRespSinceDelayChanged;
unsigned int droppedRespSinceDelayChanged; unsigned int droppedRespSinceDelayChanged;
struct timeval last_boost; /* Most recent time of increase to delayms. Init to creation time. */ struct timeval last_boost; /* Most recent time of increase to delayms. Init to creation time. */
int maxdelay;
}; };
/* To test for rate limiting, there is a delay in sending the first packet /* To test for rate limiting, there is a delay in sending the first packet