1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 17:09:02 +00:00

Move the "Script Pre-scanning", "Script scanning", and "Script

Post-scanning" messages to inside the run function, so they can be
printed only after we're sure we have at least one thread to run.
This commit is contained in:
david
2011-02-01 18:16:27 +00:00
parent c0f8979b01
commit b1e3114eca

View File

@@ -631,7 +631,7 @@ end
-- Arguments:
-- threads An array of threads (a runlevel) to run.
-- scantype A string that indicates the current script scan phase.
local function run (threads_iter, scantype)
local function run (threads_iter, scantype, hosts)
-- running scripts may be resumed at any time. waiting scripts are
-- yielded until Nsock wakes them. After being awakened with
-- nse_restore, waiting threads become pending and later are moved all
@@ -728,6 +728,18 @@ local function run (threads_iter, scantype)
return
end
if (scantype == NSE_PRE_SCAN) then
print_verbose(1, "Script Pre-scanning.");
elseif (scantype == NSE_SCAN) then
if #hosts > 1 then
print_verbose(1, "Script scanning %d hosts.", #hosts);
elseif #hosts == 1 then
print_verbose(1, "Script scanning %s.", hosts[1].ip);
end
elseif (scantype == NSE_POST_SCAN) then
print_verbose(1, "Script Post-scanning.");
end
local progress = cnse.scan_progress_meter(NAME);
-- Loop while any thread is running or waiting.
@@ -1047,18 +1059,6 @@ local function main (hosts, scantype)
insert(runlevels[script.runlevel], script);
end
if (scantype == NSE_PRE_SCAN) then
print_verbose(1, "Script Pre-scanning.");
elseif (scantype == NSE_SCAN) then
if #hosts > 1 then
print_verbose(1, "Script scanning %d hosts.", #hosts);
elseif #hosts == 1 then
print_verbose(1, "Script scanning %s.", hosts[1].ip);
end
elseif (scantype == NSE_POST_SCAN) then
print_verbose(1, "Script Post-scanning.");
end
for runlevel, scripts in ipairs(runlevels) do
-- This iterator is passed to the run function. It returns one new script
-- thread on demand until exhausted.
@@ -1106,7 +1106,7 @@ local function main (hosts, scantype)
end
end
print_verbose(2, "Starting runlevel %u (of %u) scan.", runlevel, #runlevels);
run(wrap(threads_iter), scantype)
run(wrap(threads_iter), scantype, hosts)
end
collectgarbage "collect";