From 187252bc59dd47075826bc62ebbaf0643160f875 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 7 Oct 2011 07:51:50 +0000 Subject: [PATCH] Rewrite some duplicated loops. --- scripts/broadcast-ping.nse | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/broadcast-ping.nse b/scripts/broadcast-ping.nse index aa93f707d..a315e4fef 100755 --- a/scripts/broadcast-ping.nse +++ b/scripts/broadcast-ping.nse @@ -257,18 +257,14 @@ action = function() -- generate output local output = {} - if target.ALLOW_NEW_TARGETS then - for ip_addr, mac_addr in pairs(icmp_responders) do + for ip_addr, mac_addr in pairs(icmp_responders) do + if target.ALLOW_NEW_TARGETS then target.add(ip_addr) - table.insert(output,"IP: "..ip_addr..string.rep(" ",15-#ip_addr).." MAC: "..mac_addr) - end - else - for ip_addr, mac_addr in pairs(icmp_responders) do - table.insert(output,"IP: "..ip_addr..string.rep(" ",15-#ip_addr).." MAC: "..mac_addr) - end - if #output>0 then - table.insert(output,"Use the newtargets script-arg to add the results as targets") end + table.insert(output,"IP: "..ip_addr..string.rep(" ",15-#ip_addr).." MAC: "..mac_addr) + end + if #output > 0 and not target.ALLOW_NEW_TARGETS then + table.insert(output,"Use the newtargets script-arg to add the results as targets") end return stdnse.format_output( (#output>0), output )