diff --git a/include/Host.h b/include/Host.h index 9dc7a1132e..326bc54996 100644 --- a/include/Host.h +++ b/include/Host.h @@ -527,7 +527,7 @@ class Host : public GenericHashEntry, void lua_get_listening_ports(lua_State* vm); void lua_get_labels(lua_State* vm) const; - inline u_int64_t getLabels() const { return labels_bitmap; } + u_int64_t getLabels(); void setLabels(u_int64_t bitmap); void resolveHostName(); diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index d9699857e1..f38a5c8a50 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -502,6 +502,7 @@ local lang = { ["merge_wazuh_info_success"] = "Wazuh asset information successfully merged.", ["netbios_name"] = "NetBIOS", ["http_servers"] = "HTTP(S) Servers", + ["network_gateway"] = "Network Gateway", ["ntp_server"] = "NTP Server", ["ntp_servers"] = "NTP Servers", ["offline"] = "Offline", @@ -521,7 +522,6 @@ local lang = { ["switch_port"] = "Switch Port", ["smtp_server"] = "SMTP Server", ["smtp_servers"] = "SMTP Servers", - ["network_gateway"] = "Network Gateway", ["ssh_server"] = "SSH Server", ["ssid"] = "SSID", ["tcp_fingerprint"] = "TCP Fingerprint", diff --git a/scripts/lua/modules/label_badge_utils.lua b/scripts/lua/modules/label_badge_utils.lua index 5b1fe734ea..465f5a8eb5 100644 --- a/scripts/lua/modules/label_badge_utils.lua +++ b/scripts/lua/modules/label_badge_utils.lua @@ -11,11 +11,11 @@ local label_badge_utils = {} -- Built-in host labels (bits 0-31). -- Keep in sync with include/ntop_defines.h label_badge_utils.builtin_labels = { - [0] = { i18n = "checks.dns_server" }, -- HOST_LABEL_DNS_SERVER - [1] = { i18n = "checks.ntp_server" }, -- HOST_LABEL_NTP_SERVER - [2] = { i18n = "checks.dhcp_server" }, -- HOST_LABEL_DHCP_SERVER - [3] = { i18n = "checks.smtp_server" }, -- HOST_LABEL_SMTP_SERVER - [4] = { i18n = "checks.network_gateway" }, -- HOST_LABEL_NETWORK_GATEWAY + [0] = { i18n = "asset_details.dns_server" }, -- HOST_LABEL_DNS_SERVER + [1] = { i18n = "asset_details.ntp_server" }, -- HOST_LABEL_NTP_SERVER + [2] = { i18n = "asset_details.dhcp_server" }, -- HOST_LABEL_DHCP_SERVER + [3] = { i18n = "asset_details.smtp_server" }, -- HOST_LABEL_SMTP_SERVER + [4] = { i18n = "asset_details.network_gateway" }, -- HOST_LABEL_NETWORK_GATEWAY } -- ############################################## @@ -31,11 +31,16 @@ local function get_default_labels_table() -- Bits 0-31: ntop built-in labels (read-only, auto-assigned by ntopng) for id, entry in pairs(label_badge_utils.builtin_labels) do + local name = i18n(entry.i18n) + if name == nil then + traceError(TRACE_WARNING, TRACE_CONSOLE, + "label_badge_utils: i18n key not found: " .. entry.i18n) + end labels[id] = { id = id, color = "#0d6efd", description = "", - name = i18n(entry.i18n), + name = name, reserved = "true" } end diff --git a/src/Host.cpp b/src/Host.cpp index 8b2cfb3813..d6b8efac7b 100644 --- a/src/Host.cpp +++ b/src/Host.cpp @@ -1159,6 +1159,22 @@ char* Host::get_host_label(char* const buf, ssize_t buf_len) { /* ***************************************** */ +u_int64_t Host::getLabels() { + u_int64_t bm = labels_bitmap; + Prefs* p = ntop->getPrefs(); + u_int16_t vlan = vlan_id; + + if (p->isDNSServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_DNS_SERVER); + if (p->isNTPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_NTP_SERVER); + if (p->isDHCPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_DHCP_SERVER); + if (p->isSMTPServer(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_SMTP_SERVER); + if (p->isGateway(&ip, vlan)) bm |= ((u_int64_t)1 << HOST_LABEL_NETWORK_GATEWAY); + + return bm; +} + +/* ***************************************** */ + void Host::setLabels(u_int64_t bitmap) { labels_bitmap = bitmap; iface->setHostLabels(this, bitmap);