diff --git a/CHANGELOG b/CHANGELOG index b4726af81..f290d5e92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ # Nmap Changelog ($Id$); -*-text-*- +o [NSE] Added stop function to crawler so that scripts can properly shutdown + the crawler in case they want to end early. [Patrik] + o [NSE] Fixed issue in path encoding in the http-backup-finder script. [Patrik] o [NSE] Added the script http-backup-finder that searches for backup copies diff --git a/nselib/httpspider.lua b/nselib/httpspider.lua index 277f7809c..c69f2a6b3 100644 --- a/nselib/httpspider.lua +++ b/nselib/httpspider.lua @@ -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 + + }