Coverage Report

Created: 2025-05-16 06:24

/src/ntopng/include/Prefs.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *
3
 * (C) 2013-25 - 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, *custom_geoip_dir;
45
  char *http_binding_address1, *http_binding_address2;
46
  char *https_binding_address1, *https_binding_address2;
47
  char *http_index_page;
48
  bool enable_client_x509_auth, reproduce_at_original_speed, disable_purge;
49
  char* zmq_publish_events_url, *http_log_path;
50
  const char *clickhouse_client, *clickhouse_cluster_name;
51
  Ntop* ntop;
52
  bool enable_dns_resolution, sniff_dns_responses, sniff_name_responses,
53
    sniff_local_name_responses, pcap_file_purge_hosts_flows,
54
    categorization_enabled, resolve_all_host_ip, change_user, daemonize,
55
    enable_auto_logout, enable_auto_logout_at_runtime, use_promiscuous_mode,
56
    enable_ixia_timestamps,
57
    enable_interface_name_only, enable_users_login, disable_localhost_login,
58
    service_license_check, enable_sql_log, enable_access_log, enable_assets_log, log_to_file,
59
    enable_mac_ndpi_stats, enable_activities_debug, enable_behaviour_analysis,
60
    enable_asn_behaviour_analysis, enable_network_behaviour_analysis,
61
    enable_iface_l7_behaviour_analysis, emit_flow_alerts, emit_host_alerts,
62
    dump_flows_on_clickhouse, use_mac_in_flow_key, do_reforge_timestamps,
63
    add_vlan_tags_to_cloud_exporters, collect_blacklist_stats,
64
    fail_on_invalid_license, limited_resources_mode, fingerprint_stats,
65
    tls_quic_hostnaming;
66
  u_int32_t behaviour_analysis_learning_period;
67
  u_int32_t iec60870_learning_period, modbus_learning_period,
68
    devices_learning_period, mac_address_cache_duration, enable_assets_collection;
69
  u_int32_t host_port_learning_period;
70
#ifdef NTOPNG_PRO
71
  ndpi_bitmap* modbus_allowed_function_codes;
72
  u_int modbus_too_many_exceptions;
73
  bool netbox_enabled, asset_inventory_enabled, snmp_trap_enabled;
74
#endif
75
  ServiceAcceptance behaviour_analysis_learning_status_during_learning,
76
      behaviour_analysis_learning_status_post_learning;
77
  TsDriver timeseries_driver;
78
  u_int64_t iec104_allowed_typeids[2];
79
  u_int32_t auth_session_duration;
80
  bool auth_session_midnight_expiration;
81
82
  u_int32_t non_local_host_max_idle, local_host_cache_duration,
83
      local_host_max_idle, pkt_ifaces_flow_max_idle;
84
  u_int32_t active_local_hosts_cache_interval;
85
  u_int32_t intf_rrd_raw_days, intf_rrd_1min_days, intf_rrd_1h_days,
86
      intf_rrd_1d_days;
87
  u_int32_t other_rrd_raw_days, other_rrd_1min_days, other_rrd_1h_days,
88
      other_rrd_1d_days;
89
  u_int32_t housekeeping_frequency;
90
  bool disable_alerts, enable_top_talkers, enable_sites_collection, 
91
      enable_active_local_hosts_cache, enable_dns_cache;
92
  bool enable_flow_device_port_rrd_creation,
93
      enable_observation_points_rrd_creation,
94
      enable_intranet_traffic_rrd_creation;
95
  bool enable_tiny_flows_export;
96
  bool enable_captive_portal, enable_informative_captive_portal,
97
      mac_based_captive_portal, enable_external_auth_captive_portal;
98
  bool override_dst_with_post_nat_dst, override_src_with_post_nat_src;
99
  bool routing_mode_enabled, global_dns_forging_enabled;
100
  bool device_protocol_policies_enabled, enable_vlan_trunk_bridge;
101
  bool enable_arp_matrix_generation;
102
  bool enable_zmq_encryption;
103
  bool flow_table_time, flow_table_probe_order;
104
  bool enable_broadcast_domain_too_large;
105
  u_int32_t max_num_secs_before_delete_alert, alert_page_refresh_rate;
106
  int32_t max_entity_alerts;
107
  u_int32_t safe_search_dns_ip, global_primary_dns_ip, global_secondary_dns_ip;
108
  u_int32_t max_num_packets_per_tiny_flow, max_num_bytes_per_tiny_flow,
109
      dump_frequency;
110
  u_int32_t max_extracted_pcap_bytes;
111
  u_int32_t max_ui_strlen;
112
  u_int8_t default_l7policy;
113
  HostMask hostMask;
114
115
  u_int32_t max_num_hosts, max_num_flows;
116
  u_int32_t attacker_max_num_flows_per_sec, victim_max_num_flows_per_sec;
117
  u_int32_t attacker_max_num_syn_per_sec, victim_max_num_syn_per_sec;
118
  u_int8_t ewma_alpha_percent;
119
  u_int http_port, https_port;
120
  u_int8_t num_interfaces;
121
  u_int16_t auto_assigned_pool_id;
122
  u_int8_t vs_max_num_scans;
123
  bool vs_slow_scan; 
124
  bool dump_flows_on_es, dump_flows_on_mysql, dump_flows_on_syslog,
125
      dump_json_flows_on_disk, dump_ext_json;
126
#ifdef NTOPNG_PRO
127
  bool dump_flows_direct;
128
  u_int32_t max_aggregated_flows_upperbound, max_aggregated_flows_traffic_upperbound;
129
#endif
130
  bool enable_runtime_flows_dump; /**< runtime preference to enable/disable
131
                                     flows dump from the UI */
132
  InterfaceInfo* ifNames;
133
  char* local_networks;
134
  bool local_networks_set, shutdown_when_done, simulate_vlans, simulate_macs,
135
      ignore_vlans, ignore_macs;
136
  bool insecure_tls; /**< Unsecure TLS connections a-la curl */
137
  u_int32_t num_simulated_ips;
138
  char *data_dir, *install_dir, *docs_dir, *scripts_dir, *callbacks_dir,
139
      *pcap_dir
140
#ifdef NTOPNG_PRO
141
      ,
142
      *pro_callbacks_dir
143
#endif
144
      ;
145
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
146
  char *kafka_brokers_list, *kafka_topic, *kafka_options;
147
#endif
148
  char* categorization_key;
149
  char* zmq_encryption_pwd;
150
  char* zmq_encryption_priv_key;
151
  char *export_endpoint, *export_zmq_encryption_key;
152
  char* http_prefix;
153
  char* instance_name;
154
  char *config_file_path, *ndpi_proto_path;
155
  char* packet_filter;
156
  char* user;
157
  bool user_set;
158
  char* redis_host;
159
  char* redis_password;
160
  char* pid_path;
161
  char *cpu_affinity, *other_cpu_affinity;
162
#ifdef __linux__
163
  cpu_set_t other_cpu_affinity_mask;
164
#endif
165
  u_int8_t redis_db_id;
166
  int redis_port;
167
  int dns_mode;
168
  bool json_labels_string_format;
169
  char *es_type, *es_index, *es_url, *es_user, *es_pwd, *es_host;
170
  char *mysql_host, *mysql_dbname, *mysql_user, *mysql_pw;
171
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO) && defined(HAVE_MYSQL)
172
  char *ch_user; /* In case of ch cloud, 2 users are needed, 
173
                    one for mysql and one for ch */
174
  bool ntopng_assets_inventory_enabled;
175
#endif
176
#if !defined(WIN32) && !defined(__APPLE__)
177
  int flows_syslog_facility;
178
#endif
179
  int mysql_port, clickhouse_tcp_port;
180
  bool mysql_port_secure, clickhouse_tcp_port_secure;
181
  char *ls_host, *ls_port, *ls_proto;
182
  bool has_cmdl_trace_lvl; /**< Indicate whether a verbose level
183
                              has been provided on the command line.*/
184
#ifndef HAVE_NEDGE
185
  bool appliance;
186
#endif
187
188
  ServerConfiguration *gateway, *dns_servers, *ntp_servers, *smtp_servers, *dhcp_servers;
189
190
#ifdef NTOPNG_PRO
191
  AddressTree *networks_policy_configuration;
192
  AddressTree *networks_policy_configuration_shadow;
193
#endif
194
195
#ifdef HAVE_PF_RING
196
  int pfring_cluster_id;
197
#endif
198
199
  char* test_pre_script_path;
200
  char* test_runtime_script_path;
201
  char* test_post_script_path;
202
203
  char *message_broker_url, *message_broker;
204
  bool message_broker_enabled;
205
#ifdef NTOPNG_PRO
206
  bool print_maintenance, print_license;
207
  char *lic_mgr_config_file;
208
#endif
209
  bool print_version, print_version_json;
210
  bool snmp_polling;
211
  bool active_monitoring, network_discovery, starttls;
212
  bool dump_pcap_to_clickhouse; /* Dump pcap-interface flows to ClickHouse */
213
214
  InterfacesSet lan_interfaces, wan_interfaces;
215
216
0
  inline void help() { usage(); }
217
0
  inline void nDPIhelp() { nDPIusage(); }
218
  void setCommandLineString(int optkey, const char* optarg);
219
  int setOption(int optkey, char* optarg);
220
  int checkOptions();
221
222
  void setTraceLevelFromRedis();
223
  void parseHTTPPort(char* arg);
224
  char* parseLocalNetworks(char* arg);
225
226
0
  static inline void set_binding_address(char** const dest, const char* addr) {
227
0
    if (dest && addr && addr[0] != '\0') {
228
0
      if (*dest) free(*dest);
229
0
      *dest = strdup(addr);
230
0
    }
231
0
  };
232
  bool getDefaultBoolPrefsValue(const char* pref_key, const bool default_value);
233
  void refreshBehaviourAnalysis();
234
235
 public:
236
  Prefs(Ntop* _ntop);
237
  virtual ~Prefs();
238
239
  bool is_pro_edition();
240
  bool is_enterprise_m_edition();
241
  bool is_enterprise_l_edition();
242
  bool is_enterprise_xl_edition();
243
  bool is_enterprise_xxl_edition();
244
245
115k
  bool is_edr_mode() { return false; /* TODO (used to be private Cloud mode) */ };
246
247
  bool is_nedge_pro_edition();
248
  bool is_nedge_enterprise_edition();
249
250
  bool is_embedded_edition();
251
252
  time_t pro_edition_demo_ends_at();
253
2
  inline char* get_local_networks() {
254
2
    if (!local_networks_set) return NULL;
255
0
    return (local_networks);
256
2
  };
257
0
  inline void disable_dns_resolution() { enable_dns_resolution = false; };
258
0
  inline void resolve_all_hosts() { resolve_all_host_ip = true; };
259
4.18k
  inline bool is_dns_resolution_enabled_for_all_hosts() {
260
4.18k
    return (resolve_all_host_ip);
261
4.18k
  };
262
18.9k
  inline bool is_dns_resolution_enabled() { return (enable_dns_resolution); };
263
0
  inline bool is_users_login_enabled() { return (enable_users_login); };
264
0
  inline bool is_localhost_users_login_disabled() {
265
0
    return (disable_localhost_login);
266
0
  };
267
0
  inline bool is_log_to_file_enabled() { return (log_to_file); };
268
0
  inline void disable_dns_responses_decoding() { sniff_dns_responses = false; };
269
0
  inline void disable_localhost_name_decoding() {
270
0
    sniff_local_name_responses = false;
271
0
  };
272
0
  inline void disable_all_name_decoding() { sniff_name_responses = false; };
273
380
  inline bool is_dns_decoding_enabled() /* DNS only */ {
274
380
    return (sniff_dns_responses);
275
380
  };
276
0
  inline bool is_name_decoding_enabled() /* Any */ {
277
0
    return (sniff_name_responses);
278
0
  };
279
0
  inline bool is_localhost_name_decoding_enabled() {
280
0
    return (sniff_local_name_responses);
281
0
  };
282
0
  inline void enable_categorization() { categorization_enabled = true; };
283
0
  inline bool is_categorization_enabled() { return (categorization_enabled); };
284
0
  inline bool do_change_user() { return (change_user); };
285
0
  inline void dont_change_user() { change_user = false; };
286
0
  inline bool is_sql_log_enabled() { return (enable_sql_log); };
287
0
  inline bool is_access_log_enabled() { return (enable_access_log); };
288
0
  inline void do_enable_access_log(bool state = true) {
289
0
    enable_access_log = state;
290
0
  };
291
0
  inline bool is_assets_log_enabled() { return (enable_assets_log); };
292
0
  inline void do_enable_assets_log(bool state = true) {
293
0
    enable_assets_log = state;
294
0
  };
295
0
  inline bool are_ixia_timestamps_enabled() {
296
0
    return (enable_ixia_timestamps);
297
0
  };
298
0
  inline char* get_user() { return (user); };
299
0
  inline void set_user(const char* u) {
300
0
    if (user) free(user);
301
0
    user = strdup(u);
302
0
    user_set = true;
303
0
  };
304
0
  inline bool is_user_set() { return user_set; };
305
0
  inline u_int32_t get_num_simulated_ips() const {
306
0
    return (num_simulated_ips);
307
0
  };
308
0
  inline u_int8_t get_num_user_specified_interfaces() {
309
0
    return (num_interfaces);
310
0
  };
311
5.83k
  inline bool do_dump_flows_on_es() { return (dump_flows_on_es); };
312
5.83k
  inline bool do_dump_flows_on_mysql() { return (dump_flows_on_mysql); };
313
5.83k
  inline bool do_dump_flows_on_clickhouse() {
314
5.83k
    return ((is_enterprise_m_edition() || is_nedge_enterprise_edition()) && dump_flows_on_clickhouse);
315
5.83k
  };
316
0
  inline bool do_dump_alerts_on_clickhouse() {
317
0
    return (do_dump_flows_on_clickhouse());
318
0
  };
319
5.83k
  inline bool do_dump_flows_on_syslog() { return (dump_flows_on_syslog); };
320
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
321
  inline bool do_dump_flows_on_kafka() {
322
    return ((kafka_brokers_list && kafka_topic) ? true : false);
323
  };
324
#endif
325
0
  inline bool do_dump_extended_json() { return (dump_ext_json); };
326
0
  inline bool do_dump_json_flows_on_disk() {
327
0
    return (dump_json_flows_on_disk);
328
0
  };
329
5.83k
  inline bool do_dump_flows() {
330
5.83k
    return (do_dump_flows_on_es() || do_dump_flows_on_mysql() ||
331
5.83k
            do_dump_flows_on_clickhouse() || do_dump_flows_on_syslog()
332
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
333
            || do_dump_flows_on_kafka()
334
#endif
335
5.83k
    );
336
5.83k
  };
337
338
#ifdef NTOPNG_PRO
339
  inline void toggle_dump_flows_direct(bool enable) {
340
    dump_flows_direct = enable;
341
  };
342
  inline bool do_dump_flows_direct() { return (dump_flows_direct); };
343
#endif
344
0
  inline bool is_runtime_flows_dump_enabled() const {
345
0
    return (enable_runtime_flows_dump);
346
0
  };
347
5.83k
  inline bool is_flows_dump_enabled() {
348
5.83k
    return (do_dump_flows() && is_runtime_flows_dump_enabled());
349
5.83k
  };
350
  int32_t getDefaultPrefsValue(const char* pref_key, int32_t default_value);
351
  void getDefaultStringPrefsValue(const char* pref_key, char** buffer,
352
                                  const char* default_value);
353
  char* get_if_name(int id);
354
  char* get_if_alias(int id);
355
  char* get_if_descr(int id);
356
0
  inline const char* get_config_file_path() { return (config_file_path); };
357
0
  inline const char* get_ndpi_proto_file_path() { return (ndpi_proto_path); };
358
0
  void set_data_dir(char* path) { data_dir = path; }
359
2
  inline char* get_data_dir() { return (data_dir); };
360
6
  inline char* get_docs_dir() { return (docs_dir); };  // HTTP docs
361
0
  inline const char* get_scripts_dir() { return (scripts_dir); };
362
2
  inline const char* get_callbacks_dir() { return (callbacks_dir); };
363
0
  void set_callback_dir(char* path) { callbacks_dir = path; };
364
0
  inline const char* get_pcap_dir() { return (pcap_dir); };
365
#ifdef NTOPNG_PRO
366
  inline const char* get_pro_callbacks_dir() { return (pro_callbacks_dir); };
367
#endif
368
0
  inline const char* get_test_pre_script_path() {
369
0
    return (test_pre_script_path);
370
0
  };
371
0
  inline const char* get_test_runtime_script_path() {
372
0
    return (test_runtime_script_path);
373
0
  };
374
0
  inline const char* get_test_post_script_path() {
375
0
    return (test_post_script_path);
376
0
  };
377
0
  inline const char* get_message_broker_url() {
378
0
    return(message_broker_url);
379
0
  };
380
0
  inline const char* get_message_broker() {
381
0
    return(message_broker);
382
0
  };
383
0
  inline bool is_message_broker_enabled() {
384
0
    return(message_broker_enabled);
385
0
  };
386
0
  inline char* get_export_endpoint() { return (export_endpoint); };
387
0
  inline char* get_export_zmq_encryption_key() {
388
0
    return (export_zmq_encryption_key);
389
0
  };
390
0
  inline char* get_categorization_key() { return (categorization_key); };
391
0
  inline char* get_http_prefix() { return (http_prefix); };
392
0
  inline char* get_instance_name() { return (instance_name); };
393
394
0
  inline bool do_auto_logout() { return (enable_auto_logout); };
395
0
  inline bool do_auto_logout_at_runtime() {
396
0
    return (enable_auto_logout_at_runtime);
397
0
  };
398
0
  inline bool interface_name_only() { return (enable_interface_name_only); };
399
6.04k
  inline bool do_ignore_vlans() { return (ignore_vlans); };
400
101k
  inline bool do_ignore_macs() { return (ignore_macs); };
401
87.2k
  inline bool do_simulate_vlans() { return (simulate_vlans); };
402
77.8k
  inline bool do_simulate_macs() { return (simulate_macs); };
403
0
  inline bool do_insecure_tls() { return (insecure_tls); };
404
0
  inline bool do_snmp_polling() { return (snmp_polling); };
405
  bool do_active_monitoring();
406
0
  inline bool get_active_monitoring_pref() { return (active_monitoring); };
407
0
  inline bool do_tls_quic_hostnaming() { return (tls_quic_hostnaming); };
408
0
  inline bool email_starttls_enabled()          { return (starttls); };
409
0
  inline bool dump_pcap_to_clickhouse_enabled() { return (dump_pcap_to_clickhouse); };
410
0
  inline char* get_cpu_affinity() { return (cpu_affinity); };
411
0
  inline char* get_other_cpu_affinity() { return (other_cpu_affinity); };
412
#ifdef __linux__
413
0
  inline cpu_set_t* get_other_cpu_affinity_mask() {
414
0
    return (&other_cpu_affinity_mask);
415
0
  };
416
#endif
417
0
  inline u_int get_http_port() { return (http_port); };
418
0
  inline u_int get_https_port() { return (https_port); };
419
0
  inline bool is_client_x509_auth_enabled() {
420
0
    return (enable_client_x509_auth);
421
0
  };
422
4
  inline char* get_redis_host() { return (redis_host); }
423
4
  inline char* get_redis_password() { return (redis_password); }
424
4
  inline u_int get_redis_port() { return (redis_port); };
425
4
  inline u_int get_redis_db_id() { return (redis_db_id); };
426
0
  inline char* get_pid_path() { return (pid_path); };
427
0
  inline char* get_packet_filter() { return (packet_filter); };
428
429
6
  inline u_int32_t get_max_num_hosts() { return (max_num_hosts); };
430
6
  inline u_int32_t get_max_num_flows() { return (max_num_flows); };
431
432
0
  inline bool daemonize_ntopng() { return (daemonize); };
433
434
0
  inline u_int32_t get_attacker_max_num_flows_per_sec() {
435
0
    return (attacker_max_num_flows_per_sec);
436
0
  };
437
0
  inline u_int32_t get_victim_max_num_flows_per_sec() {
438
0
    return (victim_max_num_flows_per_sec);
439
0
  };
440
0
  inline u_int32_t get_attacker_max_num_syn_per_sec() {
441
0
    return (attacker_max_num_syn_per_sec);
442
0
  };
443
0
  inline u_int32_t get_victim_max_num_syn_per_sec() {
444
0
    return (victim_max_num_syn_per_sec);
445
0
  };
446
193
  inline u_int8_t get_ewma_alpha_percent() { return (ewma_alpha_percent); };
447
448
  void add_default_interfaces();
449
  int loadFromCLI(int argc, char* argv[]);
450
  int loadFromFile(const char* path);
451
  void add_network_interface(char* name, char* description);
452
0
  inline bool json_labels_as_strings() { return (json_labels_string_format); };
453
0
  inline void set_json_symbolic_labels_format(bool as_string) {
454
0
    json_labels_string_format = as_string;
455
0
  };
456
  void set_routing_mode(bool enabled);
457
  virtual void lua(lua_State* vm);
458
  void reloadPrefsFromRedis();
459
  void loadInstanceNameDefaults();
460
  void resetDeferredInterfacesToRegister();
461
  bool addDeferredInterfaceToRegister(const char* ifname);
462
  void registerNetworkInterfaces();
463
  void refreshHostsAlertsPrefs();
464
  void refreshDeviceProtocolsPolicyPref();
465
  /* Runtime database dump prefs. Allows the user to toggle flows dump from the
466
   * UI at runtime. */
467
  void refreshDbDumpPrefs();
468
469
  void bind_http_to_address(const char* addr1, const char* addr2);
470
  void bind_https_to_address(const char* addr1, const char* addr2);
471
0
  void bind_http_to_loopback() {
472
0
    bind_http_to_address((char*)CONST_LOOPBACK_ADDRESS,
473
0
                         (char*)CONST_LOOPBACK_ADDRESS);
474
0
  };
475
0
  inline void bind_https_to_loopback() {
476
0
    bind_https_to_address((char*)CONST_LOOPBACK_ADDRESS,
477
0
                          (char*)CONST_LOOPBACK_ADDRESS);
478
0
  };
479
  inline void get_http_binding_addresses(const char** addr1,
480
0
                                         const char** addr2) {
481
0
    *addr1 = http_binding_address1;
482
0
    *addr2 = http_binding_address2;
483
0
  };
484
  inline void get_https_binding_addresses(const char** addr1,
485
0
                                          const char** addr2) {
486
0
    *addr1 = https_binding_address1;
487
0
    *addr2 = https_binding_address2;
488
0
  };
489
490
0
  inline bool checkServiceLicense() { return (service_license_check); };
491
0
  inline void disableServiceLicense() { service_license_check = false; };
492
0
  inline char* get_es_type() { return (es_type); };
493
0
  inline char* get_es_index() { return (es_index); };
494
0
  inline char* get_es_url() { return (es_url); };
495
0
  inline char* get_es_user() { return (es_user); };
496
0
  inline char* get_es_pwd() { return (es_pwd); };
497
0
  const inline char* get_es_host() { return (es_host); };
498
0
  inline bool shutdownWhenDone() { return (shutdown_when_done); }
499
0
  inline void set_promiscuous_mode(bool mode) { use_promiscuous_mode = mode; };
500
0
  inline bool use_promiscuous() { return (use_promiscuous_mode); };
501
0
  inline char* get_mysql_host() { return (mysql_host); };
502
0
  inline int get_mysql_port() { return (mysql_port); };
503
0
  inline int get_clickhouse_tcp_port() { return (clickhouse_tcp_port); };
504
0
  inline bool is_mysql_port_secure() { return (mysql_port_secure); };
505
0
  inline bool is_clickhouse_tcp_port_secure() { return (clickhouse_tcp_port_secure); };
506
0
  inline char* get_mysql_dbname() { return (mysql_dbname); };
507
0
  inline char* get_mysql_tablename() { return ((char*)"flows"); };
508
0
  inline char* get_mysql_user() { return (mysql_user); };
509
#if defined(HAVE_CLICKHOUSE) && defined(NTOPNG_PRO) && defined(HAVE_MYSQL)
510
  /* If this is not NULL, it means that the user is using CH Cloud */
511
  inline char* get_ch_user() { return (ch_user); };
512
#endif
513
0
  inline char* get_mysql_pw() { return (mysql_pw); };
514
#if !defined(WIN32) && !defined(__APPLE__)
515
0
  inline int get_flows_syslog_facility() { return (flows_syslog_facility); };
516
#endif
517
0
  inline char* get_ls_host() { return (ls_host); };
518
0
  inline char* get_ls_port() { return (ls_port); };
519
0
  inline char* get_ls_proto() { return (ls_proto); };
520
0
  inline char* get_zmq_encryption_pwd() { return (zmq_encryption_pwd); };
521
0
  inline char* get_zmq_encryption_priv_key() {
522
0
    return (zmq_encryption_priv_key);
523
0
  };
524
0
  inline bool is_zmq_encryption_enabled() { return (enable_zmq_encryption); };
525
0
  inline char* get_command_line() { return (cli ? cli : (char*)""); };
526
527
0
  inline void add_lan_interface(char* iface) { lan_interfaces.insert(iface); };
528
0
  inline void add_wan_interface(char* iface) { wan_interfaces.insert(iface); };
529
530
0
  inline bool is_lan_interface(char* iface) {
531
0
    return lan_interfaces.find(iface) != lan_interfaces.end();
532
0
  }
533
0
  inline bool is_wan_interface(char* iface) {
534
0
    return wan_interfaces.find(iface) != wan_interfaces.end();
535
0
  }
536
537
0
  inline int get_num_lan_interfaces() { return lan_interfaces.size(); }
538
0
  inline int get_num_wan_interfaces() { return wan_interfaces.size(); }
539
540
0
  inline InterfacesSet* get_lan_interfaces() { return &lan_interfaces; }
541
0
  inline InterfacesSet* get_wan_interfaces() { return &wan_interfaces; }
542
543
44.9k
  inline bool areMacNdpiStatsEnabled() { return (enable_mac_ndpi_stats); };
544
0
  inline pcap_direction_t getCaptureDirection() { return (captureDirection); };
545
0
  inline void setCaptureDirection(pcap_direction_t dir) {
546
0
    captureDirection = dir;
547
0
  };
548
#ifdef HAVE_PF_RING
549
  inline bool hasPF_RINGClusterID() { return pfring_cluster_id >= 0; };
550
  inline int getPF_RINGClusterID() { return pfring_cluster_id; };
551
#endif
552
0
  inline bool hasCmdlTraceLevel() { return has_cmdl_trace_lvl; };
553
0
  inline u_int32_t get_auth_session_duration() {
554
0
    return (auth_session_duration);
555
0
  };
556
0
  inline bool get_auth_session_midnight_expiration() {
557
0
    return (auth_session_midnight_expiration);
558
0
  };
559
408k
  inline u_int32_t get_housekeeping_frequency() {
560
408k
    return (housekeeping_frequency);
561
408k
  };
562
38.7k
  inline u_int32_t get_host_max_idle(bool localHost) const {
563
38.7k
    return (localHost ? local_host_max_idle : non_local_host_max_idle);
564
38.7k
  };
565
  /* Maximum idleness for hosts with alerts engaged, that is, with ongoing
566
   * issues. */
567
0
  inline u_int32_t get_alerted_host_max_idle() const {
568
0
    return (local_host_max_idle); /* Treat all hosts as local */
569
0
  };
570
0
  inline u_int32_t get_local_host_cache_duration() {
571
0
    return (local_host_cache_duration);
572
0
  };
573
5.83k
  inline u_int32_t get_pkt_ifaces_flow_max_idle() {
574
5.83k
    return (pkt_ifaces_flow_max_idle);
575
5.83k
  };
576
0
  inline char *getHttpIndexPage() {
577
0
    return http_index_page;
578
0
  };
579
7.50k
  inline bool are_top_talkers_enabled()            { return (enable_top_talkers);      };
580
19.2k
  inline bool are_sites_collection_enabled()       { return (enable_sites_collection); };
581
45.5k
  inline bool is_dns_cache_enabled()               { return (enable_dns_cache);        };
582
0
  inline bool flow_table_duration_or_last_seen()   { return (flow_table_time);         };
583
0
  inline bool is_active_local_host_cache_enabled() {
584
0
    return (enable_active_local_hosts_cache);
585
0
  };
586
587
0
  inline bool is_tiny_flows_export_enabled() {
588
0
    return (enable_tiny_flows_export);
589
0
  };
590
0
  inline bool is_flow_device_port_rrd_creation_enabled() {
591
0
    return (enable_flow_device_port_rrd_creation);
592
0
  };
593
0
  inline bool is_observation_points_rrd_creation_enabled() {
594
0
    return (enable_observation_points_rrd_creation);
595
0
  };
596
0
  inline char* get_http_log_path() { return(http_log_path); };
597
0
  inline bool is_intranet_traffic_rrd_creation_enabled() {
598
0
    return (enable_intranet_traffic_rrd_creation);
599
0
  };
600
0
  inline bool is_arp_matrix_generation_enabled() {
601
0
    return (enable_arp_matrix_generation);
602
0
  };
603
604
0
  inline bool do_override_dst_with_post_nat_dst() const {
605
0
    return (override_dst_with_post_nat_dst);
606
0
  };
607
0
  inline bool do_override_src_with_post_nat_src() const {
608
0
    return (override_src_with_post_nat_src);
609
0
  };
610
0
  inline bool are_device_protocol_policies_enabled() const {
611
0
    return (device_protocol_policies_enabled);
612
0
  };
613
614
0
  inline bool isVLANTrunkModeEnabled() const {
615
0
    return (enable_vlan_trunk_bridge);
616
0
  }
617
0
  inline bool isCaptivePortalEnabled() const {
618
0
    return (enable_captive_portal && !enable_vlan_trunk_bridge);
619
0
  }
620
621
0
  inline bool enableActivitiesDebug() const {
622
0
    return (enable_activities_debug);
623
0
  }
624
625
#ifdef HAVE_NEDGE
626
  bool isInformativeCaptivePortalEnabled() const;
627
  bool isExternalAuthCaptivePortalEnabled() const;
628
  const char* getCaptivePortalUrl();
629
630
  inline bool isMacBasedCaptivePortal() const {
631
    return (mac_based_captive_portal);
632
  }
633
#endif
634
0
  const TsDriver getTimeseriesDriver() const { return (timeseries_driver); }
635
636
0
  inline u_int8_t getDefaultl7Policy() { return (default_l7policy); }
637
638
0
  inline u_int32_t get_dump_frequency() const { return (dump_frequency); };
639
0
  inline u_int32_t get_max_num_packets_per_tiny_flow() const {
640
0
    return (max_num_packets_per_tiny_flow);
641
0
  };
642
0
  inline u_int32_t get_max_num_bytes_per_tiny_flow() const {
643
0
    return (max_num_bytes_per_tiny_flow);
644
0
  };
645
646
0
  inline u_int64_t get_max_extracted_pcap_bytes() {
647
0
    return max_extracted_pcap_bytes;
648
0
  };
649
650
0
  inline u_int32_t get_safe_search_dns_ip() { return (safe_search_dns_ip); };
651
0
  inline u_int32_t get_global_primary_dns_ip() {
652
0
    return (global_primary_dns_ip);
653
0
  };
654
0
  inline u_int32_t get_global_secondary_dns_ip() {
655
0
    return (global_secondary_dns_ip);
656
0
  };
657
0
  inline bool isGlobalDNSDefined() {
658
0
    return (global_primary_dns_ip ? true : false);
659
0
  };
660
36.2k
  inline HostMask getHostMask() { return (hostMask); };
661
0
  inline u_int16_t get_auto_assigned_pool_id() {
662
0
    return (auto_assigned_pool_id);
663
0
  };
664
0
  inline u_int16_t is_routing_mode() { return (routing_mode_enabled); };
665
#ifndef HAVE_NEDGE
666
0
  inline bool is_appliance() { return (appliance); };
667
#endif
668
0
  inline bool isGlobalDnsForgingEnabled() {
669
0
    return (global_dns_forging_enabled);
670
0
  };
671
0
  inline bool reproduceOriginalSpeed() {
672
0
    return (reproduce_at_original_speed);
673
0
  };
674
0
  inline void doReproduceOriginalSpeed() {
675
0
    reproduce_at_original_speed = true;
676
0
  };
677
0
  inline bool purgeHostsFlowsOnPcapFiles() {
678
0
    return (pcap_file_purge_hosts_flows);
679
0
  };
680
68.6k
  inline bool disablePurge() { return (disable_purge);  };
681
0
  inline void enableBehaviourAnalysis() { enable_behaviour_analysis = true; };
682
0
  inline bool isBehavourAnalysisEnabled() {
683
0
    return (enable_behaviour_analysis);
684
0
  };
685
0
  inline u_int32_t behaviourAnalysisLearningPeriod() {
686
0
    return behaviour_analysis_learning_period;
687
0
  };
688
689
743
  inline bool isBroadcastDomainTooLargeEnabled() {
690
743
    return (enable_broadcast_domain_too_large);
691
743
  };
692
693
0
  inline bool isASNBehavourAnalysisEnabled() {
694
0
    return (enable_asn_behaviour_analysis);
695
0
  };
696
0
  inline bool isNetworkBehavourAnalysisEnabled() {
697
0
    return (enable_network_behaviour_analysis);
698
0
  };
699
2
  inline bool isIfaceL7BehavourAnalysisEnabled() {
700
2
    return (enable_iface_l7_behaviour_analysis);
701
2
  };
702
703
0
  inline ServiceAcceptance behaviourAnalysisStatusDuringLearning() {
704
0
    return behaviour_analysis_learning_status_during_learning;
705
0
  };
706
0
  inline ServiceAcceptance behaviourAnalysisStatusPostLearning() {
707
0
    return behaviour_analysis_learning_status_post_learning;
708
0
  };
709
3.92k
  inline u_int64_t* getIEC104AllowedTypeIDs() { return (iec104_allowed_typeids);   };
710
3.86k
  inline u_int32_t getIEC60870LearingPeriod() { return (iec60870_learning_period); };
711
0
  inline u_int32_t getModbusLearingPeriod()   { return (modbus_learning_period); };
712
#ifdef NTOPNG_PRO
713
  inline bool isNetBoxEnabled() { return netbox_enabled; };
714
  inline bool isAssetInventoryEnabled() { return asset_inventory_enabled; };
715
  inline bool isSNMPTrapEnabled() { return snmp_trap_enabled; };
716
  inline ndpi_bitmap* getModbusAllowedFunctionCodes() { return (modbus_allowed_function_codes);  };
717
  inline void         setModbusTooManyExceptionsThreshold(u_int v) { modbus_too_many_exceptions = v;     }
718
  inline u_int        getModbusTooManyExceptionsThreshold()        { return(modbus_too_many_exceptions); }
719
#endif
720
0
  inline u_int32_t devicesLearingPeriod() { return (devices_learning_period); };
721
3.96k
  inline u_int32_t macAddressCacheDuration() { return (mac_address_cache_duration); };
722
0
  inline bool isAssetsCollectionEnabled() { return (enable_assets_collection); };
723
0
  inline u_int32_t hostPortLearningPeriod() { return (host_port_learning_period); };
724
0
  inline bool are_alerts_disabled() { return (disable_alerts); };
725
0
  inline bool dontEmitFlowAlerts() {
726
0
    return (disable_alerts || !emit_flow_alerts);
727
0
  };
728
0
  inline bool dontEmitHostAlerts() {
729
0
    return (disable_alerts || !emit_host_alerts);
730
0
  };
731
0
  inline void dontUseClickHouse() {
732
0
    dump_flows_on_clickhouse = dump_flows_on_mysql = false;
733
0
  };
734
0
  inline char* getZMQPublishEventsURL() { return (zmq_publish_events_url); };
735
0
  inline const char* getClickHouseClientPath() { return (clickhouse_client); };
736
0
  inline const char* getClickHouseClusterName() {
737
0
    return (clickhouse_cluster_name);
738
0
  };
739
#ifdef NTOPNG_PRO
740
  void setModbusAllowedFunctionCodes(const char *function_codes);
741
#endif
742
  void setIEC104AllowedTypeIDs(const char* type_ids);
743
  void validate();
744
#if defined(HAVE_KAFKA) && defined(NTOPNG_PRO)
745
  char* getKakfaBrokersList() { return (kafka_brokers_list); }
746
  char* getKafkaTopic() { return (kafka_topic); }
747
  char* getKafkaOptions() { return (kafka_options); }
748
#endif
749
  void reloadServersConfiguration();
750
#ifdef NTOPNG_PRO
751
  bool reloadNetworksPolicyConfiguration();
752
  bool loadPolicyConfiguration(AddressTree *tree, char *key, NetworkConfigurationId id);
753
  AddressTree* getNetworksPolicyConfiguration();
754
#endif
755
  bool isGateway(IpAddress *ip, u_int16_t vlan_id);
756
  bool isDNSServer(IpAddress *ip, u_int16_t vlan_id);
757
  bool isNTPServer(IpAddress *ip, u_int16_t vlan_id);
758
  bool isSMTPServer(IpAddress *ip, u_int16_t vlan_id);
759
  bool isDHCPServer(IpAddress *ip, u_int16_t vlan_id);
760
761
0
  ServerConfiguration* getConfiguredGateways()    { return(gateway);      }
762
0
  ServerConfiguration* getConfiguredDNSServers()  { return(dns_servers);  }
763
0
  ServerConfiguration* getConfiguredNTPServers()  { return(ntp_servers);  }
764
0
  ServerConfiguration* getConfiguredSMTPServers() { return(smtp_servers); }
765
0
  ServerConfiguration* getConfiguredDHCPServers() { return(dhcp_servers); }
766
767
73.0k
  inline bool useMacAddressInFlowKey()     { return (use_mac_in_flow_key);  }
768
10.9k
  inline bool areFingerprintStatsEnabled() { return (fingerprint_stats);    }
769
0
  inline bool doReforgeTimestamps()        { return(do_reforge_timestamps); }
770
0
  inline void enableVLANCloudToExporters() { add_vlan_tags_to_cloud_exporters = true;  }
771
0
  inline bool addVLANCloudToExporters()    { return(add_vlan_tags_to_cloud_exporters); }
772
0
  inline bool collectBlackListStats()      { return(collect_blacklist_stats);          }
773
94.6k
  inline bool limitResourcesUsage()        { return(limited_resources_mode);           }
774
0
  inline bool failOnInvalidLicense()       { return(fail_on_invalid_license);          }
775
0
  inline char* getCiphersList()            { return(ciphers_list);                     }
776
#ifdef NTOPNG_PRO
777
  inline char* getLicMgrConfigFile()       { return(lic_mgr_config_file);              }
778
  inline AddressTree* getNwPolicyConfig()  { return(networks_policy_configuration);    }
779
#endif
780
2
  inline char* getCustomGeoIPDir()         { return(custom_geoip_dir);                 }
781
  void setCustomGeoIPDir(char *d);
782
};
783
784
#endif /* _PREFS_H_ */