diff --git a/scripts/lua/host_details.lua b/scripts/lua/host_details.lua index c400dde595..3969a28610 100644 --- a/scripts/lua/host_details.lua +++ b/scripts/lua/host_details.lua @@ -621,19 +621,18 @@ end print(""..i18n("download").." JSON") - - if(isAdministrator()) then - print [[]] - - local live_traffic_utils = require("live_traffic_utils") - live_traffic_utils.printLiveTrafficForm(ifId, host_info) - - print[[]] + print [[]] + if (isAdministrator() and ifstats.isView == false and ifstats.isDynamic == false and interface.isPacketInterface()) then + + local live_traffic_utils = require("live_traffic_utils") + live_traffic_utils.printLiveTrafficForm(ifId, host_info) end + print[[]] print("\n") end + if(host["ssdp"] ~= nil) then print("SSDP (UPnP) "..host["ssdp"].."\n") end diff --git a/scripts/lua/if_stats.lua b/scripts/lua/if_stats.lua index 3cb8c1fe54..fa3fa52010 100644 --- a/scripts/lua/if_stats.lua +++ b/scripts/lua/if_stats.lua @@ -222,9 +222,23 @@ if not have_nedge and (table.len(ifstats.profiles) > 0) then end end +if _SERVER["REQUEST_METHOD"] == "POST" and not isEmptyString(_POST["traffic_recording_provider"]) then + local prev_provider = recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) + + -- if the current provider is the builtin ntopng and we are changing to another provider + -- then it may be necessary to stop the builtin ntopng + if prev_provider == "ntopng" and _POST["traffic_recording_provider"] ~= "ntopng" then + recording_utils.stop(ifstats.id) + ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled', "false") + end + + recording_utils.setCurrentTrafficRecordingProvider(ifstats.id, _POST["traffic_recording_provider"]) +end + local has_traffic_recording_page = (recording_utils.isAvailable() and (interface.isPacketInterface() - or (recording_utils.isSupportedZMQInterface(ifid) and not table.empty(ext_interfaces)))) + or ((recording_utils.isSupportedZMQInterface(ifid) and not table.empty(ext_interfaces))) + or (recording_utils.getCurrentTrafficRecordingProvider(ifid) ~= "ntopng"))) if has_traffic_recording_page then if(page == "traffic_recording") then @@ -643,7 +657,7 @@ if(ifstats.zmqRecvStats ~= nil) then end end - if (isAdministrator() and ifstats.isView == false and ifstats.isDynamic == false) then + if (isAdministrator() and ifstats.isView == false and ifstats.isDynamic == false and interface.isPacketInterface()) then print(""..i18n("download").." ") local live_traffic_utils = require("live_traffic_utils") @@ -1300,20 +1314,7 @@ elseif(page == "config") then ]] end - if has_traffic_recording_page then - if _SERVER["REQUEST_METHOD"] == "POST" and not isEmptyString(_POST["traffic_recording_provider"]) then - local prev_provider = recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) - - -- if the current provider is the builtin ntopng and we are changing to another provider - -- then it may be necessary to stop the builtin ntopng - if prev_provider == "ntopng" and _POST["traffic_recording_provider"] ~= "ntopng" then - recording_utils.stop(ifstats.id) - ntop.setCache('ntopng.prefs.ifid_'..ifstats.id..'.traffic_recording.enabled', "false") - end - - recording_utils.setCurrentTrafficRecordingProvider(ifstats.id, _POST["traffic_recording_provider"]) - end - + if has_traffic_recording_page or (true) then local cur_provider = recording_utils.getCurrentTrafficRecordingProvider(ifstats.id) local providers = recording_utils.getAvailableTrafficRecordingProviders() @@ -1332,6 +1333,11 @@ elseif(page == "config") then label = string.format("%s (%s)", provider["name"], provider["conf"]) end + if provider["name"] == "ntopng" and not interface.isPacketInterface() then + -- non-packet interfaces + label = "none" + end + print[[]] end diff --git a/src/PacketDumper.cpp b/src/PacketDumper.cpp index 01d0416e4c..558bc82258 100644 --- a/src/PacketDumper.cpp +++ b/src/PacketDumper.cpp @@ -48,8 +48,10 @@ void PacketDumper::init(NetworkInterface *i) { num_bytes_cur_file = 0; out_path = NULL; - if (strcmp(name, "lo") == 0) + if(strcmp(name, "lo") == 0) iface_type = DLT_NULL; + else if(!i->isPacketInterface()) + iface_type = DLT_EN10MB; else iface_type = i->get_datalink(); } diff --git a/src/Utils.cpp b/src/Utils.cpp index b6e3e9bfce..693b018b24 100755 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -3367,7 +3367,7 @@ void Utils::init_pcap_header(struct pcap_file_header * const h, NetworkInterface h->thiszone = 0; h->sigfigs = 0; h->snaplen = ntop->getGlobals()->getSnaplen(); - h->linktype = iface->get_datalink(); + h->linktype = iface->isPacketInterface() ? iface->get_datalink() : DLT_EN10MB; } /* ****************************************************** */