mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 13:11:28 +00:00
o [NSE] Added stop function to crawler so that scripts can properly shutdown
the crawler in case they want to end early. [Patrik]
This commit is contained in:
@@ -561,6 +561,12 @@ Crawler = {
|
||||
end
|
||||
|
||||
while(true) do
|
||||
|
||||
if ( self.quit ) then
|
||||
table.insert(response_queue, {false, { err = false, msg = "Quit signalled by crawler" } })
|
||||
break
|
||||
end
|
||||
|
||||
-- in case the user set a max page count to retrieve check how many
|
||||
-- pages we have retrieved so far
|
||||
local count = self:getPageCount()
|
||||
@@ -607,6 +613,7 @@ Crawler = {
|
||||
end
|
||||
condvar "signal"
|
||||
end
|
||||
condvar "signal"
|
||||
end,
|
||||
|
||||
-- Loads the argument set on a script level
|
||||
@@ -690,5 +697,14 @@ Crawler = {
|
||||
end
|
||||
end,
|
||||
|
||||
-- signals the crawler to stop
|
||||
stop = function(self)
|
||||
local condvar = nmap.condvar(self.response_queue)
|
||||
self.quit = true
|
||||
condvar "signal"
|
||||
condvar "wait"
|
||||
end
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user