diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/blocking.c | 6 | ||||
-rw-r--r-- | src/xmpp/bookmark.c | 6 | ||||
-rw-r--r-- | src/xmpp/capabilities.c | 6 | ||||
-rw-r--r-- | src/xmpp/capabilities.h | 6 | ||||
-rw-r--r-- | src/xmpp/connection.c | 72 | ||||
-rw-r--r-- | src/xmpp/form.c | 6 | ||||
-rw-r--r-- | src/xmpp/form.h | 6 | ||||
-rw-r--r-- | src/xmpp/iq.c | 6 | ||||
-rw-r--r-- | src/xmpp/message.c | 16 | ||||
-rw-r--r-- | src/xmpp/presence.c | 6 | ||||
-rw-r--r-- | src/xmpp/roster.c | 6 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 6 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 8 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 8 |
14 files changed, 33 insertions, 131 deletions
diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 7c55b1bf..e68999d2 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -38,13 +38,7 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include <glib.h> diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index 4e40e3ec..916c8195 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -41,13 +41,7 @@ #include <string.h> #include <glib.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 98a5c399..638b2c90 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -45,13 +45,7 @@ #include <glib.h> #include <glib/gstdio.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h index 0760f7d7..bbc1cf8e 100644 --- a/src/xmpp/capabilities.h +++ b/src/xmpp/capabilities.h @@ -38,13 +38,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "xmpp/xmpp.h" diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 5570fb1a..516006a9 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -43,13 +43,7 @@ #include <glib.h> #include <glib/gstdio.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "common.h" #include "log.h" @@ -94,10 +88,8 @@ static void _xmpp_file_logger(void* const userdata, const xmpp_log_level_t level 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); -#ifdef HAVE_LIBMESODE -TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert); -static int _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg); -#endif +TLSCertificate* _xmppcert_to_profcert(const xmpp_tlscert_t* xmpptlscert); +static int _connection_certfail_cb(const xmpp_tlscert_t* xmpptlscert, const char* errormsg); static void _random_bytes_init(void); static void _random_bytes_close(void); @@ -220,28 +212,20 @@ connection_connect(const char* const jid, const char* const passwd, const char* #undef LOG_FLAG_IF_SET } -#ifdef HAVE_LIBMESODE char* cert_path = prefs_get_tls_certpath(); if (cert_path) { - xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + xmpp_conn_set_capath(conn.xmpp_conn, cert_path); free(cert_path); } - int connect_status = xmpp_connect_client( - conn.xmpp_conn, - altdomain, - port, - _connection_certfail_cb, - _connection_handler, - conn.xmpp_ctx); -#else + xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb); + int connect_status = xmpp_connect_client( conn.xmpp_conn, altdomain, port, _connection_handler, conn.xmpp_ctx); -#endif if (connect_status == 0) { conn.conn_status = JABBER_CONNECTING; @@ -555,28 +539,20 @@ connection_register(const char* const altdomain, int port, const char* const tls reg->username = strdup(username); reg->password = strdup(password); -#ifdef HAVE_LIBMESODE char* cert_path = prefs_get_tls_certpath(); if (cert_path) { - xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + xmpp_conn_set_capath(conn.xmpp_conn, cert_path); free(cert_path); } - int connect_status = xmpp_connect_raw( - conn.xmpp_conn, - altdomain, - port, - _connection_certfail_cb, - _register_handler, - reg); -#else + xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb); + int connect_status = xmpp_connect_raw( conn.xmpp_conn, altdomain, port, _register_handler, reg); -#endif if (connect_status == 0) { conn.conn_status = JABBER_RAW_CONNECTING; @@ -645,17 +621,15 @@ connection_clear_data(void) } } -#ifdef HAVE_LIBMESODE TLSCertificate* connection_get_tls_peer_cert(void) { - xmpp_tlscert_t* xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn); + xmpp_tlscert_t* xmpptlscert = xmpp_conn_get_peer_cert(conn.xmpp_conn); TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); - xmpp_conn_free_tlscert(conn.xmpp_ctx, xmpptlscert); + xmpp_tlscert_free(xmpptlscert); return cert; } -#endif gboolean connection_is_secured(void) @@ -971,9 +945,8 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status } } -#ifdef HAVE_LIBMESODE static int -_connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg) +_connection_certfail_cb(const xmpp_tlscert_t* xmpptlscert, const char* errormsg) { TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); @@ -984,20 +957,21 @@ _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg) } TLSCertificate* -_xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert) +_xmppcert_to_profcert(const xmpp_tlscert_t* xmpptlscert) { + int version = (int)strtol( + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_VERSION), NULL, 10); 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)); + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_FINGERPRINT_SHA1), + version, + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SERIALNUMBER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SUBJECT), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_ISSUER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTBEFORE), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTAFTER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_KEYALG), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SIGALG)); } -#endif static xmpp_log_t* _xmpp_get_file_logger(void) diff --git a/src/xmpp/form.c b/src/xmpp/form.c index dc8c583c..5290c83f 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -38,13 +38,7 @@ #include <string.h> #include <stdlib.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include <glib.h> diff --git a/src/xmpp/form.h b/src/xmpp/form.h index b305addf..73a3d6c7 100644 --- a/src/xmpp/form.h +++ b/src/xmpp/form.h @@ -36,13 +36,7 @@ #ifndef XMPP_FORM_H #define XMPP_FORM_H -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "xmpp/xmpp.h" diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index dd3c2423..ebc052fc 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -44,13 +44,7 @@ #include <stdio.h> #include <glib.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 051d1ece..4aa22437 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -39,13 +39,7 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "profanity.h" #include "log.h" @@ -229,7 +223,13 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con gboolean is_carbon = FALSE; // XEP-0280: Message Carbons - xmpp_stanza_t* carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS); + // Only allow `<sent xmlns='urn:xmpp:carbons:2'>` and `<received xmlns='urn:xmpp:carbons:2'>` carbons + // Thus ignoring `<private xmlns="urn:xmpp:carbons:2"/>` + xmpp_stanza_t* carbons = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_SENT, STANZA_NS_CARBONS); + if (!carbons) { + carbons = xmpp_stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_RECEIVED, STANZA_NS_CARBONS); + } + if (carbons) { // carbon must come from ourselves @@ -1289,7 +1289,7 @@ _handle_carbons(xmpp_stanza_t* const stanza) } */ - if ((g_strcmp0(name, "received") != 0) && (g_strcmp0(name, "sent") != 0)) { + if ((g_strcmp0(name, STANZA_NAME_RECEIVED) != 0) && (g_strcmp0(name, STANZA_NAME_SENT) != 0)) { log_warning("Carbon received with unrecognised stanza name: %s", name); return NULL; } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 2982274d..a9b07daa 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -42,13 +42,7 @@ #include <glib.h> #include <glib/gprintf.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 2b5a1696..fd7ceecf 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -41,13 +41,7 @@ #include <glib.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 3a1cb4a5..d28ed3d2 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -48,13 +48,7 @@ #include <glib.h> -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index bd61f2f4..7aac5d08 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -38,13 +38,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include <xmpp/xmpp.h> @@ -123,6 +117,8 @@ #define STANZA_NAME_USERNAME "username" #define STANZA_NAME_PROPOSE "propose" #define STANZA_NAME_REPORT "report" +#define STANZA_NAME_RECEIVED "received" +#define STANZA_NAME_SENT "sent" // error conditions #define STANZA_NAME_BAD_REQUEST "bad-request" diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index bb561080..16293d73 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -40,13 +40,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include <mesode.h> -#endif - -#ifdef HAVE_LIBSTROPHE #include <strophe.h> -#endif #include "config/accounts.h" #include "config/tlscerts.h" @@ -199,9 +193,7 @@ char* connection_get_barejid(void); char* connection_get_user(void); char* connection_create_uuid(void); void connection_free_uuid(char* uuid); -#ifdef HAVE_LIBMESODE TLSCertificate* connection_get_tls_peer_cert(void); -#endif gboolean connection_is_secured(void); gboolean connection_send_stanza(const char* const stanza); GList* connection_get_available_resources(void); |