diff --git a/include/Prefs.h b/include/Prefs.h index 444af66e2d..3625ae873e 100644 --- a/include/Prefs.h +++ b/include/Prefs.h @@ -44,6 +44,7 @@ class Prefs { char *https_binding_address1, *https_binding_address2; bool enable_client_x509_auth, reproduce_at_original_speed; char *lan_interface, *wan_interface, *zmq_publish_events_url; + char *toggle_date_type; Ntop *ntop; bool enable_dns_resolution, sniff_dns_responses, pcap_file_purge_hosts_flows, categorization_enabled, resolve_all_host_ip, change_user, daemonize, diff --git a/include/ntop_defines.h b/include/ntop_defines.h index 5c3aabf3bc..5822fe5ab3 100644 --- a/include/ntop_defines.h +++ b/include/ntop_defines.h @@ -609,6 +609,7 @@ #define CONST_OTHER_RRD_1D_DAYS NTOPNG_PREFS_PREFIX".other_rrd_1d_days" #define CONST_SAFE_SEARCH_DNS NTOPNG_PREFS_PREFIX".safe_search_dns" #define CONST_GLOBAL_DNS NTOPNG_PREFS_PREFIX".global_dns" +#define CONST_DATE_TYPE NTOPNG_USER_PREFIX".%s.datetype" #define CONST_SECONDARY_DNS NTOPNG_PREFS_PREFIX".secondary_dns" #define CONST_MAX_NUM_SECS_ALERTS_BEFORE_DEL NTOPNG_PREFS_PREFIX".max_num_secs_before_delete_alert" #define CONST_MAX_ENTITY_ALERTS NTOPNG_PREFS_PREFIX".max_entity_alerts" @@ -889,6 +890,7 @@ #define STORE_MANAGER_MAX_QUERY 2048 #define STORE_MANAGER_MAX_KEY 20 #define DEFAULT_GLOBAL_DNS "" +#define DEFAULT_DATE_TYPE "middle_endian" #define DEFAULT_SAFE_SEARCH_DNS "208.67.222.123" /* OpenDNS Family Shield */ #define ALERTS_MANAGER_MAX_AGGR_SECS 300 /* Aggregate equal alerts if generated within this interval */ diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index f5e00b9b57..4628fba94e 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -189,6 +189,9 @@ local lang = { ["legenda"] = "Legenda", ["level"] = "Level", ["light"] = "Light", + ["little_endian"] = "Little Endian", + ["middle_endian"] = "Middle Endian", + ["big_endian"] = "Big Endian", ["local_hosts"] = "Local Hosts", ["local_traffic"] = "Local Traffic", ["lua_c_api"] = "Lua/C API", @@ -4554,6 +4557,8 @@ local lang = { ["toggle_vlan_rrds_title"] = "VLANs", ["toggle_webhook_notification_description"] = "Toggle alerts notifications via webhook (HTTP).", ["toggle_webhook_notification_title"] = "Toggle Webhook Notification", + ["toggle_date_type_title"] = "Date Format", + ["toggle_date_type_description"] = "Switch between different format for date represantion", ["topk_heuristic_precision_description"] = "Use an heuristic when aggregating historical top hosts, countries, etc, to build traffic reports. Useful when building reports over long-periods.", ["topk_heuristic_precision_title"] = "Top-K Heuristic", ["traffic_behaviour"] = "Traffic Behavior", diff --git a/scripts/lua/admin/prefs.lua b/scripts/lua/admin/prefs.lua index 4ede846a5b..f16990bf93 100644 --- a/scripts/lua/admin/prefs.lua +++ b/scripts/lua/admin/prefs.lua @@ -448,6 +448,18 @@ function printGUI() -- ###################### + + local d_labels = {i18n("little_endian"), i18n("middle_endian"), i18n("big_endian")} + local d_values = {"little_endian", "middle_endian", "big_endian"} + local d_label = "toggle_date_type" + + multipleTableButtonPrefs(subpage_active.entries[d_label].title, + subpage_active.entries[d_label].description, + d_labels, d_values, "middle_endian", "primary", + d_label, "ntopng.user." .. _SESSION["user"] .. ".datetype") + + -- ###################### + prefsInputFieldPrefs(subpage_active.entries["max_ui_strlen"].title, subpage_active.entries["max_ui_strlen"].description, "ntopng.prefs.", "max_ui_strlen", prefs.max_ui_strlen, "number", nil, nil, nil, {min=3, max=128}) diff --git a/scripts/lua/modules/prefs_menu.lua b/scripts/lua/modules/prefs_menu.lua index e263ababba..ef6f95d3a0 100644 --- a/scripts/lua/modules/prefs_menu.lua +++ b/scripts/lua/modules/prefs_menu.lua @@ -380,7 +380,10 @@ local menu_subpages = { }, }}, {id="gui", label=i18n("prefs.gui"), advanced=false, pro_only=false, hidden=false, entries={ - toggle_autologout = { + toggle_date_type = { + title = i18n("prefs.toggle_date_type_title"), + description = i18n("prefs.toggle_date_type_description"), + }, toggle_autologout = { title = i18n("prefs.toggle_autologout_title"), description = i18n("prefs.toggle_autologout_description"), },toggle_interface_name_only = { diff --git a/src/Prefs.cpp b/src/Prefs.cpp index bfcf0a590a..4f3fe3d3b1 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -94,6 +94,7 @@ Prefs::Prefs(Ntop *_ntop) { es_index = es_url = es_user = es_pwd = es_host = NULL; https_port = 0; // CONST_DEFAULT_NTOP_PORT+1; change_user = true; + toggle_date_type = NULL; user = strdup(CONST_DEFAULT_NTOP_USER); user_set = false; http_binding_address1 = NULL; @@ -239,6 +240,7 @@ Prefs::~Prefs() { if(https_binding_address1) free(https_binding_address1); if(https_binding_address2) free(https_binding_address2); if(lan_interface) free(lan_interface); + if(toggle_date_type) free(toggle_date_type); if(wan_interface) free(wan_interface); if(ndpi_proto_path) free(ndpi_proto_path); if(test_pre_script_path) free(test_pre_script_path); @@ -713,6 +715,12 @@ void Prefs::reloadPrefsFromRedis() { free(aux); } + getDefaultStringPrefsValue(CONST_GLOBAL_DNS, &aux, DEFAULT_GLOBAL_DNS); + if(aux) { + toggle_date_type = strdup(aux); + free(aux); + } + getDefaultStringPrefsValue(CONST_SECONDARY_DNS, &aux, DEFAULT_GLOBAL_DNS); if(aux) { global_secondary_dns_ip = Utils::inet_addr(aux); @@ -1925,6 +1933,7 @@ void Prefs::lua(lua_State* vm) { lua_push_uint64_table_entry(vm, "http.port", get_http_port()); lua_push_str_table_entry(vm, "instance_name", instance_name ? instance_name : (char*)""); + lua_push_str_table_entry(vm, "toggle_date_type", toggle_date_type ? toggle_date_type : (char*)""); /* Command line options */ lua_push_bool_table_entry(vm, "has_cmdl_trace_lvl", has_cmdl_trace_lvl);