Reimplemented view: interface, and Paginator code.

Minor code cleanup
This commit is contained in:
Luca 2016-08-18 13:44:24 +02:00
parent 650ce6e202
commit 274921ee5c
34 changed files with 809 additions and 359 deletions

View file

@ -22,57 +22,17 @@ print [[
num = 0
interface.select(ifname)
if(true) then
res = interface.findHost(query)
res = interface.findHost(query)
if(res ~= nil) then
for k, v in pairs(res) do
if(v ~= "") then
if(num > 0) then print(",\n") end
print('\t"'..v..'"')
num = num + 1
end
end
else
hosts_stats = interface.getHostsInfo()
-- query = "192"
if(query ~= nil) then
query = string.lower(query)
for _key, value in pairs(hosts_stats) do
if(num >= max_num_to_find) then
break
end
found = 0
if((hosts_stats[_key]["name"] == nil) and (hosts_stats[_key]["ip"] ~= nil)) then
hosts_stats[_key]["name"] = ntop.getResolvedAddress(hosts_stats[_key]["ip"])
end
what = hosts_stats[_key]["name"]
if((what ~= nil) and (string.contains(string.lower(what), query))) then
found = 1
else
what = hosts_stats[_key]["mac"]
if(starts(what, query)) then
found = 1
else
if(hosts_stats[_key]["ip"] ~= nil) then
what = hosts_stats[_key]["ip"]
if(starts(what, query)) then
found = 1
end
end
end
end
if(found == 1) then
if(num > 0) then print(",\n") end
print("\t\""..what .. "\"")
num = num + 1
end
end
end
end
end -- if
end -- for
end -- if
print [[