// SPDX-License-Identifier: GPL-3.0-or-later#include"aclk.h"#ifdef ENABLE_ACLK#include"aclk_stats.h"#include"mqtt_wss_client.h"#include"aclk_otp.h"#include"aclk_tx_msgs.h"#include"aclk_query.h"#include"aclk_query_queue.h"#include"aclk_util.h"#include"aclk_rx_msgs.h"#include"https_client.h"#include"schema-wrappers/schema_wrappers.h"#include"aclk_capas.h"#include"aclk_proxy.h"#ifdef ACLK_LOG_CONVERSATION_DIR#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#endif#define ACLK_STABLE_TIMEOUT 3 // Minimum delay to mark AGENT as stable#endif /* ENABLE_ACLK */intaclk_pubacks_per_conn=0;// How many PubAcks we got since MQTT conn est.intaclk_rcvd_cloud_msgs=0;intaclk_connection_counter=0;intdisconnect_req=0;intaclk_connected=0;intaclk_ctx_based=0;intaclk_disable_runtime=0;intaclk_stats_enabled;intaclk_kill_link=0;usec_taclk_session_us=0;time_taclk_session_sec=0;time_tlast_conn_time_mqtt=0;time_tlast_conn_time_appl=0;time_tlast_disconnect_time=0;time_tnext_connection_attempt=0;floatlast_backoff_value=0;time_taclk_block_until=0;#ifdef ENABLE_ACLKmqtt_wss_clientmqttwss_client;netdata_mutex_taclk_shared_state_mutex=NETDATA_MUTEX_INITIALIZER;#define ACLK_SHARED_STATE_LOCK netdata_mutex_lock(&aclk_shared_state_mutex)#define ACLK_SHARED_STATE_UNLOCK netdata_mutex_unlock(&aclk_shared_state_mutex)structaclk_shared_stateaclk_shared_state={.mqtt_shutdown_msg_id=-1,.mqtt_shutdown_msg_rcvd=0};#ifdef MQTT_WSS_DEBUG#include<openssl/ssl.h>#define DEFAULT_SSKEYLOGFILE_NAME "SSLKEYLOGFILE"constchar*ssl_log_filename=NULL;FILE*ssl_log_file=NULL;staticvoidaclk_ssl_keylog_cb(constSSL