1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-28 10:29:03 +00:00

moved some debug output where it made more sense

fixed some formatting
This commit is contained in:
batrick
2011-06-13 22:59:30 +00:00
parent c9e955a756
commit e37cfc5d0e

View File

@@ -652,8 +652,7 @@ end
-- The main loop function for NSE. It handles running all the script threads.
-- 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, hosts)
local function run (threads_iter, 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
@@ -750,18 +749,6 @@ local function run (threads_iter, scantype, hosts)
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.
@@ -1081,12 +1068,24 @@ 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.
local function threads_iter ()
-- activate prerule scripts
if (scantype == NSE_PRE_SCAN) then
if scantype == NSE_PRE_SCAN then
for _, script in ipairs(scripts) do
local thread = script:new_thread("prerule");
if thread then
@@ -1095,7 +1094,7 @@ local function main (hosts, scantype)
end
end
-- activate hostrule and portrule scripts
elseif (scantype == NSE_SCAN) then
elseif scantype == NSE_SCAN then
-- Check hostrules for this host.
for j, host in ipairs(hosts) do
for _, script in ipairs(scripts) do
@@ -1117,7 +1116,7 @@ local function main (hosts, scantype)
end
end
-- activate postrule scripts
elseif (scantype == NSE_POST_SCAN) then
elseif scantype == NSE_POST_SCAN then
for _, script in ipairs(scripts) do
local thread = script:new_thread("postrule");
if thread then
@@ -1128,7 +1127,7 @@ local function main (hosts, scantype)
end
end
print_verbose(2, "Starting runlevel %u (of %u) scan.", runlevel, #runlevels);
run(wrap(threads_iter), scantype, hosts)
run(wrap(threads_iter), hosts)
end
collectgarbage "collect";