Coverage Report

Created: 2026-09-14 06:54

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