2016-05-05 18:51:49 -04:00
|
|
|
/*
|
|
|
|
* connection.c
|
2019-11-13 06:11:05 -05:00
|
|
|
* vim: expandtab:ts=4:sts=4:sw=4
|
2016-05-05 18:51:49 -04:00
|
|
|
*
|
2019-01-22 05:31:45 -05:00
|
|
|
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
|
2019-10-16 04:54:05 -04:00
|
|
|
* Copyright (C) 2018 - 2019 Michael Vetter <jubalh@idoru.org>
|
2016-05-05 18:51:49 -04:00
|
|
|
*
|
|
|
|
* This file is part of Profanity.
|
|
|
|
*
|
|
|
|
* Profanity is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Profanity is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-07-23 20:14:49 -04:00
|
|
|
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
|
2016-05-05 18:51:49 -04:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link the code of portions of this program with the OpenSSL library under
|
|
|
|
* certain conditions as described in each individual source file, and
|
|
|
|
* distribute linked combinations including the two.
|
|
|
|
*
|
|
|
|
* You must obey the GNU General Public License in all respects for all of the
|
|
|
|
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
|
|
* may extend this exception to your version of the file(s), but you are not
|
|
|
|
* obligated to do so. If you do not wish to do so, delete this exception
|
|
|
|
* statement from your version. If you delete this exception statement from all
|
|
|
|
* source files in the program, then also delete it here.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2020-07-07 07:53:30 -04:00
|
|
|
#include <assert.h>
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2019-10-16 04:17:34 -04:00
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
#ifdef HAVE_LIBMESODE
|
|
|
|
#include <mesode.h>
|
|
|
|
#endif
|
2016-07-24 10:43:51 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
#ifdef HAVE_LIBSTROPHE
|
|
|
|
#include <strophe.h>
|
|
|
|
#endif
|
|
|
|
|
2019-10-16 04:43:56 -04:00
|
|
|
#include "common.h"
|
2020-07-07 07:53:30 -04:00
|
|
|
#include "log.h"
|
2019-10-16 04:17:34 -04:00
|
|
|
#include "config/files.h"
|
2016-05-05 21:02:23 -04:00
|
|
|
#include "config/preferences.h"
|
2016-05-05 18:51:49 -04:00
|
|
|
#include "event/server_events.h"
|
|
|
|
#include "xmpp/connection.h"
|
2020-07-07 03:43:28 -04:00
|
|
|
#include "xmpp/session.h"
|
2020-07-07 07:53:30 -04:00
|
|
|
#include "xmpp/iq.h"
|
|
|
|
#include "ui/ui.h"
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
typedef struct prof_conn_t
|
|
|
|
{
|
|
|
|
xmpp_log_t* xmpp_log;
|
|
|
|
xmpp_ctx_t* xmpp_ctx;
|
|
|
|
xmpp_conn_t* xmpp_conn;
|
2019-06-01 13:21:46 -04:00
|
|
|
gboolean xmpp_in_event_loop;
|
2016-05-05 18:51:49 -04:00
|
|
|
jabber_conn_status_t conn_status;
|
2019-06-01 13:21:46 -04:00
|
|
|
xmpp_conn_event_t conn_last_event;
|
2020-07-07 08:18:57 -04:00
|
|
|
char* presence_message;
|
2016-05-05 18:51:49 -04:00
|
|
|
int priority;
|
2020-07-07 08:18:57 -04:00
|
|
|
char* domain;
|
|
|
|
GHashTable* available_resources;
|
|
|
|
GHashTable* features_by_jid;
|
|
|
|
GHashTable* requested_features;
|
2016-05-05 18:51:49 -04:00
|
|
|
} ProfConnection;
|
|
|
|
|
|
|
|
static ProfConnection conn;
|
2020-07-07 08:18:57 -04:00
|
|
|
static gchar* profanity_instance_id = NULL;
|
|
|
|
static gchar* prof_identifier = NULL;
|
2016-05-05 18:51:49 -04:00
|
|
|
|
|
|
|
static xmpp_log_t* _xmpp_get_file_logger(void);
|
2020-07-07 08:18:57 -04:00
|
|
|
static void _xmpp_file_logger(void* const userdata, const xmpp_log_level_t level, const char* const area, const char* const msg);
|
2016-05-10 16:59:41 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
static void _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error,
|
|
|
|
xmpp_stream_error_t* const stream_error, void* const userdata);
|
2016-05-10 17:09:09 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
#ifdef HAVE_LIBMESODE
|
2020-07-07 08:18:57 -04:00
|
|
|
TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert);
|
|
|
|
static int _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg);
|
2016-05-05 18:51:49 -04:00
|
|
|
#endif
|
|
|
|
|
2019-10-16 09:53:28 -04:00
|
|
|
static void _random_bytes_init(void);
|
|
|
|
static void _random_bytes_close(void);
|
2020-07-07 08:18:57 -04:00
|
|
|
static void _compute_identifier(const char* barejid);
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2016-05-10 17:49:58 -04:00
|
|
|
void
|
|
|
|
connection_init(void)
|
2016-05-05 18:51:49 -04:00
|
|
|
{
|
2016-05-07 18:29:19 -04:00
|
|
|
xmpp_initialize();
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_conn = NULL;
|
|
|
|
conn.xmpp_ctx = NULL;
|
2019-06-01 13:21:46 -04:00
|
|
|
conn.xmpp_in_event_loop = FALSE;
|
2016-05-10 18:53:44 -04:00
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
2019-06-01 13:21:46 -04:00
|
|
|
conn.conn_last_event = XMPP_CONN_DISCONNECT;
|
2016-05-10 18:53:44 -04:00
|
|
|
conn.presence_message = NULL;
|
2016-05-05 18:51:49 -04:00
|
|
|
conn.domain = NULL;
|
2016-05-07 22:14:22 -04:00
|
|
|
conn.features_by_jid = NULL;
|
2016-05-07 18:04:50 -04:00
|
|
|
conn.available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy);
|
2019-04-08 13:09:25 -04:00
|
|
|
conn.requested_features = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
_random_bytes_init();
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
2016-07-24 09:08:30 -04:00
|
|
|
void
|
|
|
|
connection_check_events(void)
|
|
|
|
{
|
2019-06-01 13:21:46 -04:00
|
|
|
conn.xmpp_in_event_loop = TRUE;
|
2016-07-24 09:08:30 -04:00
|
|
|
xmpp_run_once(conn.xmpp_ctx, 10);
|
2019-06-01 13:21:46 -04:00
|
|
|
conn.xmpp_in_event_loop = FALSE;
|
2016-07-24 09:08:30 -04:00
|
|
|
}
|
|
|
|
|
2016-05-10 18:27:16 -04:00
|
|
|
void
|
|
|
|
connection_shutdown(void)
|
|
|
|
{
|
2016-05-10 18:53:44 -04:00
|
|
|
connection_clear_data();
|
2016-05-10 18:27:16 -04:00
|
|
|
xmpp_shutdown();
|
|
|
|
|
|
|
|
free(conn.xmpp_log);
|
|
|
|
conn.xmpp_log = NULL;
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
_random_bytes_close();
|
2016-05-10 18:27:16 -04:00
|
|
|
}
|
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
jabber_conn_status_t
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_connect(const char* const jid, const char* const passwd, const char* const altdomain, int port,
|
|
|
|
const char* const tls_policy, const char* const auth_policy)
|
2016-05-05 21:02:23 -04:00
|
|
|
{
|
2020-02-26 18:22:05 -05:00
|
|
|
long flags;
|
|
|
|
|
2016-11-21 19:39:52 -05:00
|
|
|
assert(jid != NULL);
|
2016-05-05 21:02:23 -04:00
|
|
|
assert(passwd != NULL);
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
Jid* jidp = jid_create(jid);
|
2016-11-21 19:39:52 -05:00
|
|
|
if (jidp == NULL) {
|
|
|
|
log_error("Malformed JID not able to connect: %s", jid);
|
2016-05-05 21:02:23 -04:00
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
|
|
|
return conn.conn_status;
|
|
|
|
}
|
2019-10-16 09:53:28 -04:00
|
|
|
|
2019-10-19 18:01:19 -04:00
|
|
|
_compute_identifier(jidp->barejid);
|
2016-11-21 19:39:52 -05:00
|
|
|
jid_destroy(jidp);
|
2016-05-05 21:02:23 -04:00
|
|
|
|
2016-11-21 19:39:52 -05:00
|
|
|
log_info("Connecting as %s", jid);
|
2016-05-05 21:02:23 -04:00
|
|
|
|
2016-05-05 21:31:55 -04:00
|
|
|
if (conn.xmpp_log) {
|
|
|
|
free(conn.xmpp_log);
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_log = _xmpp_get_file_logger();
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2016-05-05 21:31:55 -04:00
|
|
|
if (conn.xmpp_conn) {
|
|
|
|
xmpp_conn_release(conn.xmpp_conn);
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
2016-05-05 21:31:55 -04:00
|
|
|
if (conn.xmpp_ctx) {
|
|
|
|
xmpp_ctx_free(conn.xmpp_ctx);
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_ctx = xmpp_ctx_new(NULL, conn.xmpp_log);
|
|
|
|
if (conn.xmpp_ctx == NULL) {
|
2016-05-05 18:51:49 -04:00
|
|
|
log_warning("Failed to get libstrophe ctx during connect");
|
|
|
|
return JABBER_DISCONNECTED;
|
|
|
|
}
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_conn = xmpp_conn_new(conn.xmpp_ctx);
|
|
|
|
if (conn.xmpp_conn == NULL) {
|
2016-05-05 18:51:49 -04:00
|
|
|
log_warning("Failed to get libstrophe conn during connect");
|
|
|
|
return JABBER_DISCONNECTED;
|
|
|
|
}
|
2016-11-21 19:39:52 -05:00
|
|
|
xmpp_conn_set_jid(conn.xmpp_conn, jid);
|
2016-05-05 21:31:55 -04:00
|
|
|
xmpp_conn_set_pass(conn.xmpp_conn, passwd);
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2020-02-26 18:22:05 -05:00
|
|
|
flags = xmpp_conn_get_flags(conn.xmpp_conn);
|
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
if (!tls_policy || (g_strcmp0(tls_policy, "force") == 0)) {
|
2020-02-26 18:22:05 -05:00
|
|
|
flags |= XMPP_CONN_FLAG_MANDATORY_TLS;
|
2018-11-06 07:01:27 -05:00
|
|
|
} else if (g_strcmp0(tls_policy, "trust") == 0) {
|
2020-02-26 18:22:05 -05:00
|
|
|
flags |= XMPP_CONN_FLAG_MANDATORY_TLS;
|
|
|
|
flags |= XMPP_CONN_FLAG_TRUST_TLS;
|
2016-05-05 18:51:49 -04:00
|
|
|
} else if (g_strcmp0(tls_policy, "disable") == 0) {
|
2020-02-26 18:22:05 -05:00
|
|
|
flags |= XMPP_CONN_FLAG_DISABLE_TLS;
|
2017-06-24 14:33:30 -04:00
|
|
|
} else if (g_strcmp0(tls_policy, "legacy") == 0) {
|
2020-02-26 18:22:05 -05:00
|
|
|
flags |= XMPP_CONN_FLAG_LEGACY_SSL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auth_policy && (g_strcmp0(auth_policy, "legacy") == 0)) {
|
|
|
|
flags |= XMPP_CONN_FLAG_LEGACY_AUTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmpp_conn_set_flags(conn.xmpp_conn, flags);
|
|
|
|
|
|
|
|
/* Print debug logs that can help when users share the logs */
|
|
|
|
if (flags != 0) {
|
|
|
|
log_debug("Connecting with flags (0x%lx):", flags);
|
2020-07-07 08:18:57 -04:00
|
|
|
#define LOG_FLAG_IF_SET(name) \
|
|
|
|
if (flags & name) { \
|
|
|
|
log_debug(" " #name); \
|
|
|
|
}
|
2020-02-26 18:22:05 -05:00
|
|
|
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_MANDATORY_TLS);
|
|
|
|
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_TRUST_TLS);
|
|
|
|
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_DISABLE_TLS);
|
|
|
|
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_SSL);
|
|
|
|
LOG_FLAG_IF_SET(XMPP_CONN_FLAG_LEGACY_AUTH);
|
|
|
|
#undef LOG_FLAG_IF_SET
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBMESODE
|
2020-07-07 08:18:57 -04:00
|
|
|
char* cert_path = prefs_get_tls_certpath();
|
2016-05-05 18:51:49 -04:00
|
|
|
if (cert_path) {
|
2016-05-05 21:31:55 -04:00
|
|
|
xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path);
|
2016-10-17 18:48:03 -04:00
|
|
|
free(cert_path);
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int connect_status = xmpp_connect_client(
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_conn,
|
2016-05-05 18:51:49 -04:00
|
|
|
altdomain,
|
|
|
|
port,
|
|
|
|
_connection_certfail_cb,
|
|
|
|
_connection_handler,
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_ctx);
|
2016-05-05 18:51:49 -04:00
|
|
|
#else
|
|
|
|
int connect_status = xmpp_connect_client(
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_conn,
|
2016-05-05 18:51:49 -04:00
|
|
|
altdomain,
|
|
|
|
port,
|
|
|
|
_connection_handler,
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.xmpp_ctx);
|
2016-05-05 18:51:49 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (connect_status == 0) {
|
|
|
|
conn.conn_status = JABBER_CONNECTING;
|
|
|
|
} else {
|
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return conn.conn_status;
|
|
|
|
}
|
|
|
|
|
2016-05-10 18:18:11 -04:00
|
|
|
void
|
|
|
|
connection_disconnect(void)
|
|
|
|
{
|
2019-06-01 13:21:46 -04:00
|
|
|
// don't disconnect already disconnected connection,
|
|
|
|
// or we get infinite loop otherwise
|
|
|
|
if (conn.conn_last_event == XMPP_CONN_CONNECT) {
|
|
|
|
conn.conn_status = JABBER_DISCONNECTING;
|
|
|
|
xmpp_disconnect(conn.xmpp_conn);
|
|
|
|
|
|
|
|
while (conn.conn_status == JABBER_DISCONNECTING) {
|
|
|
|
session_process_events();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
2016-05-10 18:18:11 -04:00
|
|
|
}
|
2016-05-10 18:34:25 -04:00
|
|
|
|
2019-06-01 13:21:46 -04:00
|
|
|
// can't free libstrophe objects while we're in the event loop
|
|
|
|
if (!conn.xmpp_in_event_loop) {
|
|
|
|
if (conn.xmpp_conn) {
|
|
|
|
xmpp_conn_release(conn.xmpp_conn);
|
|
|
|
conn.xmpp_conn = NULL;
|
|
|
|
}
|
2016-05-10 18:34:25 -04:00
|
|
|
|
2019-06-01 13:21:46 -04:00
|
|
|
if (conn.xmpp_ctx) {
|
|
|
|
xmpp_ctx_free(conn.xmpp_ctx);
|
|
|
|
conn.xmpp_ctx = NULL;
|
|
|
|
}
|
2016-05-10 18:34:25 -04:00
|
|
|
}
|
2019-10-16 09:53:28 -04:00
|
|
|
|
|
|
|
free(prof_identifier);
|
2019-10-21 03:50:13 -04:00
|
|
|
prof_identifier = NULL;
|
2016-05-10 18:18:11 -04:00
|
|
|
}
|
|
|
|
|
2016-05-10 19:02:39 -04:00
|
|
|
void
|
|
|
|
connection_set_disconnected(void)
|
|
|
|
{
|
|
|
|
FREE_SET_NULL(conn.presence_message);
|
|
|
|
FREE_SET_NULL(conn.domain);
|
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
2016-05-10 18:53:44 -04:00
|
|
|
void
|
|
|
|
connection_clear_data(void)
|
|
|
|
{
|
2016-06-01 17:41:17 -04:00
|
|
|
if (conn.features_by_jid) {
|
|
|
|
g_hash_table_destroy(conn.features_by_jid);
|
|
|
|
conn.features_by_jid = NULL;
|
|
|
|
}
|
2016-05-10 18:53:44 -04:00
|
|
|
|
2016-06-01 17:41:17 -04:00
|
|
|
if (conn.available_resources) {
|
|
|
|
g_hash_table_remove_all(conn.available_resources);
|
|
|
|
}
|
2019-04-08 13:09:25 -04:00
|
|
|
|
|
|
|
if (conn.requested_features) {
|
|
|
|
g_hash_table_remove_all(conn.requested_features);
|
|
|
|
}
|
2016-05-10 18:53:44 -04:00
|
|
|
}
|
|
|
|
|
2016-05-10 16:59:41 -04:00
|
|
|
#ifdef HAVE_LIBMESODE
|
|
|
|
TLSCertificate*
|
|
|
|
connection_get_tls_peer_cert(void)
|
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
xmpp_tlscert_t* xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn);
|
|
|
|
TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert);
|
2016-05-10 16:59:41 -04:00
|
|
|
xmpp_conn_free_tlscert(conn.xmpp_ctx, xmpptlscert);
|
|
|
|
|
|
|
|
return cert;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
connection_is_secured(void)
|
|
|
|
{
|
|
|
|
if (conn.conn_status == JABBER_CONNECTED) {
|
|
|
|
return xmpp_conn_is_secured(conn.xmpp_conn) == 0 ? FALSE : TRUE;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_send_stanza(const char* const stanza)
|
2016-05-10 16:59:41 -04:00
|
|
|
{
|
|
|
|
if (conn.conn_status != JABBER_CONNECTED) {
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
xmpp_send_raw_string(conn.xmpp_conn, "%s", stanza);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_supports(const char* const feature)
|
2016-05-10 16:59:41 -04:00
|
|
|
{
|
2019-07-10 06:27:28 -04:00
|
|
|
gboolean ret = FALSE;
|
2020-07-07 08:18:57 -04:00
|
|
|
GList* jids = g_hash_table_get_keys(conn.features_by_jid);
|
2016-05-10 16:59:41 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
GList* curr = jids;
|
2016-05-10 16:59:41 -04:00
|
|
|
while (curr) {
|
2020-07-07 08:18:57 -04:00
|
|
|
char* jid = curr->data;
|
|
|
|
GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid);
|
2016-05-10 16:59:41 -04:00
|
|
|
if (features && g_hash_table_lookup(features, feature)) {
|
2019-07-10 06:27:28 -04:00
|
|
|
ret = TRUE;
|
|
|
|
break;
|
2016-05-10 16:59:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(jids);
|
|
|
|
|
2019-07-10 06:27:28 -04:00
|
|
|
return ret;
|
2016-05-10 16:59:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
char*
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_jid_for_feature(const char* const feature)
|
2016-05-10 16:59:41 -04:00
|
|
|
{
|
2016-11-19 21:09:34 -05:00
|
|
|
if (conn.features_by_jid == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
GList* jids = g_hash_table_get_keys(conn.features_by_jid);
|
2016-05-10 16:59:41 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
GList* curr = jids;
|
2016-05-10 16:59:41 -04:00
|
|
|
while (curr) {
|
2020-07-07 08:18:57 -04:00
|
|
|
char* jid = curr->data;
|
|
|
|
GHashTable* features = g_hash_table_lookup(conn.features_by_jid, jid);
|
2016-05-10 16:59:41 -04:00
|
|
|
if (features && g_hash_table_lookup(features, feature)) {
|
2016-09-05 18:19:22 -04:00
|
|
|
g_list_free(jids);
|
2016-05-10 16:59:41 -04:00
|
|
|
return jid;
|
|
|
|
}
|
|
|
|
|
|
|
|
curr = g_list_next(curr);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free(jids);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-04-08 13:09:25 -04:00
|
|
|
void
|
|
|
|
connection_request_features(void)
|
|
|
|
{
|
|
|
|
/* We don't record it as a requested feature to avoid triggering th
|
|
|
|
* sv_ev_connection_features_received too soon */
|
|
|
|
iq_disco_info_request_onconnect(conn.domain);
|
|
|
|
}
|
|
|
|
|
2016-05-10 16:59:41 -04:00
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_set_disco_items(GSList* items)
|
2016-05-10 16:59:41 -04:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
GSList* curr = items;
|
2016-05-10 16:59:41 -04:00
|
|
|
while (curr) {
|
2020-07-07 08:18:57 -04:00
|
|
|
DiscoItem* item = curr->data;
|
2019-04-08 13:09:25 -04:00
|
|
|
g_hash_table_insert(conn.requested_features, strdup(item->jid), NULL);
|
2016-05-10 16:59:41 -04:00
|
|
|
g_hash_table_insert(conn.features_by_jid, strdup(item->jid),
|
2020-07-07 08:18:57 -04:00
|
|
|
g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL));
|
2016-05-10 16:59:41 -04:00
|
|
|
|
|
|
|
iq_disco_info_request_onconnect(item->jid);
|
|
|
|
|
|
|
|
curr = g_slist_next(curr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
jabber_conn_status_t
|
|
|
|
connection_get_status(void)
|
|
|
|
{
|
|
|
|
return conn.conn_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmpp_conn_t*
|
|
|
|
connection_get_conn(void)
|
|
|
|
{
|
2016-05-05 21:31:55 -04:00
|
|
|
return conn.xmpp_conn;
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
xmpp_ctx_t*
|
|
|
|
connection_get_ctx(void)
|
|
|
|
{
|
2016-05-05 21:31:55 -04:00
|
|
|
return conn.xmpp_ctx;
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
2016-05-05 20:12:54 -04:00
|
|
|
const char*
|
|
|
|
connection_get_fulljid(void)
|
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
|
2016-11-21 19:39:52 -05:00
|
|
|
if (jid) {
|
|
|
|
return jid;
|
|
|
|
} else {
|
|
|
|
return xmpp_conn_get_jid(conn.xmpp_conn);
|
|
|
|
}
|
2016-05-05 20:12:54 -04:00
|
|
|
}
|
|
|
|
|
2020-05-25 07:04:19 -04:00
|
|
|
char*
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_get_barejid(void)
|
|
|
|
{
|
|
|
|
const char* jid = connection_get_fulljid();
|
|
|
|
char* result;
|
2020-05-25 07:04:19 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
Jid* jidp = jid_create(jid);
|
2020-05-25 07:04:19 -04:00
|
|
|
result = strdup(jidp->barejid);
|
|
|
|
jid_destroy(jidp);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:56:06 -05:00
|
|
|
char*
|
|
|
|
connection_get_user(void)
|
|
|
|
{
|
|
|
|
const char* jid = connection_get_fulljid();
|
|
|
|
char* result;
|
|
|
|
result = strdup(jid);
|
|
|
|
|
|
|
|
char* split = strchr(result, '@');
|
|
|
|
*split = '\0';
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-04-08 13:09:25 -04:00
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_features_received(const char* const jid)
|
2019-04-08 13:09:25 -04:00
|
|
|
{
|
2021-03-06 13:55:22 -05:00
|
|
|
log_info("[CONNECTION] connection_features_received %s", jid);
|
2019-04-08 13:09:25 -04:00
|
|
|
if (g_hash_table_remove(conn.requested_features, jid) && g_hash_table_size(conn.requested_features) == 0) {
|
|
|
|
sv_ev_connection_features_received();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-07 22:04:36 -04:00
|
|
|
GHashTable*
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_get_features(const char* const jid)
|
2016-05-07 21:25:34 -04:00
|
|
|
{
|
2016-05-07 22:04:36 -04:00
|
|
|
return g_hash_table_lookup(conn.features_by_jid, jid);
|
2016-05-07 21:25:34 -04:00
|
|
|
}
|
|
|
|
|
2016-05-07 18:04:50 -04:00
|
|
|
GList*
|
|
|
|
connection_get_available_resources(void)
|
|
|
|
{
|
|
|
|
return g_hash_table_get_values(conn.available_resources);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_add_available_resource(Resource* resource)
|
2016-05-07 18:04:50 -04:00
|
|
|
{
|
|
|
|
g_hash_table_replace(conn.available_resources, strdup(resource->name), resource);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_remove_available_resource(const char* const resource)
|
2016-05-07 18:04:50 -04:00
|
|
|
{
|
|
|
|
g_hash_table_remove(conn.available_resources, resource);
|
|
|
|
}
|
|
|
|
|
2016-05-05 20:16:13 -04:00
|
|
|
char*
|
|
|
|
connection_create_uuid(void)
|
|
|
|
{
|
2016-05-05 21:31:55 -04:00
|
|
|
return xmpp_uuid_gen(conn.xmpp_ctx);
|
2016-05-05 20:16:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_free_uuid(char* uuid)
|
2016-05-05 20:16:13 -04:00
|
|
|
{
|
|
|
|
if (uuid) {
|
2016-05-05 21:31:55 -04:00
|
|
|
xmpp_free(conn.xmpp_ctx, uuid);
|
2016-05-05 20:16:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-30 05:01:28 -04:00
|
|
|
char*
|
2019-10-17 09:40:40 -04:00
|
|
|
connection_create_stanza_id(void)
|
2018-08-30 05:01:28 -04:00
|
|
|
{
|
2021-04-14 16:47:58 -04:00
|
|
|
char* rndid = get_random_string(CON_RAND_ID_LEN);
|
2018-08-30 05:01:28 -04:00
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
assert(rndid != NULL);
|
2018-08-30 05:01:28 -04:00
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
gchar* hmac = g_compute_hmac_for_string(G_CHECKSUM_SHA1,
|
2020-07-07 08:18:57 -04:00
|
|
|
(guchar*)prof_identifier, strlen(prof_identifier),
|
2021-04-14 16:47:58 -04:00
|
|
|
rndid, strlen(rndid));
|
2019-10-18 10:12:26 -04:00
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
char *ret = g_strdup_printf("%s%s", rndid, hmac);
|
2018-08-30 05:01:28 -04:00
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
free(rndid);
|
2019-10-19 02:18:37 -04:00
|
|
|
g_free(hmac);
|
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
return ret;
|
2018-08-30 05:01:28 -04:00
|
|
|
}
|
|
|
|
|
2016-05-08 16:47:52 -04:00
|
|
|
char*
|
2016-05-05 18:51:49 -04:00
|
|
|
connection_get_domain(void)
|
|
|
|
{
|
|
|
|
return conn.domain;
|
|
|
|
}
|
|
|
|
|
2016-05-08 16:47:52 -04:00
|
|
|
char*
|
2016-05-05 18:51:49 -04:00
|
|
|
connection_get_presence_msg(void)
|
|
|
|
{
|
|
|
|
return conn.presence_message;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-07-07 08:18:57 -04:00
|
|
|
connection_set_presence_msg(const char* const message)
|
2016-05-05 18:51:49 -04:00
|
|
|
{
|
|
|
|
FREE_SET_NULL(conn.presence_message);
|
|
|
|
if (message) {
|
|
|
|
conn.presence_message = strdup(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
connection_set_priority(const int priority)
|
|
|
|
{
|
|
|
|
conn.priority = priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-07 08:18:57 -04:00
|
|
|
_connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error,
|
|
|
|
xmpp_stream_error_t* const stream_error, void* const userdata)
|
2016-05-05 18:51:49 -04:00
|
|
|
{
|
2019-06-01 13:21:46 -04:00
|
|
|
conn.conn_last_event = status;
|
|
|
|
|
2016-05-10 17:09:09 -04:00
|
|
|
switch (status) {
|
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
// login success
|
2016-05-10 17:09:09 -04:00
|
|
|
case XMPP_CONN_CONNECT:
|
2016-05-05 18:51:49 -04:00
|
|
|
log_debug("Connection handler: XMPP_CONN_CONNECT");
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.conn_status = JABBER_CONNECTED;
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
Jid* my_jid = jid_create(xmpp_conn_get_jid(conn.xmpp_conn));
|
2016-05-07 19:21:06 -04:00
|
|
|
conn.domain = strdup(my_jid->domainpart);
|
|
|
|
jid_destroy(my_jid);
|
|
|
|
|
2016-05-07 22:14:22 -04:00
|
|
|
conn.features_by_jid = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)g_hash_table_destroy);
|
2016-05-07 22:04:36 -04:00
|
|
|
g_hash_table_insert(conn.features_by_jid, strdup(conn.domain), g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL));
|
2016-05-07 19:21:06 -04:00
|
|
|
|
2016-05-05 19:53:03 -04:00
|
|
|
session_login_success(connection_is_secured());
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2016-05-10 17:09:09 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// disconnected
|
|
|
|
case XMPP_CONN_DISCONNECT:
|
2016-05-05 18:51:49 -04:00
|
|
|
log_debug("Connection handler: XMPP_CONN_DISCONNECT");
|
|
|
|
|
|
|
|
// lost connection for unknown reason
|
2016-05-05 21:31:55 -04:00
|
|
|
if (conn.conn_status == JABBER_CONNECTED) {
|
2016-05-05 18:51:49 -04:00
|
|
|
log_debug("Connection handler: Lost connection for unknown reason");
|
2016-05-05 19:53:03 -04:00
|
|
|
session_lost_connection();
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
// login attempt failed
|
2016-05-05 21:31:55 -04:00
|
|
|
} else if (conn.conn_status != JABBER_DISCONNECTING) {
|
2016-05-05 18:51:49 -04:00
|
|
|
log_debug("Connection handler: Login failed");
|
2016-05-05 19:53:03 -04:00
|
|
|
session_login_failed();
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
2016-05-10 17:09:09 -04:00
|
|
|
// close stream response from server after disconnect is handled
|
2016-05-05 21:31:55 -04:00
|
|
|
conn.conn_status = JABBER_DISCONNECTED;
|
2016-05-10 17:09:09 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// connection failed
|
|
|
|
case XMPP_CONN_FAIL:
|
2016-05-05 18:51:49 -04:00
|
|
|
log_debug("Connection handler: XMPP_CONN_FAIL");
|
2016-05-10 17:09:09 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
// unknown state
|
|
|
|
default:
|
2016-05-05 18:51:49 -04:00
|
|
|
log_error("Connection handler: Unknown status");
|
2016-05-10 17:09:09 -04:00
|
|
|
break;
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBMESODE
|
|
|
|
static int
|
2020-07-07 08:18:57 -04:00
|
|
|
_connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg)
|
2016-05-05 18:51:49 -04:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert);
|
2016-05-10 16:59:41 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
int res = sv_ev_certfail(errormsg, cert);
|
|
|
|
tlscerts_free(cert);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2016-05-10 17:09:09 -04:00
|
|
|
|
|
|
|
TLSCertificate*
|
2020-07-07 08:18:57 -04:00
|
|
|
_xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert)
|
2016-05-10 17:09:09 -04:00
|
|
|
{
|
|
|
|
return tlscerts_new(
|
|
|
|
xmpp_conn_tlscert_fingerprint(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_version(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_serialnumber(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_subjectname(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_issuername(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_notbefore(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_notafter(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_key_algorithm(xmpptlscert),
|
|
|
|
xmpp_conn_tlscert_signature_algorithm(xmpptlscert));
|
|
|
|
}
|
2016-05-05 18:51:49 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static xmpp_log_t*
|
|
|
|
_xmpp_get_file_logger(void)
|
|
|
|
{
|
2016-05-10 16:59:41 -04:00
|
|
|
log_level_t prof_level = log_get_filter();
|
|
|
|
xmpp_log_level_t xmpp_level = XMPP_LEVEL_ERROR;
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2016-05-10 16:59:41 -04:00
|
|
|
switch (prof_level) {
|
2020-07-07 08:18:57 -04:00
|
|
|
case PROF_LEVEL_DEBUG:
|
|
|
|
xmpp_level = XMPP_LEVEL_DEBUG;
|
|
|
|
break;
|
|
|
|
case PROF_LEVEL_INFO:
|
|
|
|
xmpp_level = XMPP_LEVEL_INFO;
|
|
|
|
break;
|
|
|
|
case PROF_LEVEL_WARN:
|
|
|
|
xmpp_level = XMPP_LEVEL_WARN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
xmpp_level = XMPP_LEVEL_ERROR;
|
|
|
|
break;
|
2016-05-10 16:59:41 -04:00
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
xmpp_log_t* file_log = malloc(sizeof(xmpp_log_t));
|
2016-05-05 18:51:49 -04:00
|
|
|
file_log->handler = _xmpp_file_logger;
|
2016-05-10 16:59:41 -04:00
|
|
|
file_log->userdata = &xmpp_level;
|
2016-05-05 18:51:49 -04:00
|
|
|
|
|
|
|
return file_log;
|
|
|
|
}
|
|
|
|
|
2016-05-10 16:59:41 -04:00
|
|
|
static void
|
2020-07-07 08:18:57 -04:00
|
|
|
_xmpp_file_logger(void* const userdata, const xmpp_log_level_t xmpp_level, const char* const area, const char* const msg)
|
2016-05-05 18:51:49 -04:00
|
|
|
{
|
2016-05-10 16:59:41 -04:00
|
|
|
log_level_t prof_level = PROF_LEVEL_ERROR;
|
2016-05-05 18:51:49 -04:00
|
|
|
|
2016-05-10 16:59:41 -04:00
|
|
|
switch (xmpp_level) {
|
2020-07-07 08:18:57 -04:00
|
|
|
case XMPP_LEVEL_DEBUG:
|
|
|
|
prof_level = PROF_LEVEL_DEBUG;
|
|
|
|
break;
|
|
|
|
case XMPP_LEVEL_INFO:
|
|
|
|
prof_level = PROF_LEVEL_INFO;
|
|
|
|
break;
|
|
|
|
case XMPP_LEVEL_WARN:
|
|
|
|
prof_level = PROF_LEVEL_WARN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
prof_level = PROF_LEVEL_ERROR;
|
|
|
|
break;
|
2016-05-05 18:51:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
log_msg(prof_level, area, msg);
|
2016-05-10 16:59:41 -04:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
if ((g_strcmp0(area, "xmpp") == 0) || (g_strcmp0(area, "conn")) == 0) {
|
|
|
|
sv_ev_xmpp_stanza(msg);
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
static void
|
|
|
|
_random_bytes_init(void)
|
2019-10-16 04:17:34 -04:00
|
|
|
{
|
2020-07-07 08:18:57 -04:00
|
|
|
char* rndbytes_loc;
|
|
|
|
GKeyFile* rndbytes;
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2019-10-16 04:54:05 -04:00
|
|
|
rndbytes_loc = files_get_data_path(FILE_PROFANITY_IDENTIFIER);
|
2019-10-16 04:17:34 -04:00
|
|
|
|
|
|
|
if (g_file_test(rndbytes_loc, G_FILE_TEST_EXISTS)) {
|
|
|
|
g_chmod(rndbytes_loc, S_IRUSR | S_IWUSR);
|
|
|
|
}
|
|
|
|
|
|
|
|
rndbytes = g_key_file_new();
|
|
|
|
g_key_file_load_from_file(rndbytes, rndbytes_loc, G_KEY_FILE_KEEP_COMMENTS, NULL);
|
|
|
|
|
2019-10-16 04:43:56 -04:00
|
|
|
if (g_key_file_has_group(rndbytes, "identifier")) {
|
2019-10-19 17:27:19 -04:00
|
|
|
profanity_instance_id = g_key_file_get_string(rndbytes, "identifier", "random_bytes", NULL);
|
2019-10-16 04:17:34 -04:00
|
|
|
} else {
|
2019-10-19 17:27:19 -04:00
|
|
|
profanity_instance_id = get_random_string(10);
|
|
|
|
g_key_file_set_string(rndbytes, "identifier", "random_bytes", profanity_instance_id);
|
2019-10-16 04:17:34 -04:00
|
|
|
|
|
|
|
gsize g_data_size;
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* g_accounts_data = g_key_file_to_data(rndbytes, &g_data_size, NULL);
|
2019-10-16 04:17:34 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
gchar* base = g_path_get_dirname(rndbytes_loc);
|
|
|
|
gchar* true_loc = get_file_or_linked(rndbytes_loc, base);
|
2019-10-16 04:17:34 -04:00
|
|
|
g_file_set_contents(true_loc, g_accounts_data, g_data_size, NULL);
|
|
|
|
|
|
|
|
g_free(base);
|
|
|
|
free(true_loc);
|
|
|
|
g_free(g_accounts_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(rndbytes_loc);
|
|
|
|
g_key_file_free(rndbytes);
|
|
|
|
}
|
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
static void
|
|
|
|
_random_bytes_close(void)
|
2019-10-16 04:17:34 -04:00
|
|
|
{
|
2019-10-19 17:27:19 -04:00
|
|
|
g_free(profanity_instance_id);
|
2019-10-16 04:17:34 -04:00
|
|
|
}
|
2019-10-16 09:53:28 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
static void
|
|
|
|
_compute_identifier(const char* barejid)
|
2019-10-16 09:53:28 -04:00
|
|
|
{
|
2019-10-21 03:50:13 -04:00
|
|
|
//in case of reconnect (lost connection)
|
2019-10-19 01:40:59 -04:00
|
|
|
free(prof_identifier);
|
|
|
|
|
2021-04-14 16:47:58 -04:00
|
|
|
prof_identifier = g_compute_hmac_for_string(G_CHECKSUM_SHA256,
|
|
|
|
(guchar*)profanity_instance_id, strlen(profanity_instance_id),
|
|
|
|
barejid, strlen(barejid));
|
2019-10-16 09:53:28 -04:00
|
|
|
}
|
2019-10-18 04:40:24 -04:00
|
|
|
|
2020-07-07 08:18:57 -04:00
|
|
|
const char*
|
|
|
|
connection_get_profanity_identifier(void)
|
|
|
|
{
|
2019-10-18 04:40:24 -04:00
|
|
|
return prof_identifier;
|
|
|
|
}
|