From 2aa6eccafc4e9f58c704411fc9d5ff680e87e45a Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Tue, 18 Apr 2023 11:52:44 +0200 Subject: [PATCH] Fix extraction from smart timeline --- .../pages/components/datatable.template | 2 +- scripts/lua/check_recording_data.lua | 4 +--- scripts/lua/modules/http_lint.lua | 1 - scripts/lua/modules/recording_utils.lua | 19 ++++++++----------- scripts/lua/modules/ui_utils.lua | 5 ++--- src/TimelineExtract.cpp | 2 +- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/httpdocs/templates/pages/components/datatable.template b/httpdocs/templates/pages/components/datatable.template index b169c86dde..ca2f740240 100644 --- a/httpdocs/templates/pages/components/datatable.template +++ b/httpdocs/templates/pages/components/datatable.template @@ -409,7 +409,7 @@ {% if actions.show_pcap_download then %} /* Button to open the pcap download dialog */ - {icon: 'fa-download', title: "{{ i18n('traffic_recording.pcap_download') }}", onclick: 'pcapDownload(' + dataRow.filter.epoch_begin + ', ' + dataRow.filter.epoch_end+ ', "' + dataRow.filter.bpf + '", true); return false;'}, + {icon: 'fa-download', title: "{{ i18n('traffic_recording.pcap_download') }}", onclick: 'pcapDownload(' + dataRow.filter.epoch_begin + ', ' + dataRow.filter.epoch_end+ ', "' + dataRow.filter.bpf + '"); return false;'}, {% end %} {% if actions.show_acknowledge then %} diff --git a/scripts/lua/check_recording_data.lua b/scripts/lua/check_recording_data.lua index 9352973816..8ca87d8b36 100644 --- a/scripts/lua/check_recording_data.lua +++ b/scripts/lua/check_recording_data.lua @@ -19,12 +19,10 @@ end local ifid = tonumber(_GET["ifid"] or interface.getId()) local epoch_begin = tonumber(_GET["epoch_begin"]) local epoch_end = tonumber(_GET["epoch_end"]) -local alert_data_only = _GET["alert_data_only"] local master_ifid = interface.getMasterInterfaceId(ifid) -local smart_data = toboolean(alert_data_only) -local window_info = recording_utils.isDataAvailable(master_ifid, epoch_begin, epoch_end, smart_data) +local window_info = recording_utils.isDataAvailable(master_ifid, epoch_begin, epoch_end) if window_info.epoch_begin and window_info.epoch_end then window_info.epoch_begin_formatted = format_utils.formatPastEpochShort(window_info.epoch_begin) diff --git a/scripts/lua/modules/http_lint.lua b/scripts/lua/modules/http_lint.lua index f21783991e..4625f94e14 100644 --- a/scripts/lua/modules/http_lint.lua +++ b/scripts/lua/modules/http_lint.lua @@ -2197,7 +2197,6 @@ local known_parameters = { ["traffic_recording_provider"] = validateTrafficRecordingProvider, ["dismiss_external_providers_reminder"] = validateBool, ["dismiss_missing_geoip_reminder"] = validateBool, - ["alert_data_only"] = validateBool, -- -- TOP STATS diff --git a/scripts/lua/modules/recording_utils.lua b/scripts/lua/modules/recording_utils.lua index 853f6cffb8..dd84b329a2 100644 --- a/scripts/lua/modules/recording_utils.lua +++ b/scripts/lua/modules/recording_utils.lua @@ -948,7 +948,6 @@ end --! @brief Return the current n2disk timeline, or the "Smart" timeline if active, based on the time interval function recording_utils.getTimelineByInterval(ifid, epoch_begin, epoch_end) - if recording_utils.isExtractionEnabled(ifid) then local stats = recording_utils.stats(ifid) local info = is_data_in_window(stats, epoch_begin, epoch_end) @@ -957,14 +956,12 @@ function recording_utils.getTimelineByInterval(ifid, epoch_begin, epoch_end) end end - if not info.available then - -- Check Smart Recording - if smart_data and recording_utils.isSmartEnabled() then - local stats = recording_utils.smartStats(ifid) - info = is_data_in_window(stats, epoch_begin, epoch_end) - if info.available then - return recording_utils.getCurrentTrafficRecordingProviderSmartTimelinePath(ifid) - end + -- Check Smart Recording + if recording_utils.isSmartEnabled(ifid) then + local stats = recording_utils.smartStats(ifid) + local info = is_data_in_window(stats, epoch_begin, epoch_end) + if info.available then + return recording_utils.getCurrentTrafficRecordingProviderSmartTimelinePath(ifid) end end @@ -1090,7 +1087,7 @@ end --! @param epoch_begin the begin time (epoch) --! @param epoch_end the end time (epoch) --! @return a table with 'available' = true if the specified interval is included in the dump window, 'epoch_begin'/'epoch_end' are also returned with the actual available window. -function recording_utils.isDataAvailable(ifid, epoch_begin, epoch_end, smart_data) +function recording_utils.isDataAvailable(ifid, epoch_begin, epoch_end) local info = {} info.available = false @@ -1101,7 +1098,7 @@ function recording_utils.isDataAvailable(ifid, epoch_begin, epoch_end, smart_dat if not info.available then -- Check Smart Recording - if smart_data and recording_utils.isSmartEnabled() then + if recording_utils.isSmartEnabled(ifid) then local stats = recording_utils.smartStats(ifid) info = is_data_in_window(stats, epoch_begin, epoch_end) end diff --git a/scripts/lua/modules/ui_utils.lua b/scripts/lua/modules/ui_utils.lua index 56eb00b7df..2d71839eac 100644 --- a/scripts/lua/modules/ui_utils.lua +++ b/scripts/lua/modules/ui_utils.lua @@ -145,14 +145,13 @@ function ui_utils.draw_pcap_download_dialog(ifid) }); } - function pcapDownload(epoch_begin, epoch_end, bpf_filter, is_alert) { + function pcapDownload(epoch_begin, epoch_end, bpf_filter) { $.ajax({ type: "GET", url: ']] print(ntop.getHttpPrefix().."/lua/check_recording_data.lua") print [[', data: { epoch_begin: epoch_begin, - epoch_end: epoch_end, - alert_data_only: is_alert + epoch_end: epoch_end }, error: function(err) { console.error(err); }, success: function(data) { diff --git a/src/TimelineExtract.cpp b/src/TimelineExtract.cpp index 872b64754d..bd361bcd50 100644 --- a/src/TimelineExtract.cpp +++ b/src/TimelineExtract.cpp @@ -48,7 +48,7 @@ pfring *TimelineExtract::openTimeline(const char *timeline_path, time_t from, snprintf(timeline_ifname, sizeof(timeline_ifname), "timeline:%s", timeline_path); - handle = pfring_open(timeline_path, 16384, 0); + handle = pfring_open(timeline_ifname, 16384, 0); if (handle == NULL) { ntop->getTrace()->traceEvent(TRACE_ERROR, "Unable to open %s",