conn: added API xmpp_conn_is_secured()
This patch is provided by @kjkao. New API is already used in WorksSystems/wks_xep0047.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
- IPv6 support
|
||||
- Old style SSL support
|
||||
- New API xmpp_uuid_gen()
|
||||
- New API xmpp_conn_is_secured()
|
||||
|
||||
0.8.8
|
||||
- XML namespace support
|
||||
|
||||
@@ -21,9 +21,13 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||
void * const userdata)
|
||||
{
|
||||
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
|
||||
int secured;
|
||||
|
||||
if (status == XMPP_CONN_CONNECT) {
|
||||
fprintf(stderr, "DEBUG: connected\n");
|
||||
secured = xmpp_conn_is_secured(conn);
|
||||
fprintf(stderr, "DEBUG: connection is %s.\n",
|
||||
secured ? "secured" : "NOT secured");
|
||||
xmpp_disconnect(conn);
|
||||
}
|
||||
else {
|
||||
@@ -74,7 +78,7 @@ int main(int argc, char **argv)
|
||||
/* create a connection */
|
||||
conn = xmpp_conn_new(ctx);
|
||||
|
||||
/* configure connection properties */
|
||||
/* configure connection properties (optional) */
|
||||
if (opt_disable_tls)
|
||||
xmpp_conn_disable_tls(conn);
|
||||
if (opt_old_ssl)
|
||||
|
||||
@@ -788,6 +788,12 @@ void xmpp_conn_set_old_style_ssl(xmpp_conn_t * const conn)
|
||||
conn->tls_is_old_ssl = 1;
|
||||
}
|
||||
|
||||
/** Returns whether TLS session is established or not. */
|
||||
int xmpp_conn_is_secured(xmpp_conn_t * const conn)
|
||||
{
|
||||
return conn->secured && !conn->tls_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
static void _log_open_tag(xmpp_conn_t *conn, char **attrs)
|
||||
{
|
||||
char buf[4096];
|
||||
|
||||
@@ -216,6 +216,7 @@ void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass);
|
||||
xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn);
|
||||
void xmpp_conn_disable_tls(xmpp_conn_t * const conn);
|
||||
void xmpp_conn_set_old_style_ssl(xmpp_conn_t * const conn);
|
||||
int xmpp_conn_is_secured(xmpp_conn_t * const conn);
|
||||
|
||||
int xmpp_connect_client(xmpp_conn_t * const conn,
|
||||
const char * const altdomain,
|
||||
|
||||
Reference in New Issue
Block a user