mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
Improve search in case of full ip with partial match
This commit is contained in:
parent
0837613112
commit
9494fee954
2 changed files with 19 additions and 2 deletions
|
|
@ -79,6 +79,12 @@ end
|
|||
|
||||
local ifid = interface.getId()
|
||||
|
||||
local query_info = hostkey2hostinfo(query)
|
||||
local is_full_ip = isIPv4(query_info['host']) or isIPv6(query_info['host'])
|
||||
|
||||
-- Report if a perfect host match was found (full ip)
|
||||
local exact_match = false
|
||||
|
||||
--- Links
|
||||
|
||||
local function build_flow_alerts_url(key, value)
|
||||
|
|
@ -438,7 +444,8 @@ if not is_system_interface then
|
|||
local ip = nil
|
||||
local mac = nil
|
||||
|
||||
local label = hostinfo2label(hostkey2hostinfo(host_key), true)
|
||||
local host_info = hostkey2hostinfo(host_key)
|
||||
local label = hostinfo2label(host_info, true)
|
||||
if host_key ~= k then
|
||||
label = label .. " · " .. k
|
||||
end
|
||||
|
|
@ -462,6 +469,8 @@ if not is_system_interface then
|
|||
add_historical_flows_link(links, 'name', host_key)
|
||||
end
|
||||
|
||||
exact_match = is_full_ip and host_info['host'] == query_info['host']
|
||||
|
||||
hosts[k] = {
|
||||
label = label,
|
||||
name = host_key,
|
||||
|
|
@ -578,6 +587,13 @@ if not is_system_interface then
|
|||
return r
|
||||
end
|
||||
|
||||
if is_full_ip and not exact_match then
|
||||
what = "ip"
|
||||
label = i18n("db_search.no_exact_match", {what=what, query=query})
|
||||
query = query .. tag_utils.SEPARATOR .. "eq"
|
||||
results[#results + 1] = build_result(label, query, what, nil, nil, "historical")
|
||||
end
|
||||
|
||||
for k, v in pairsByField(hosts, 'name', asc) do
|
||||
if((res_count >= max_group_items) or (#results >= max_total_items)) then
|
||||
break
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue