From bab3a80cdf5dae7e29f26f2d7c19232c7db16272 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Tue, 6 Sep 2022 00:13:40 +0200 Subject: [PATCH] Changes in host details --- scripts/locales/en.lua | 1 + scripts/lua/host_details.lua | 10 ++++++++-- src/Flow.cpp | 11 +++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index 383b0adcdb..8b9f30fb03 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -7,6 +7,7 @@ local lang = { ["action"] = "Action", ["actions"] = "Actions", ["active_flows"] = "Live", + ["local_flows_sankey"] = "Local Flows", ["activities"] = "Activities", ["activity"] = "Activity", ["add"] = "Add", diff --git a/scripts/lua/host_details.lua b/scripts/lua/host_details.lua index 7895b6a15f..0357818230 100644 --- a/scripts/lua/host_details.lua +++ b/scripts/lua/host_details.lua @@ -87,8 +87,6 @@ end -- print(">>>") print(host_info["host"]) print("<<<") if(debug_hosts) then traceError(TRACE_DEBUG,TRACE_CONSOLE, i18n("host_details.trace_debug_host_info",{hostinfo=host_info["host"],vlan=host_vlan}).."\n") end - - local host = interface.getHostInfo(host_info["host"], host_vlan) local tskey @@ -426,6 +424,12 @@ else page_name = "flows", label = '', }, + { + hidden = only_historical or not ntop.isEnterpriseL() or (host.localhost == false), + active = page == "flows_sankey", + page_name = "flows_sankey", + label = '', + }, { hidden = only_historical or host["is_broadcast"] or host["is_multicast"] or not ntop.hasGeoIP(), active = page == "geomap", @@ -1912,6 +1916,8 @@ elseif(page == "flows") then ]] +elseif(page == "flows_sankey") then + print(template.gen("pages/sankey_host.template", { host = host_ip })) elseif(page == "snmp" and ntop.isEnterpriseM() and isAllowedSystemInterface()) then local snmp_config = require "snmp_config" diff --git a/src/Flow.cpp b/src/Flow.cpp index 8493323a12..55dd81197d 100644 --- a/src/Flow.cpp +++ b/src/Flow.cpp @@ -2207,7 +2207,8 @@ void Flow::lua(lua_State* vm, AddressTree * ptree, bool mask_flow; bool has_json_info = false; u_char community_id[200]; - + char buf[64]; + if(ptree) { if(src_ip) src_match = src_ip->match(ptree); if(dst_ip) dst_match = dst_ip->match(ptree); @@ -2219,7 +2220,7 @@ void Flow::lua(lua_State* vm, AddressTree * ptree, lua_get_ip(vm, true /* Client */); lua_get_ip(vm, false /* Server */); - + lua_push_uint32_table_entry(vm, "vlan", get_vlan_id()); lua_get_port(vm, true /* Client */); lua_get_port(vm, false /* Server */); @@ -2236,8 +2237,7 @@ void Flow::lua(lua_State* vm, AddressTree * ptree, if(vrfId) lua_push_uint64_table_entry(vm, "vrfId", vrfId); - /* See VLANAddressTree.h for details */ - lua_push_uint32_table_entry(vm, "vlan", get_vlan_id()); + /* See VLANAddressTree.h for details */ lua_push_uint32_table_entry(vm, "observation_point_id", get_observation_point_id()); if(srcAS) @@ -2436,6 +2436,9 @@ void Flow::lua(lua_State* vm, AddressTree * ptree, lua_get_status(vm); + lua_push_str_table_entry(vm, "proto.ndpi", + detection_completed ? get_detected_protocol_name(buf, sizeof(buf)) : (char*)CONST_TOO_EARLY); + // this is used to dynamicall update entries in the GUI lua_push_uint64_table_entry(vm, "ntopng.key", key()); // Key lua_push_uint64_table_entry(vm, "hash_entry_id", get_hash_entry_id());