Skip to content

Commit

Permalink
Add isDatabaseViewInterface lua call
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Jul 10, 2024
1 parent 06965da commit a789c34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/ntop_typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,8 @@ typedef enum {
interface_type_DIVERT,
interface_type_DUMMY,
interface_type_ZC_FLOW,
interface_type_SYSLOG
interface_type_SYSLOG,
interface_type_DB_VIEW
} InterfaceType;

/* Update Flow::dissectHTTP when extending the type below */
Expand Down
3 changes: 2 additions & 1 deletion scripts/lua/inc/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ interface.select(ifname)
local ifs = interface.getStats()
local is_pcap_dump = interface.isPcapDumpInterface()
local is_packet_interface = interface.isPacketInterface()
local is_db_view_interface = interface.isDatabaseViewInterface()
local is_viewed = ifs.isViewed
local is_influxdb_enabled = ntop.getPref("ntopng.prefs.timeseries_driver") == "influxdb"
local is_clickhouse_enabled = ntop.isClickHouseEnabled()
Expand Down Expand Up @@ -278,7 +279,7 @@ else
-- Alerts
page_utils.add_menubar_section({
section = page_utils.menu_sections.alerts,
hidden = not prefs.are_alerts_enabled or not auth.has_capability(auth.capabilities.alerts),
hidden = not prefs.are_alerts_enabled or not auth.has_capability(auth.capabilities.alerts) or is_pcap_dump or is_db_view_interface,
entries = {{
entry = page_utils.menu_entries.alerts_list,
url = "/lua/alert_stats.lua"
Expand Down
16 changes: 16 additions & 0 deletions src/LuaEngineInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,21 @@ static int ntop_interface_is_pcap_dump_interface(lua_State *vm) {

/* ****************************************** */

static int ntop_interface_is_database_view_interface(lua_State *vm) {
NetworkInterface *curr_iface = getCurrentInterface(vm);
bool rv = false;

ntop->getTrace()->traceEvent(TRACE_DEBUG, "%s() called", __FUNCTION__);

if (curr_iface && curr_iface->getIfType() == interface_type_DB_VIEW)
rv = true;

lua_pushboolean(vm, rv);
return (ntop_lua_return_value(vm, __FUNCTION__, CONST_LUA_OK));
}

/* ****************************************** */

static int ntop_interface_is_zmq_interface(lua_State *vm) {
NetworkInterface *curr_iface = getCurrentInterface(vm);
bool rv = false;
Expand Down Expand Up @@ -5398,6 +5413,7 @@ static luaL_Reg _ntop_interface_reg[] = {
{"isDiscoverableInterface", ntop_interface_is_discoverable_interface},
{"isBridgeInterface", ntop_interface_is_bridge_interface},
{"isPcapDumpInterface", ntop_interface_is_pcap_dump_interface},
{"isDatabaseViewInterface", ntop_interface_is_database_view_interface},
{"isZMQInterface", ntop_interface_is_zmq_interface},
{"isView", ntop_interface_is_view},
{"isViewed", ntop_interface_is_viewed},
Expand Down

0 comments on commit a789c34

Please sign in to comment.