mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Don't randomly select the servers to show. Just show the ones at the
top. Display the total number when limiting output.
This commit is contained in:
@@ -120,28 +120,22 @@ local function getservers(host, port, q3protocol)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function formatresult(servers, outputlimit, protocols)
|
local function formatresult(servers, outputlimit, protocols)
|
||||||
math.randomseed(os.time())
|
|
||||||
randomized = {}
|
|
||||||
while #servers > 0 do
|
|
||||||
local x = table.remove(servers, math.random(1, #servers))
|
|
||||||
table.insert(randomized, x)
|
|
||||||
end
|
|
||||||
if not outputlimit then
|
if not outputlimit then
|
||||||
outputlimit = #randomized
|
outputlimit = #servers
|
||||||
end
|
end
|
||||||
local formatted = {}
|
local formatted = {}
|
||||||
for i = 1, outputlimit do
|
for i = 1, outputlimit do
|
||||||
if not randomized[i] then
|
if not servers[i] then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local node = randomized[i]
|
local node = servers[i]
|
||||||
local protocol = node.protocol
|
local protocol = node.protocol
|
||||||
local ip = node.ip
|
local ip = node.ip
|
||||||
local portnum = node.port
|
local portnum = node.port
|
||||||
table.insert(formatted, string.format('%s:%d %s (%s)', ip, portnum, protocols[protocol], protocol))
|
table.insert(formatted, string.format('%s:%d %s (%s)', ip, portnum, protocols[protocol], protocol))
|
||||||
end
|
end
|
||||||
if #formatted < #randomized then
|
if #formatted < #servers then
|
||||||
table.insert(formatted, string.format('Only %d shown. Use --script-args %s.outputlimit=-1 to see all.', outputlimit, SCRIPT_NAME))
|
table.insert(formatted, string.format('Only %d/%d shown. Use --script-args %s.outputlimit=-1 to see all.', #formatted, #servers, SCRIPT_NAME))
|
||||||
end
|
end
|
||||||
return formatted
|
return formatted
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user