mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 09:20:10 +00:00
Add badges for report ports and tcp ports column (#7874)
This commit is contained in:
parent
8c12d234c0
commit
a4e83a9111
6 changed files with 181 additions and 8 deletions
|
|
@ -68,6 +68,12 @@ vs_utils.scan_status = {
|
|||
scanning = 4
|
||||
}
|
||||
|
||||
vs_utils.tcp_ports_diff_case = {
|
||||
no_diff = 2, -- case 1 or 2 (combined)
|
||||
ntopng_more_t_vs = 3,
|
||||
vs_more_t_ntopng = 4
|
||||
}
|
||||
|
||||
-- **********************************************************
|
||||
|
||||
function vs_utils.is_nmap_installed()
|
||||
|
|
@ -1136,6 +1142,85 @@ function vs_utils.format_port_label(port, service_name, protocol)
|
|||
end
|
||||
end
|
||||
|
||||
-- **********************************************************
|
||||
-- Retrieves detected ports by ntopng
|
||||
|
||||
function vs_utils.retrieve_detected_ports(host)
|
||||
local host_info = interface.getHostInfo(host)
|
||||
|
||||
local tcp_ports_detected = {}
|
||||
if (host_info and host_info.used_ports and host_info.used_ports.local_server_ports) then
|
||||
for port, l7_proto in pairs(host_info.used_ports.local_server_ports) do
|
||||
local port_details = split(port, ":")
|
||||
local id_port = port_details[2]
|
||||
local l4_proto = port_details[1]
|
||||
|
||||
if (l4_proto == 'tcp') then
|
||||
tcp_ports_detected[#tcp_ports_detected+1] = id_port
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return tcp_ports_detected
|
||||
end
|
||||
|
||||
-- Search port in ports list
|
||||
local function find_port(port_to_find, port_list)
|
||||
for _, port in ipairs(port_list) do
|
||||
if(port_to_find == tonumber(port)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Compare vs ports and ntopng detected ports
|
||||
function vs_utils.compare_ports(vs_scan_port_string_list, ntopng_ports)
|
||||
|
||||
local vs_scan_ports = split(vs_scan_port_string_list, ",")
|
||||
|
||||
local ports_unused = {}
|
||||
local filtered_ports = {}
|
||||
-- check vs_scan_ports with ntopng_ports
|
||||
local not_found_a_port = false
|
||||
for _,vs_port in ipairs(vs_scan_ports) do
|
||||
local find_actual_port = find_port(tonumber(vs_port), ntopng_ports)
|
||||
|
||||
if (not find_actual_port) then
|
||||
not_found_a_port = true
|
||||
ports_unused[#ports_unused+1] = vs_port
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local diff_case
|
||||
|
||||
if (not_found_a_port) then
|
||||
diff_case = vs_utils.tcp_ports_diff_case.vs_more_t_ntopng
|
||||
end
|
||||
|
||||
if (#vs_scan_ports == #ntopng_ports) then
|
||||
diff_case = vs_utils.tcp_ports_diff_case.no_diff
|
||||
else
|
||||
local filtered = false
|
||||
|
||||
for _,ntop_port in ipairs(ntopng_ports) do
|
||||
if (not find_port(tonumber(ntop_port), vs_scan_ports)) then
|
||||
filtered = true
|
||||
filtered_ports[#filtered_ports+1] = ntop_port
|
||||
end
|
||||
|
||||
end
|
||||
if (filtered) then
|
||||
diff_case = vs_utils.tcp_ports_diff_case.ntopng_more_t_vs
|
||||
end
|
||||
end
|
||||
|
||||
return ports_unused, filtered_ports, diff_case
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- **********************************************************
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue