Clean debug messages and make debug level 3 the default debug level for the 'adding new targets' code.

This commit is contained in:
djalal 2010-09-03 17:53:34 +00:00
parent 299b8e8f28
commit c9a756bc12
3 changed files with 13 additions and 10 deletions

View file

@ -568,6 +568,7 @@ const std::list<struct sockaddr_storage> &TargetGroup::get_resolved_addrs(void)
}
#ifndef NOLUA
/* debug level for the adding target is: 3 */
NewTargets *NewTargets::get (void) {
if (new_targets)
return new_targets;
@ -600,8 +601,11 @@ unsigned long NewTargets::push (const char *target) {
/* push target onto the queue for future scans */
queue.push(tg);
if (o.debugging > 3)
if (o.debugging > 2)
log_write(LOG_PLAIN, "New target %s pushed onto the queue.\n", tg.c_str());
} else {
if (o.debugging > 2)
log_write(LOG_PLAIN, "Target %s is already in the queue.\n", tg.c_str());
}
}
@ -645,11 +649,11 @@ unsigned long NewTargets::get_queued (void) {
unsigned long NewTargets::insert (const char *target) {
if (*target) {
if (new_targets == NULL) {
error("Error: to add targets run with -sC or --script options.");
error("ERROR: to add targets run with -sC or --script options.");
return 0;
}
if (o.current_scantype == SCRIPT_POST_SCAN) {
error("Error: adding targets is disabled in the Post-scanning phase.");
error("ERROR: adding targets is disabled in the Post-scanning phase.");
return 0;
}
}

View file

@ -715,8 +715,7 @@ static int l_add_targets (lua_State *L)
/* errors */
} else {
lua_pushnumber(L, ntarget);
lua_pushstring(L,
"Error: failed to add targets, post-scanning phase or no resources.");
lua_pushstring(L, "failed to add new targets.");
return 2;
}
} else {

View file

@ -83,16 +83,16 @@ add = function (...)
-- Force the check here, but it would be better if scripts
-- check ALLOW_NEW_TARGETS before calling target.add()
if not ALLOW_NEW_TARGETS then
stdnse.print_debug(3,
"Error: to add targets run with --script-args 'newtargets'")
return false, "Error: to add targets run with --script-args 'newtargets'"
stdnse.print_debug(1,
"ERROR: to add targets run with --script-args 'newtargets'")
return false, "to add targets run with --script-args 'newtargets'"
end
local new_targets = {count = select("#", ...), ...}
-- function called without arguments
if new_targets.count == 0 then
return true, nmap.add_targets()
return true, nmap.add_targets()
end
new_targets.count = calc_max_targets(new_targets.count)
@ -100,7 +100,7 @@ add = function (...)
if new_targets.count == 0 then
stdnse.print_debug(3,
"Warning: Maximum new targets reached, no more new targets.")
return false, "Warning: Maximum new targets reached, no more new targets."
return false, "Maximum new targets reached, no more new targets."
end
local hosts, err = nmap.add_targets(unpack(new_targets,1,new_targets.count))