Coverage Report

Created: 2026-05-14 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntopng/include/Prefs.h
Line
Count
Source
1
/*
2
 *
3
 * (C) 2013-26 - ntop.org
4
 *
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software Foundation,
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
 *
20
 */
21
22
#ifndef _PREFS_H_
23
#define _PREFS_H_
24
25
#include "ntop_includes.h"
26
27
class Ntop;
28
class Flow;
29
30
extern void usage();
31
extern void nDPIusage();
32
33
typedef struct {
34
  char *name, *alias, *description;
35
  int id;
36
} InterfaceInfo;
37
38
typedef std::set<std::string> InterfacesSet;
39
40
class Prefs {
41
 private:
42
  u_int8_t num_deferred_interfaces_to_register;
43
  pcap_direction_t captureDirection;
44
  char **deferred_interfaces_to_register, *cli, *ciphers_list,
45
      *custom_geoip_dir;
46
  char *http_binding_address1, *http_binding_address2;
47
  char *https_binding_address1, *https_binding_address2;
48
  char* http_index_page;
49
  char* influx_internal_db_name;
50
  bool influx_internal_available;
51
  bool enable_client_x509_auth, reproduce_at_original_speed, disable_purge,
52
      strict_startup;
53
  char *zmq_publish_events_url, *http_log_path;
54
  const char *clickhouse_client, *clickhouse_cluster_name;
55
  Ntop* ntop;
56
  bool enable_dns_resolution, sniff_dns_responses, sniff_name_responses,
57
      sniff_local_name_responses, pcap_file_purge_hosts_flows,
58
      categorization_enabled, resolve_all_host_ip, change_user, daemonize,
59
      enable_auto_logout, enable_auto_logout_at_runtime, use_promiscuous_mode,
60
      enable_ixia_timestamps, full_stats_enabled, enable_interface_name_only,
61
      enable_users_login, disable_localhost_login, service_license_check,
62
      enable_sql_log, enable_access_log, enable_assets_log, log_to_file,
63
      enable_mac_ndpi_stats, enable_activities_debug, enable_behaviour_analysis,
64
      enable_asn_behaviour_analysis, enable_network_behaviour_analysis,
65
      enable_iface_l7_behaviour_analysis, emit_flow_alerts, emit_host_alerts,
66
      dump_flows_on_clickhouse, readonly_flows_dump, 
67
      do_reforge_timestamps, add_vlan_tags_to_cloud_exporters,
68
      collect_blacklist_stats, fail_on_invalid_license, limited_resources_mode,
69
      fingerprint_stats, tls_quic_hostnaming;
70
#ifndef HAVE_NEDGE
71
  bool use_mac_in_flow_key;
72
#endif
73
  u_int32_t behaviour_analysis_learning_period;
74
  u_int32_t iec60870_learning_period, modbus_learning_period,
75
      s7comm_learning_period, devices_learning_period,
76
      mac_address_cache_duration;
77
  u_int32_t host_port_learning_period;
78
  bool enable_flow_swap_heuristic;
79
  bool skip_dpi_for_collected_flows;
80
#ifdef NTOPNG_PRO
81
  ndpi_bitmap* modbus_allowed_function_codes;
82
  u_int modbus_too_many_exceptions;
83
  ndpi_bitmap* s7comm_allowed_function_codes;
84
  u_int s7comm_too_many_errors;
85
  u_int profinet_too_many_errors;
86
  bool data_archive_before_ttl_delete, asset_inventory_enabled,
87
      snmp_trap_enabled;
88
#endif
89
  ServiceAcceptance behaviour_analysis_learning_status_during_learning,
90
      behaviour_analysis_learning_status_post_learning;
91
  TsDriver timeseries_driver;
92
  u_int64_t iec104_allowed_typeids[2];
93
  u_int32_t auth_session_duration;
94
  bool auth_session_midnight_expiration;
95
96
  u_int32_t non_local_host_max_idle, local_host_cache_duration,
97
      local_host_max_idle, pkt_ifaces_flow_max_idle;
98
  u_int32_t active_local_hosts_cache_interval;
99
  u_int32_t intf_rrd_raw_days, intf_rrd_1min_days, intf_rrd_1h_days,
100
      intf_rrd_1d_days;
101
  u_int32_t other_rrd_raw_days, other_rrd_1min_days, other_rrd_1h_days,
102
      other_rrd_1d_days;
103
  u_int32_t housekeeping_frequency;
104
  bool disable_alerts, enable_top_talkers, enable_sites_collection,
105
      enable_active_local_hosts_cache, enable_dns_cache, split_ts_direction;
106
  bool enable_flow_device_port_rrd_creation,
107
      enable_observation_points_rrd_creation,
108
      enable_intranet_traffic_rrd_creation;
109
  bool enable_tiny_flows_export;
110
  bool enable_captive_portal, enable_informative_captive_portal,
111
      mac_based_captive_portal, enable_external_auth_captive_portal;
112
  bool override_dst_with_post_nat_dst, override_src_with_post_nat_src;
113
  bool routing_mode_enabled, global_dns_forging_enabled;
114
  bool device_protocol_policies_enabled, enable_vlan_trunk_bridge;
115
  bool enable_arp_matrix_generation;
116
  bool enable_zmq_encryption;
117
  bool flow_table_time, flow_table_probe_order;
118
  bool enable_broadcast_domain_too_large;
119
  u_int32_t max_num_secs_before_delete_alert, alert_page_refresh_rate;
120
  int32_t max_entity_alerts;
121
  u_int32_t safe_search_dns_ip, global_primary_dns_ip, global_secondary_dns_ip;
122
  u_int32_t max_num_packets_per_tiny_flow, max_num_bytes_per_tiny_flow,
123
      dump_frequency;
124
  u_int32_t max_extracted_pcap_bytes, max_extracted_pcap_files;
125
  u_int32_t max_ui_strlen;
126
  u_int8_t default_l7policy;
127
  HostMask hostMask;
128
129
  u_int32_t max_num_hosts, max_num_flows;
130
  u_int32_t attacker_max_num_flows_per_sec, victim_max_num_flows_per_sec;
131
  u_int32_t attacker_max_num_syn_per_sec, victim_max_num_syn_per_sec;
132
  u_int8_t ewma_alpha_percent;
133
  u_int http_port, https_port;
134
  u_int8_t num_interfaces;
135
  u_int16_t auto_assigned_pool_id;
136
  u_int8_t vs_max_num_scans;
137
  bool vs_slow_scan;
138
  bool dump_flows_on_es, dump_flows_on_syslog, dump_json_flows_on_disk,
139
      dump_ext_json;
140
  bool asn_mode_enabled;
141
#ifdef NTOPNG_PRO
142
  bool dump_flows_direct;
143
  u_int32_t dump_queue_len, dump_queue_block_size;
144
  u_int32_t max_aggregated_flows_upperbound,
145
      max_aggregated_flows_traffic_upperbound;
146
#endif
147
  bool enable_runtime_flows_dump; /**< runtime preference to enable/disable
148
                                     flows dump from the UI */
149
  InterfaceInfo* ifNames;
150
  char* local_networks;
151
  bool local_networks_set, shutdown_when_done, simulate_vlans, simulate_macs,
152
      ignore_vlans, ignore_macs;
153
  bool insecure_tls; /**< Unsecure TLS connections a-la curl */
154
  u_int32_t num_simulated_ips;
155
  u_int16_t custom_if_mtu;
156
  char *data_dir, *install_dir, *docs_dir, *scripts_dir, *callbacks_dir,
157
      *pcap_dir, *clickhouse_archive_dir
158
#ifdef NTOPNG_PRO
159
      ,
160
      *pro_callbacks_dir
161
#endif
162
      ;
163
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
164
  char *kafka_brokers_list, *kafka_topic, *kafka_options;
165
#endif
166
  char* categorization_key;
167
  char* zmq_encryption_pwd;
168
  char* zmq_encryption_priv_key;
169
  char *export_endpoint, *export_zmq_encryption_key;
170
  char* http_prefix;
171
  char* instance_name;
172
  char *config_file_path, *ndpi_proto_path;
173
  char* packet_filter;
174
  char* user;
175
  bool user_set;
176
  char* redis_host;
177
  char* redis_password;
178
  char* redis_tls_ca_cert;
179
  char* redis_tls_cert;
180
  char* redis_tls_key;
181
  bool redis_tls_skip_verify;
182
  char* pid_path;
183
  char *cpu_affinity, *other_cpu_affinity;
184
#ifdef __linux__
185
  cpu_set_t other_cpu_affinity_mask;
186
#endif
187
  u_int8_t redis_db_id;
188
  int redis_port;
189
  int dns_mode;
190
  bool json_labels_string_format;
191
  char *es_type, *es_index, *es_url, *es_user, *es_pwd, *es_host;
192
  char* clickhouse_host;
193
  char* clickhouse_dbname;
194
  char* clickhouse_user;
195
  char* clickhouse_pw;
196
  char* clickhouse_ro_user;
197
  char* clickhouse_ro_pw;
198
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO)
199
  char* clickhouse_cluster_user; /* In case of ch cloud, 2 users are needed,
200
                    one for mysql and one for ch */
201
  bool ntopng_assets_inventory_enabled;
202
#endif
203
#if !defined(WIN32) && !defined(__APPLE__)
204
  int flows_syslog_facility;
205
#endif
206
  int clickhouse_tcp_port;
207
  bool clickhouse_tcp_port_secure;
208
  char *ls_host, *ls_port, *ls_proto;
209
  bool has_cmdl_trace_lvl; /**< Indicate whether a verbose level
210
                              has been provided on the command line.*/
211
#ifndef HAVE_NEDGE
212
  bool appliance;
213
#endif
214
215
  ServerConfiguration *gateway, *dns_servers, *ntp_servers, *smtp_servers,
216
      *dhcp_servers;
217
  ASNConfiguration *customer_asn, *sub_customer_asn, *remote_asn;
218
219
#ifdef NTOPNG_PRO
220
  AddressTree* networks_policy_configuration;
221
  AddressTree* networks_policy_configuration_shadow;
222
#endif
223
224
#ifdef HAVE_PF_RING
225
  int pfring_cluster_id;
226
#endif
227
228
  char* test_pre_script_path;
229
  char* test_runtime_script_path;
230
  char* test_post_script_path;
231
232
  char *message_broker_url, *message_broker;
233
  bool message_broker_enabled;
234
#ifdef NTOPNG_PRO
235
  bool print_maintenance, print_license;
236
  char* lic_mgr_config_file;
237
#endif
238
  bool print_version, print_version_json;
239
  bool snmp_polling;
240
  bool active_monitoring, network_discovery, starttls;
241
  bool use_host_pools_for_local;
242
  bool dump_pcap_to_clickhouse; /* Dump pcap-interface flows to ClickHouse */
243
  bool query_performance_log;
244
245
  InterfacesSet lan_interfaces, wan_interfaces;
246
247
0
  inline void help() { usage(); }
248
0
  inline void nDPIhelp() { nDPIusage(); }
249
  void setCommandLineString(int optkey, const char* optarg);
250
  int setOption(int optkey, char* optarg);
251
  int checkOptions();
252
253
  void setTraceLevelFromRedis();
254
  void parseHTTPPort(char* arg);
255
  char* parseLocalNetworks(char* arg);
256
257
0
  static inline void set_binding_address(char** const dest, const char* addr) {
258
0
    if (dest && addr && addr[0] != '\0') {
259
0
      if (*dest) free(*dest);
260
0
      *dest = strdup(addr);
261
0
    }
262
0
  };
263
  bool getDefaultBoolPrefsValue(const char* pref_key, const bool default_value);
264
  void refreshBehaviourAnalysis();
265
266
 public:
267
  Prefs(Ntop* _ntop);
268
  virtual ~Prefs();
269
270
  bool is_pro_edition();
271
  bool is_enterprise_m_edition();
272
  bool is_enterprise_l_edition();
273
  bool is_enterprise_xl_edition();
274
  bool is_enterprise_xxl_edition();
275
  bool is_enterprise_xxxl_edition();
276
277
  bool is_nedge_pro_edition();
278
  bool is_nedge_enterprise_edition();
279
280
  bool is_embedded_edition();
281
  bool is_nanalyst_available();
282
  
283
  time_t pro_edition_demo_ends_at();
284
2
  inline char* get_local_networks() {
285
2
    if (!local_networks_set) return NULL;
286
0
    return (local_networks);
287
2
  };
288
0
  inline void disable_dns_resolution() { enable_dns_resolution = false; };
289
0
  inline void resolve_all_hosts() { resolve_all_host_ip = true; };
290
4.95k
  inline bool is_dns_resolution_enabled_for_all_hosts() {
291
4.95k
    return (resolve_all_host_ip);
292
4.95k
  };
293
21.3k
  inline bool is_dns_resolution_enabled() { return (enable_dns_resolution); };
294
0
  inline bool is_users_login_enabled() { return (enable_users_login); };
295
0
  inline bool is_localhost_users_login_disabled() {
296
0
    return (disable_localhost_login);
297
0
  };
298
0
  inline bool is_log_to_file_enabled() { return (log_to_file); };
299
0
  inline void disable_dns_responses_decoding() { sniff_dns_responses = false; };
300
0
  inline void disable_localhost_name_decoding() {
301
0
    sniff_local_name_responses = false;
302
0
  };
303
0
  inline void disable_all_name_decoding() { sniff_name_responses = false; };
304
1.61k
  inline bool is_dns_decoding_enabled() /* DNS only */ {
305
1.61k
    return (sniff_dns_responses);
306
1.61k
  };
307
0
  inline bool is_name_decoding_enabled() /* Any */ {
308
0
    return (sniff_name_responses);
309
0
  };
310
0
  inline bool is_localhost_name_decoding_enabled() {
311
0
    return (sniff_local_name_responses);
312
0
  };
313
0
  inline void enable_categorization() { categorization_enabled = true; };
314
0
  inline bool is_categorization_enabled() { return (categorization_enabled); };
315
0
  inline bool do_change_user() { return (change_user); };
316
0
  inline void dont_change_user() { change_user = false; };
317
0
  inline bool is_sql_log_enabled() { return (enable_sql_log); };
318
0
  inline bool is_access_log_enabled() { return (enable_access_log); };
319
0
  inline void do_enable_access_log(bool state = true) {
320
0
    enable_access_log = state;
321
0
  };
322
0
  inline bool is_assets_log_enabled() { return (enable_assets_log); };
323
0
  inline void do_enable_assets_log(bool state = true) {
324
0
    enable_assets_log = state;
325
0
  };
326
0
  inline bool are_ixia_timestamps_enabled() {
327
0
    return (enable_ixia_timestamps);
328
0
  };
329
0
  inline char* get_user() { return (user); };
330
0
  inline void set_user(const char* u) {
331
0
    if (user) free(user);
332
0
    user = strdup(u);
333
0
    user_set = true;
334
0
  };
335
0
  inline bool is_user_set() { return user_set; };
336
0
  inline u_int32_t get_num_simulated_ips() const {
337
0
    return (num_simulated_ips);
338
0
  };
339
2
  inline u_int16_t get_custom_if_mtu() const { return (custom_if_mtu); };
340
0
  inline u_int8_t get_num_user_specified_interfaces() {
341
0
    return (num_interfaces);
342
0
  };
343
5.81k
  inline bool do_dump_flows_on_es() { return (dump_flows_on_es); };
344
5.81k
  inline bool do_dump_flows_on_clickhouse() {
345
5.81k
    return ((is_enterprise_m_edition() || is_nedge_enterprise_edition()) &&
346
0
            dump_flows_on_clickhouse);
347
5.81k
  };
348
0
  inline bool do_dump_alerts_on_clickhouse() {
349
0
    return (do_dump_flows_on_clickhouse());
350
0
  };
351
5.81k
  inline bool do_dump_flows_on_syslog() { return (dump_flows_on_syslog); };
352
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
353
  inline bool do_dump_flows_on_kafka() {
354
    return ((kafka_brokers_list && kafka_topic) ? true : false);
355
  };
356
#endif
357
0
  inline bool do_dump_extended_json() { return (dump_ext_json); };
358
0
  inline bool do_dump_json_flows_on_disk() {
359
0
    return (dump_json_flows_on_disk);
360
0
  };
361
5.81k
  inline bool do_dump_flows() {
362
5.81k
    return (do_dump_flows_on_es() || do_dump_flows_on_clickhouse() ||
363
5.81k
            do_dump_flows_on_syslog()
364
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
365
            || do_dump_flows_on_kafka()
366
#endif
367
5.81k
    );
368
5.81k
  };
369
370
#ifdef NTOPNG_PRO
371
  inline u_int32_t get_dump_queue_len() { return dump_queue_len; };
372
  inline u_int32_t get_dump_queue_block_size() {
373
    return dump_queue_block_size;
374
  };
375
  inline void toggle_dump_flows_direct(bool enable) {
376
    dump_flows_direct = enable;
377
  };
378
  inline bool do_dump_flows_direct() { return (dump_flows_direct); };
379
#endif
380
0
  inline bool is_runtime_flows_dump_enabled() const {
381
0
    return (enable_runtime_flows_dump);
382
0
  };
383
0
  inline bool is_readonly_flows_dump() { return (readonly_flows_dump); };
384
5.81k
  inline bool is_flows_dump_enabled() {
385
5.81k
    return (do_dump_flows() && is_runtime_flows_dump_enabled() &&
386
0
            !readonly_flows_dump);
387
5.81k
  };
388
  int32_t getDefaultPrefsValue(const char* pref_key, int32_t default_value);
389
  void getDefaultStringPrefsValue(const char* pref_key, char** buffer,
390
                                  const char* default_value);
391
  char* get_if_name(int id);
392
  char* get_if_alias(int id);
393
  char* get_if_descr(int id);
394
0
  inline const char* get_config_file_path() { return (config_file_path); };
395
0
  inline const char* get_ndpi_proto_file_path() { return (ndpi_proto_path); };
396
0
  void set_data_dir(char* path) { data_dir = path; }
397
2
  inline char* get_data_dir() { return (data_dir); };
398
6
  inline char* get_docs_dir() { return (docs_dir); };  // HTTP docs
399
0
  inline const char* get_scripts_dir() { return (scripts_dir); };
400
2
  inline const char* get_callbacks_dir() { return (callbacks_dir); };
401
0
  inline char* get_influx_internal_db_name() {
402
0
    return (influx_internal_db_name);
403
0
  };
404
  void set_influx_internal_db_name(char* internal_name);
405
0
  inline bool get_influx_internal_available() {
406
0
    return (influx_internal_available);
407
0
  };
408
0
  inline void set_influx_internal_available(bool available) {
409
0
    influx_internal_available = available;
410
0
  };
411
0
  void set_callback_dir(char* path) { callbacks_dir = path; };
412
0
  inline const char* get_pcap_dir() { return (pcap_dir); };
413
0
  inline const char* get_clickhouse_archive_dir() {
414
0
    return (clickhouse_archive_dir);
415
0
  };
416
#ifdef NTOPNG_PRO
417
  inline const char* get_pro_callbacks_dir() { return (pro_callbacks_dir); };
418
#endif
419
0
  inline const char* get_test_pre_script_path() {
420
0
    return (test_pre_script_path);
421
0
  };
422
0
  inline const char* get_test_runtime_script_path() {
423
0
    return (test_runtime_script_path);
424
0
  };
425
0
  inline const char* get_test_post_script_path() {
426
0
    return (test_post_script_path);
427
0
  };
428
0
  inline const char* get_message_broker_url() { return (message_broker_url); };
429
0
  inline const char* get_message_broker() { return (message_broker); };
430
0
  inline bool is_message_broker_enabled() { return (message_broker_enabled); };
431
0
  inline char* get_export_endpoint() { return (export_endpoint); };
432
0
  inline char* get_export_zmq_encryption_key() {
433
0
    return (export_zmq_encryption_key);
434
0
  };
435
0
  inline char* get_categorization_key() { return (categorization_key); };
436
0
  inline char* get_http_prefix() { return (http_prefix); };
437
0
  inline char* get_instance_name() { return (instance_name); };
438
439
0
  inline bool do_auto_logout() { return (enable_auto_logout); };
440
0
  inline bool do_auto_logout_at_runtime() {
441
0
    return (enable_auto_logout_at_runtime);
442
0
  };
443
0
  inline bool interface_name_only() { return (enable_interface_name_only); };
444
2.29k
  inline bool do_ignore_vlans() { return (ignore_vlans); };
445
83.7k
  inline bool do_ignore_macs() { return (ignore_macs); };
446
77.7k
  inline bool do_simulate_vlans() { return (simulate_vlans); };
447
72.7k
  inline bool do_simulate_macs() { return (simulate_macs); };
448
0
  inline bool do_insecure_tls() { return (insecure_tls); };
449
0
  inline bool do_snmp_polling() { return (snmp_polling); };
450
  bool do_active_monitoring();
451
0
  inline bool get_active_monitoring_pref() { return (active_monitoring); };
452
0
  inline bool do_tls_quic_hostnaming() { return (tls_quic_hostnaming); };
453
0
  inline bool email_starttls_enabled() { return (starttls); };
454
0
  inline bool dump_pcap_to_clickhouse_enabled() {
455
0
    return (dump_pcap_to_clickhouse);
456
0
  };
457
0
  inline bool query_performance_log_enabled() {
458
0
    return (query_performance_log);
459
0
  };
460
0
  inline char* get_cpu_affinity() { return (cpu_affinity); };
461
0
  inline char* get_other_cpu_affinity() { return (other_cpu_affinity); };
462
#ifdef __linux__
463
0
  inline cpu_set_t* get_other_cpu_affinity_mask() {
464
0
    return (&other_cpu_affinity_mask);
465
0
  };
466
#endif
467
0
  inline u_int get_http_port() { return (http_port); };
468
0
  inline u_int get_https_port() { return (https_port); };
469
0
  inline bool is_client_x509_auth_enabled() {
470
0
    return (enable_client_x509_auth);
471
0
  };
472
4
  inline char* get_redis_host() { return (redis_host); }
473
4
  inline char* get_redis_password() { return (redis_password); }
474
4
  inline char* get_redis_tls_ca_cert() { return (redis_tls_ca_cert); }
475
4
  inline char* get_redis_tls_cert() { return (redis_tls_cert); }
476
4
  inline char* get_redis_tls_key() { return (redis_tls_key); }
477
4
  inline bool get_redis_tls_skip_verify() { return (redis_tls_skip_verify); }
478
4
  inline u_int get_redis_port() { return (redis_port); };
479
4
  inline u_int get_redis_db_id() { return (redis_db_id); };
480
0
  inline char* get_pid_path() { return (pid_path); };
481
0
  inline char* get_packet_filter() { return (packet_filter); };
482
483
6
  inline u_int32_t get_max_num_hosts() { return (max_num_hosts); };
484
6
  inline u_int32_t get_max_num_flows() { return (max_num_flows); };
485
486
0
  inline bool daemonize_ntopng() { return (daemonize); };
487
488
0
  inline u_int32_t get_attacker_max_num_flows_per_sec() {
489
0
    return (attacker_max_num_flows_per_sec);
490
0
  };
491
0
  inline u_int32_t get_victim_max_num_flows_per_sec() {
492
0
    return (victim_max_num_flows_per_sec);
493
0
  };
494
0
  inline u_int32_t get_attacker_max_num_syn_per_sec() {
495
0
    return (attacker_max_num_syn_per_sec);
496
0
  };
497
0
  inline u_int32_t get_victim_max_num_syn_per_sec() {
498
0
    return (victim_max_num_syn_per_sec);
499
0
  };
500
201
  inline u_int8_t get_ewma_alpha_percent() { return (ewma_alpha_percent); };
501
502
  void add_default_interfaces();
503
  int loadFromCLI(int argc, char* argv[]);
504
  int loadFromFile(const char* path);
505
  void add_network_interface(char* name, char* description);
506
0
  inline bool json_labels_as_strings() { return (json_labels_string_format); };
507
0
  inline void set_json_symbolic_labels_format(bool as_string) {
508
0
    json_labels_string_format = as_string;
509
0
  };
510
  void set_routing_mode(bool enabled);
511
  virtual void lua(lua_State* vm);
512
  void reloadPrefsFromRedis();
513
  void loadInstanceNameDefaults();
514
  void resetDeferredInterfacesToRegister();
515
  bool addDeferredInterfaceToRegister(const char* ifname);
516
  void registerNetworkInterfaces();
517
  void refreshHostsAlertsPrefs();
518
  void refreshDeviceProtocolsPolicyPref();
519
  /* Runtime database dump prefs. Allows the user to toggle flows dump from the
520
   * UI at runtime. */
521
  void refreshDbDumpPrefs();
522
523
  void bind_http_to_address(const char* addr1, const char* addr2);
524
  void bind_https_to_address(const char* addr1, const char* addr2);
525
0
  void bind_http_to_loopback() {
526
0
    bind_http_to_address((char*)CONST_LOOPBACK_ADDRESS,
527
0
                         (char*)CONST_LOOPBACK_ADDRESS);
528
0
  };
529
0
  inline void bind_https_to_loopback() {
530
0
    bind_https_to_address((char*)CONST_LOOPBACK_ADDRESS,
531
0
                          (char*)CONST_LOOPBACK_ADDRESS);
532
0
  };
533
  inline void get_http_binding_addresses(const char** addr1,
534
0
                                         const char** addr2) {
535
0
    *addr1 = http_binding_address1;
536
0
    *addr2 = http_binding_address2;
537
0
  };
538
  inline void get_https_binding_addresses(const char** addr1,
539
0
                                          const char** addr2) {
540
0
    *addr1 = https_binding_address1;
541
0
    *addr2 = https_binding_address2;
542
0
  };
543
544
0
  inline bool checkServiceLicense() { return (service_license_check); };
545
0
  inline void disableServiceLicense() { service_license_check = false; };
546
0
  inline char* get_es_type() { return (es_type); };
547
0
  inline char* get_es_index() { return (es_index); };
548
0
  inline char* get_es_url() { return (es_url); };
549
0
  inline char* get_es_user() { return (es_user); };
550
0
  inline char* get_es_pwd() { return (es_pwd); };
551
0
  const inline char* get_es_host() { return (es_host); };
552
0
  inline bool shutdownWhenDone() { return (shutdown_when_done); }
553
0
  inline void set_promiscuous_mode(bool mode) { use_promiscuous_mode = mode; };
554
0
  inline bool use_promiscuous() { return (use_promiscuous_mode); };
555
556
0
  inline char* get_clickhouse_host() { return (clickhouse_host); };
557
0
  inline int get_clickhouse_tcp_port() { return (clickhouse_tcp_port); };
558
0
  inline bool is_clickhouse_tcp_port_secure() {
559
0
    return (clickhouse_tcp_port_secure);
560
0
  };
561
0
  inline char* get_clickhouse_dbname() { return (clickhouse_dbname); };
562
0
  inline char* get_clickhouse_user() { return (clickhouse_user); };
563
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO)
564
  /* If this is not NULL, it means that the user is using CH Cloud */
565
  inline char* get_clickhouse_cluster_user() {
566
    return (clickhouse_cluster_user);
567
  };
568
#endif
569
0
  inline char* get_clickhouse_pw() { return (clickhouse_pw); };
570
0
  inline char* get_clickhouse_ro_user() { return (clickhouse_ro_user); };
571
0
  inline char* get_clickhouse_ro_pw() { return (clickhouse_ro_pw); };
572
573
#if !defined(WIN32) && !defined(__APPLE__)
574
0
  inline int get_flows_syslog_facility() { return (flows_syslog_facility); };
575
#endif
576
0
  inline char* get_ls_host() { return (ls_host); };
577
0
  inline char* get_ls_port() { return (ls_port); };
578
0
  inline char* get_ls_proto() { return (ls_proto); };
579
0
  inline char* get_zmq_encryption_pwd() { return (zmq_encryption_pwd); };
580
0
  inline char* get_zmq_encryption_priv_key() {
581
0
    return (zmq_encryption_priv_key);
582
0
  };
583
0
  inline bool is_zmq_encryption_enabled() { return (enable_zmq_encryption); };
584
0
  inline char* get_command_line() { return (cli ? cli : (char*)""); };
585
586
0
  inline void add_lan_interface(char* iface) { lan_interfaces.insert(iface); };
587
0
  inline void add_wan_interface(char* iface) { wan_interfaces.insert(iface); };
588
589
0
  inline bool is_lan_interface(char* iface) {
590
0
    return lan_interfaces.find(iface) != lan_interfaces.end();
591
0
  }
592
0
  inline bool is_wan_interface(char* iface) {
593
0
    return wan_interfaces.find(iface) != wan_interfaces.end();
594
0
  }
595
596
0
  inline int get_num_lan_interfaces() { return lan_interfaces.size(); }
597
0
  inline int get_num_wan_interfaces() { return wan_interfaces.size(); }
598
599
0
  inline InterfacesSet* get_lan_interfaces() { return &lan_interfaces; }
600
0
  inline InterfacesSet* get_wan_interfaces() { return &wan_interfaces; }
601
602
48.3k
  inline bool areMacNdpiStatsEnabled() { return (enable_mac_ndpi_stats); };
603
0
  inline pcap_direction_t getCaptureDirection() { return (captureDirection); };
604
0
  inline void setCaptureDirection(pcap_direction_t dir) {
605
0
    captureDirection = dir;
606
0
  };
607
#ifdef HAVE_PF_RING
608
  inline bool hasPF_RINGClusterID() { return pfring_cluster_id >= 0; };
609
  inline int getPF_RINGClusterID() { return pfring_cluster_id; };
610
#endif
611
0
  inline bool hasCmdlTraceLevel() { return has_cmdl_trace_lvl; };
612
0
  inline u_int32_t get_auth_session_duration() {
613
0
    return (auth_session_duration);
614
0
  };
615
0
  inline bool get_auth_session_midnight_expiration() {
616
0
    return (auth_session_midnight_expiration);
617
0
  };
618
420k
  inline u_int32_t get_housekeeping_frequency() {
619
420k
    return (housekeeping_frequency);
620
420k
  };
621
39.5k
  inline u_int32_t get_host_max_idle(bool localHost) const {
622
39.5k
    return (localHost ? local_host_max_idle : non_local_host_max_idle);
623
39.5k
  };
624
  /* Maximum idleness for hosts with alerts engaged, that is, with ongoing
625
   * issues. */
626
0
  inline u_int32_t get_alerted_host_max_idle() const {
627
0
    return (local_host_max_idle); /* Treat all hosts as local */
628
0
  };
629
0
  inline u_int32_t get_local_host_cache_duration() {
630
0
    return (local_host_cache_duration);
631
0
  };
632
5.94k
  inline u_int32_t get_pkt_ifaces_flow_max_idle() {
633
5.94k
    return (pkt_ifaces_flow_max_idle);
634
5.94k
  };
635
0
  inline char* getHttpIndexPage() { return http_index_page; };
636
637
11.4k
  inline bool isASNModeEnabled() { return asn_mode_enabled; };
638
8.03k
  inline bool are_top_talkers_enabled() { return (enable_top_talkers); };
639
0
  inline bool are_sites_collection_enabled() {
640
0
    return (enable_sites_collection);
641
0
  };
642
53.3k
  inline bool is_dns_cache_enabled() { return (enable_dns_cache); };
643
0
  inline bool flow_table_duration_or_last_seen() { return (flow_table_time); };
644
0
  inline bool is_active_local_host_cache_enabled() {
645
0
    return (enable_active_local_hosts_cache);
646
0
  };
647
648
0
  inline bool is_tiny_flows_export_enabled() {
649
0
    return (enable_tiny_flows_export);
650
0
  };
651
0
  inline bool is_flow_device_port_rrd_creation_enabled() {
652
0
    return (enable_flow_device_port_rrd_creation);
653
0
  };
654
0
  inline bool is_observation_points_rrd_creation_enabled() {
655
0
    return (enable_observation_points_rrd_creation);
656
0
  };
657
0
  inline char* get_http_log_path() { return (http_log_path); };
658
0
  inline bool is_intranet_traffic_rrd_creation_enabled() {
659
0
    return (enable_intranet_traffic_rrd_creation);
660
0
  };
661
0
  inline bool is_arp_matrix_generation_enabled() {
662
0
    return (enable_arp_matrix_generation);
663
0
  };
664
665
0
  inline bool do_override_dst_with_post_nat_dst() const {
666
0
    return (override_dst_with_post_nat_dst);
667
0
  };
668
0
  inline bool do_override_src_with_post_nat_src() const {
669
0
    return (override_src_with_post_nat_src);
670
0
  };
671
0
  inline bool are_device_protocol_policies_enabled() const {
672
0
    return (device_protocol_policies_enabled);
673
0
  };
674
675
0
  inline bool isVLANTrunkModeEnabled() const {
676
0
    return (enable_vlan_trunk_bridge);
677
0
  }
678
0
  inline bool isCaptivePortalEnabled() const {
679
0
    return (enable_captive_portal && !enable_vlan_trunk_bridge);
680
0
  }
681
682
0
  inline bool enableActivitiesDebug() const {
683
0
    return (enable_activities_debug);
684
0
  }
685
686
#ifdef HAVE_NEDGE
687
  bool isInformativeCaptivePortalEnabled() const;
688
  bool isExternalAuthCaptivePortalEnabled() const;
689
  const char* getCaptivePortalUrl();
690
691
  inline bool isMacBasedCaptivePortal() const {
692
    return (mac_based_captive_portal);
693
  }
694
#endif
695
0
  const TsDriver getTimeseriesDriver() const { return (timeseries_driver); }
696
0
  inline u_int8_t getDefaultl7Policy() { return (default_l7policy); }
697
698
0
  inline u_int32_t get_dump_frequency() const { return (dump_frequency); };
699
0
  inline u_int32_t get_max_num_packets_per_tiny_flow() const {
700
0
    return (max_num_packets_per_tiny_flow);
701
0
  };
702
0
  inline u_int32_t get_max_num_bytes_per_tiny_flow() const {
703
0
    return (max_num_bytes_per_tiny_flow);
704
0
  };
705
706
0
  inline u_int64_t get_max_extracted_pcap_bytes() {
707
0
    return max_extracted_pcap_bytes;
708
0
  };
709
710
0
  inline u_int64_t get_max_extracted_pcap_files() {
711
0
    return max_extracted_pcap_files;
712
0
  };
713
714
0
  inline u_int32_t get_safe_search_dns_ip() { return (safe_search_dns_ip); };
715
0
  inline u_int32_t get_global_primary_dns_ip() {
716
0
    return (global_primary_dns_ip);
717
0
  };
718
0
  inline u_int32_t get_global_secondary_dns_ip() {
719
0
    return (global_secondary_dns_ip);
720
0
  };
721
0
  inline bool isGlobalDNSDefined() {
722
0
    return (global_primary_dns_ip ? true : false);
723
0
  };
724
29.8k
  inline HostMask getHostMask() { return (hostMask); };
725
0
  inline u_int16_t get_auto_assigned_pool_id() {
726
0
    return (auto_assigned_pool_id);
727
0
  };
728
0
  inline u_int16_t is_routing_mode() { return (routing_mode_enabled); };
729
#ifndef HAVE_NEDGE
730
0
  inline bool is_appliance() { return (appliance); };
731
#endif
732
0
  inline bool isGlobalDnsForgingEnabled() {
733
0
    return (global_dns_forging_enabled);
734
0
  };
735
0
  inline bool reproduceOriginalSpeed() {
736
0
    return (reproduce_at_original_speed);
737
0
  };
738
0
  inline void doReproduceOriginalSpeed() {
739
0
    reproduce_at_original_speed = true;
740
0
  };
741
0
  inline bool purgeHostsFlowsOnPcapFiles() {
742
0
    return (pcap_file_purge_hosts_flows /* || dump_flows_on_clickhouse */);
743
0
  };
744
68.0k
  inline bool disablePurge() { return (disable_purge); };
745
0
  inline bool isStrictStartup() { return (strict_startup); };
746
0
  inline void enableBehaviourAnalysis() { enable_behaviour_analysis = true; };
747
0
  inline bool isBehavourAnalysisEnabled() {
748
0
    return (enable_behaviour_analysis);
749
0
  };
750
0
  inline u_int32_t behaviourAnalysisLearningPeriod() {
751
0
    return behaviour_analysis_learning_period;
752
0
  };
753
754
616
  inline bool isBroadcastDomainTooLargeEnabled() {
755
616
    return (enable_broadcast_domain_too_large);
756
616
  };
757
758
0
  inline bool isASNBehavourAnalysisEnabled() {
759
0
    return (enable_asn_behaviour_analysis);
760
0
  };
761
0
  inline bool isNetworkBehavourAnalysisEnabled() {
762
0
    return (enable_network_behaviour_analysis);
763
0
  };
764
2
  inline bool isIfaceL7BehavourAnalysisEnabled() {
765
2
    return (enable_iface_l7_behaviour_analysis);
766
2
  };
767
768
0
  inline ServiceAcceptance behaviourAnalysisStatusDuringLearning() {
769
0
    return behaviour_analysis_learning_status_during_learning;
770
0
  };
771
0
  inline ServiceAcceptance behaviourAnalysisStatusPostLearning() {
772
0
    return behaviour_analysis_learning_status_post_learning;
773
0
  };
774
4.09k
  inline u_int64_t* getIEC104AllowedTypeIDs() {
775
4.09k
    return (iec104_allowed_typeids);
776
4.09k
  };
777
3.50k
  inline u_int32_t getIEC60870LearingPeriod() {
778
3.50k
    return (iec60870_learning_period);
779
3.50k
  };
780
0
  inline u_int32_t getModbusLearningPeriod() {
781
0
    return (modbus_learning_period);
782
0
  };
783
0
  inline u_int32_t getS7CommLearningPeriod() {
784
0
    return (s7comm_learning_period);
785
0
  };
786
#ifdef NTOPNG_PRO
787
  inline bool isAssetInventoryEnabled() {
788
    return (asset_inventory_enabled && !isASNModeEnabled());
789
  };
790
  inline bool isSNMPTrapEnabled() { return snmp_trap_enabled; };
791
  inline ndpi_bitmap* getModbusAllowedFunctionCodes() {
792
    return (modbus_allowed_function_codes);
793
  };
794
  inline void setModbusTooManyExceptionsThreshold(u_int v) {
795
    modbus_too_many_exceptions = v;
796
  }
797
  inline u_int getModbusTooManyExceptionsThreshold() {
798
    return (modbus_too_many_exceptions);
799
  }
800
  inline ndpi_bitmap* getS7CommAllowedFunctionCodes() {
801
    return (s7comm_allowed_function_codes);
802
  };
803
  inline void setS7CommTooManyErrorsThreshold(u_int v) {
804
    s7comm_too_many_errors = v;
805
  }
806
  inline u_int getS7CommTooManyErrorsThreshold() {
807
    return (s7comm_too_many_errors);
808
  }
809
  inline void setProfinetTooManyErrorsThreshold(u_int v) {
810
    profinet_too_many_errors = v;
811
  }
812
  inline u_int getProfinetTooManyErrorsThreshold() {
813
    return (profinet_too_many_errors);
814
  }
815
#endif
816
0
  inline u_int32_t devicesLearingPeriod() { return (devices_learning_period); };
817
1.40k
  inline u_int32_t macAddressCacheDuration() {
818
1.40k
    return (mac_address_cache_duration);
819
1.40k
  };
820
0
  inline u_int32_t hostPortLearningPeriod() {
821
0
    return (host_port_learning_period);
822
0
  };
823
27.1k
  inline bool isFlowSwapHeuristicEnabled() {
824
27.1k
    return (enable_flow_swap_heuristic);
825
27.1k
  };
826
0
  inline bool skipDPIforCollectedFlows() {
827
0
    return (skip_dpi_for_collected_flows);
828
0
  };
829
0
  inline bool are_alerts_disabled() { return (disable_alerts); };
830
0
  inline bool dontEmitFlowAlerts() {
831
0
    return (disable_alerts || !emit_flow_alerts);
832
0
  };
833
0
  inline bool dontEmitHostAlerts() {
834
0
    return (disable_alerts || !emit_host_alerts);
835
0
  };
836
0
  inline void dontUseClickHouse() { dump_flows_on_clickhouse = false; };
837
0
  inline char* getZMQPublishEventsURL() { return (zmq_publish_events_url); };
838
0
  inline const char* getClickHouseClientPath() { return (clickhouse_client); };
839
0
  inline const char* getClickHouseClusterName() {
840
0
    return (clickhouse_cluster_name);
841
0
  };
842
#ifdef NTOPNG_PRO
843
  void setModbusAllowedFunctionCodes(const char* function_codes);
844
  void setS7CommAllowedFunctionCodes(const char* function_codes);
845
#endif
846
  void setIEC104AllowedTypeIDs(const char* type_ids);
847
  void validate();
848
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
849
  char* getKakfaBrokersList() { return (kafka_brokers_list); }
850
  char* getKafkaTopic() { return (kafka_topic); }
851
  char* getKafkaOptions() { return (kafka_options); }
852
#endif
853
  void reloadServersConfiguration();
854
  void reloadASNConfiguration();
855
#ifdef NTOPNG_PRO
856
  bool reloadNetworksPolicyConfiguration();
857
  bool loadPolicyConfiguration(AddressTree* tree, char* key,
858
                               NetworkConfigurationId id);
859
  AddressTree* getNetworksPolicyConfiguration();
860
#endif
861
  bool isGateway(IpAddress* ip, u_int16_t vlan_id);
862
  bool isDNSServer(IpAddress* ip, u_int16_t vlan_id);
863
  bool isNTPServer(IpAddress* ip, u_int16_t vlan_id);
864
  bool isSMTPServer(IpAddress* ip, u_int16_t vlan_id);
865
  bool isDHCPServer(IpAddress* ip, u_int16_t vlan_id);
866
867
  bool isCustomerASN(u_int32_t asn);
868
  bool isSubCustomerASN(u_int32_t asn);
869
  bool isRemoteASN(u_int32_t asn);
870
871
0
  ServerConfiguration* getConfiguredGateways() { return (gateway); }
872
0
  ServerConfiguration* getConfiguredDNSServers() { return (dns_servers); }
873
0
  ServerConfiguration* getConfiguredNTPServers() { return (ntp_servers); }
874
0
  ServerConfiguration* getConfiguredSMTPServers() { return (smtp_servers); }
875
0
  ServerConfiguration* getConfiguredDHCPServers() { return (dhcp_servers); }
876
877
0
  ASNConfiguration* getCustomerASN() { return (customer_asn); }
878
0
  ASNConfiguration* getSubCustomerASN() { return (sub_customer_asn); }
879
0
  ASNConfiguration* getRemoteASN() { return (remote_asn); }
880
881
#ifndef HAVE_NEDGE
882
75.4k
  inline bool useMacAddressInFlowKey() { return (use_mac_in_flow_key); }
883
#endif
884
28.0k
  inline bool useHostPoolsForLocal() const { return use_host_pools_for_local; }
885
11.8k
  inline bool areFingerprintStatsEnabled() { return (fingerprint_stats); }
886
0
  inline bool doReforgeTimestamps() { return (do_reforge_timestamps); }
887
0
  inline void enableVLANCloudToExporters() {
888
0
    add_vlan_tags_to_cloud_exporters = true;
889
0
  }
890
0
  inline bool addVLANCloudToExporters() {
891
0
    return (add_vlan_tags_to_cloud_exporters);
892
0
  }
893
0
  inline bool collectBlackListStats() { return (collect_blacklist_stats); }
894
111k
  inline bool limitResourcesUsage() { return (limited_resources_mode); }
895
0
  inline bool failOnInvalidLicense() { return (fail_on_invalid_license); }
896
0
  inline char* getCiphersList() { return (ciphers_list); }
897
#ifdef NTOPNG_PRO
898
  inline char* getLicMgrConfigFile() { return (lic_mgr_config_file); }
899
  inline AddressTree* getNwPolicyConfig() {
900
    return (networks_policy_configuration);
901
  }
902
#endif
903
2
  inline char* getCustomGeoIPDir() { return (custom_geoip_dir); }
904
  void setCustomGeoIPDir(char* d);
905
906
53.6k
  inline bool fullStatsEnabled() { return (full_stats_enabled); }
907
0
  inline bool isFlowDedupEnabled() {
908
0
    return (is_enterprise_xl_edition() ? true : false);
909
0
  }
910
};
911
912
#endif /* _PREFS_H_ */