diff --git a/http_src/vue/page-aggregated-live-flows-v2.vue b/http_src/vue/page-aggregated-live-flows-v2.vue index 8248fb05dd..14c9de7860 100644 --- a/http_src/vue/page-aggregated-live-flows-v2.vue +++ b/http_src/vue/page-aggregated-live-flows-v2.vue @@ -52,7 +52,7 @@ const criteria_list_def = [ { label: _i18n("client"), value: 2, param: "client", table_id: "aggregated_client", enterprise_m: false, search_enabled: false }, { label: _i18n("client_server"), value: 4, param: "client_server", table_id: "aggregated_client_server", enterprise_m: true, search_enabled: false }, { label: _i18n("client_server_application_proto"), value: 5, param: "app_client_server", table_id: "aggregated_app_client_server", enterprise_m: true, search_enabled: true }, - { label: _i18n("client_server_srv_port"), value: 7, param: "client_server_srv_port", table_id: "aggregated_client_server_srv_port", enterprise_m: true, search_enabled: false }, + { label: _i18n("client_server_srv_port"), value: 7, param: "client_server_srv_port", table_id: "aggregated_client_server_srv_port", enterprise_m: false, search_enabled: false }, { label: _i18n("info"), value: 6, param: "info", table_id: "aggregated_info", enterprise_m: true, search_enabled: true }, { label: _i18n("server"), value: 3, param: "server", table_id: "aggregated_server", enterprise_m: false, search_enabled: false }, ]; @@ -143,15 +143,16 @@ const map_table_def_columns = async (columns) => { // application protocol case columns.push( { - title_i18n: "application_proto", sortable: true, name: 'application', data_field: 'application', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field) => { - return `${data_field.label_with_icons}` + title_i18n: "application_proto", sortable: true, name: 'application', data_field: 'application', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field, rowData) => { + return format_application_proto_guessed(data_field, rowData) + //return `${data_field.label_with_icons}` } }, - { + /*{ title_i18n: "application_proto_guessed",sortable: false, name: 'application', data_field: 'is_not_guessed', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field, rowData) => { return format_application_proto_guessed(data_field, rowData) } - } + }*/ ); } else if (selected_criteria.value.value == 2) { @@ -173,6 +174,18 @@ const map_table_def_columns = async (columns) => { } }); } + else if (selected_criteria.value.value == 7) { + columns.push( + { + title_i18n: "client", sortable: true, name: 'client', data_field: 'client', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field, rowData) => { + return format_client_name(data_field, rowData) + } + }, { + title_i18n: "last_server", sortable: true, name: 'server', data_field: 'server', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field, rowData) => { + return format_server_name(data_field, rowData); + } + }) + } else if (props.context.is_ntop_enterprise_m) { if (selected_criteria.value.value == 4 || selected_criteria.value.value == 7 ) { columns.push( @@ -198,8 +211,9 @@ const map_table_def_columns = async (columns) => { } }, { - title_i18n: "application_proto",sortable: true, name: 'application', data_field: 'application', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field) => { - return `${data_field.label_with_icons}`; + title_i18n: "application_proto",sortable: true, name: 'application', data_field: 'application', class: ['text-nowrap'], responsivePriority: 1, render_func: (data_field, rowData) => { + return format_application_proto_guessed(data_field, rowData); + //return `${data_field.label_with_icons}` } }); } else if (selected_criteria.value.value == 6) { @@ -324,9 +338,9 @@ const format_flows_icon = function (data, rowData) { const format_application_proto_guessed = function (data, rowData) { if(rowData.confidence == 0 ) - return ``+ rowData.confidence_name + ` ` + return `${data.label_with_icons} `+ rowData.confidence_name + ` ` else if (rowData.confidence) - return ` `+ rowData.confidence_name + `` + return `${data.label_with_icons} `+ rowData.confidence_name + `` } diff --git a/httpdocs/dist b/httpdocs/dist index c57698361d..73a1cc9191 160000 --- a/httpdocs/dist +++ b/httpdocs/dist @@ -1 +1 @@ -Subproject commit c57698361df15d98a1f614920ab74012c374a998 +Subproject commit 73a1cc91918d851119837eeb2b149388aa7584ee diff --git a/include/NetworkInterface.h b/include/NetworkInterface.h index 55a9aa89ab..94cfc5847f 100644 --- a/include/NetworkInterface.h +++ b/include/NetworkInterface.h @@ -1356,6 +1356,9 @@ public: bool *matched); static bool compute_server_flow_stats(GenericHashEntry *node, void *user_data, bool *matched); + static bool compute_client_server_srv_port_flow_stats(GenericHashEntry *node, + void *user_data, + bool *matched); static bool get_host_ports(GenericHashEntry *node, void *user_data, bool *matched); @@ -1377,9 +1380,6 @@ public: bool *matched); static bool compute_info_flow_stats(GenericHashEntry *node, void *user_data, bool *matched); - static bool compute_client_server_srv_port_flow_stats(GenericHashEntry *node, - void *user_data, - bool *matched); #endif void getActiveMacs(lua_State *vm); }; diff --git a/scripts/lua/rest/v2/get/flow/aggregated_live_flows.lua b/scripts/lua/rest/v2/get/flow/aggregated_live_flows.lua index 6a0def1544..b1926acc41 100644 --- a/scripts/lua/rest/v2/get/flow/aggregated_live_flows.lua +++ b/scripts/lua/rest/v2/get/flow/aggregated_live_flows.lua @@ -81,7 +81,9 @@ local criteria_type_id = 1 -- by default application_protocol if criteria == "client" then criteria_type_id = 2 elseif criteria == "server" then - criteria_type_id = 3 + criteria_type_id = 3 +elseif criteria == "client_server_srv_port" then + criteria_type_id = 7 elseif ntop.isEnterpriseM() then criteria_type_id = get_criteria_type_id(criteria) end @@ -100,6 +102,7 @@ for _, data in pairs(aggregated_info or {}) do local add_app_proto = false local add_server = false local add_client = false + local add_server_port = false local client = nil local server = nil local info = nil @@ -132,6 +135,16 @@ for _, data in pairs(aggregated_info or {}) do if(data.server_ip ~= nil) then add_server = true end + elseif (criteria_type_id == 7) then + if(data.server_ip ~= nil) then + add_server = true + end + if(data.client_ip ~= nil) then + add_client = true + end + if(data.srv_port ~= nil) then + add_server_port = true + end elseif ntop.isEnterpriseM() then response = get_output_flags(criteria_type_id) end @@ -144,7 +157,7 @@ for _, data in pairs(aggregated_info or {}) do } end - if (response ~= {} and response.add_srv_port) then + if (add_server_port) then srv_port = { label = data.srv_port, id = data.srv_port diff --git a/src/NetworkInterface.cpp b/src/NetworkInterface.cpp index 7d2acd4ec5..ee62f1db83 100644 --- a/src/NetworkInterface.cpp +++ b/src/NetworkInterface.cpp @@ -11083,15 +11083,15 @@ bool NetworkInterface::compute_protocol_flow_stats(GenericHashEntry *node, ndpi_protocol detected_protocol = f->get_detected_protocol(); std::unordered_map::iterator it; struct aggregated_stats *stats = (struct aggregated_stats*)user_data; - u_int64_t is_not_guessed = (u_int64_t) int(f->isDPIDetectedFlow()); + bool is_not_guessed = f->isDPIDetectedFlow(); if(stats->ip_addr != NULL) { if(!f->matchFlowIP(stats->ip_addr, stats->vlan_id)) return(false); } - /* setProtoKey(key); fs->setFlowIPVLAN(f); + fs->setIsNotGuessed(is_not_guessed); stats->count[key] = fs; } } else { @@ -11203,6 +11204,48 @@ bool NetworkInterface::compute_server_flow_stats(GenericHashEntry *node, /* **************************************************** */ +bool NetworkInterface::compute_client_server_srv_port_flow_stats(GenericHashEntry *node, + void *user_data, bool *matched) { + Flow *f = (Flow *)node; + struct aggregated_stats *stats = (struct aggregated_stats*)user_data; + + if(stats->ip_addr != NULL) { + if(!f->matchFlowIP(stats->ip_addr, stats->vlan_id)) + return(false); + } + + u_int64_t vlan_id = f->get_vlan_id(); + std::unordered_map::iterator it; + u_int64_t key = (((u_int64_t)f->get_cli_ip_addr()->key()) << 16) + + (((u_int64_t)f->get_srv_ip_addr()->key()) << 16) + + (((u_int64_t)f->get_srv_port()) << 32) + + ((u_int64_t)vlan_id << 32); + + it = stats->count.find(key); + + if (it == stats->count.end()) { + AggregatedFlowsStats *fs = + new (std::nothrow) AggregatedFlowsStats(f->get_cli_ip_addr(), f->get_srv_ip_addr(), f->get_protocol(), + f->get_bytes_cli2srv(), f->get_bytes_srv2cli(), f->getScore()); + + if (fs != NULL) { + fs->setFlowIPVLAN(f); + fs->setSrvPort(f->get_srv_port()); + fs->setKey(key); + stats->count[key] = fs; + } + } else + it->second->incFlowStats(f->get_cli_ip_addr(), f->get_srv_ip_addr(), + f->get_bytes_cli2srv(), f->get_bytes_srv2cli(), + f->getScore()); + + *matched = true; + + return (false); /* false = keep on walking */ +} + +/* **************************************************** */ + /* Sort aggregated live flows compare functions */ static bool asc_application_name_cmp(AggregatedFlowsStats *a, AggregatedFlowsStats *b) { @@ -11636,6 +11679,11 @@ void NetworkInterface::getFilteredLiveFlowsStats(lua_State *vm) { walker(&begin_slot, true /* walk_all */, walker_flows, compute_server_flow_stats, &stats); break; + case AnalysisCriteria::client_server_srv_port: + /* info criteria flows stats case */ + walker(&begin_slot, true /* walk_all */, walker_flows, + compute_client_server_srv_port_flow_stats, &stats); + break; #if defined(NTOPNG_PRO) case AnalysisCriteria::client_server_criteria: @@ -11658,13 +11706,6 @@ void NetworkInterface::getFilteredLiveFlowsStats(lua_State *vm) { walker(&begin_slot, true /* walk_all */, walker_flows, compute_info_flow_stats, &stats); break; - - case AnalysisCriteria::client_server_srv_port: - /* info criteria flows stats case */ - if (ntop->getPrefs()->is_enterprise_m_edition()) - walker(&begin_slot, true /* walk_all */, walker_flows, - compute_client_server_srv_port_flow_stats, &stats); - break; #endif default: