summaryrefslogtreecommitdiff
path: root/res/res_xmpp.c
diff options
context:
space:
mode:
authorKarsten Wemheuer <kwe-digium@iptam.com>2016-02-02 11:05:15 +0100
committerJoshua Colp <jcolp@digium.com>2016-02-02 06:48:15 -0600
commit2a6f18cd55d0108e7a3de2f6f71602c11ac2d485 (patch)
tree4a11b4fd4bf30a4473cf6c02435f2d0b5c46e19c /res/res_xmpp.c
parent40da6434c1189e2557d20ea3871761cb34595257 (diff)
res_xmpp: Does not connect in component mode
The module res_xmpp does not accept usernames in the form used in component mode (XEP-0114). In component mode there is no @something in the name. In component mode the connection is now not dropped anymore. If the xmpp server sends out a "stream" tag before handshake is finished, the connection gets dropped in res_xmpp. Now this tag will be ignored and the connection will be established. After connecting there will be an exchange of presence states. This does not work as expected in component mode. The responsible function "xmpp_pak_presence" is left before the states get sent out. Sending presence states in component mode is now moved to the top of the function. ASTERISK-25735 #close Change-Id: I70e036f931c3124ebb2ad1e56f93ed35cfdd9d5c
Diffstat (limited to 'res/res_xmpp.c')
-rw-r--r--res/res_xmpp.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 2a087b055..67e479d86 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -3130,6 +3130,10 @@ done:
/*! \brief Internal function called when we authenticated as a component */
static int xmpp_component_authenticating(struct ast_xmpp_client *client, struct ast_xmpp_client_config *cfg, int type, iks *node)
{
+ if (!strcmp(iks_name(node), "stream:features")) {
+ return 0;
+ }
+
if (strcmp(iks_name(node), "handshake")) {
ast_log(LOG_ERROR, "Failed to authenticate component '%s'\n", client->name);
return -1;
@@ -3305,6 +3309,11 @@ static int xmpp_pak_presence(struct ast_xmpp_client *client, struct ast_xmpp_cli
int status = pak->show ? pak->show : STATUS_DISAPPEAR;
enum ast_device_state state = AST_DEVICE_UNAVAILABLE;
+ /* If this is a component presence probe request answer immediately with our presence status */
+ if (ast_test_flag(&cfg->flags, XMPP_COMPONENT) && !ast_strlen_zero(type) && !strcasecmp(type, "probe")) {
+ xmpp_client_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), cfg->status, cfg->statusmsg);
+ }
+
/* If no resource is available this is a general buddy presence update, which we will ignore */
if (!pak->from->resource) {
return 0;
@@ -3319,11 +3328,6 @@ static int xmpp_pak_presence(struct ast_xmpp_client *client, struct ast_xmpp_cli
return 0;
}
- /* If this is a component presence probe request answer immediately with our presence status */
- if (ast_test_flag(&cfg->flags, XMPP_COMPONENT) && !ast_strlen_zero(type) && !strcasecmp(type, "probe")) {
- xmpp_client_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), cfg->status, cfg->statusmsg);
- }
-
ao2_lock(buddy->resources);
if (!(resource = ao2_callback(buddy->resources, OBJ_NOLOCK, xmpp_resource_cmp, pak->from->resource))) {
@@ -3864,7 +3868,7 @@ static int xmpp_client_config_post_apply(void *obj, void *arg, int flags)
cfg->client->jid = iks_id_new(cfg->client->stack, cfg->user);
}
- if (!cfg->client->jid || ast_strlen_zero(cfg->client->jid->user)) {
+ if (!cfg->client->jid || (ast_strlen_zero(cfg->client->jid->user) && !ast_test_flag(&cfg->flags, XMPP_COMPONENT))) {
ast_log(LOG_ERROR, "Jabber identity '%s' could not be created for client '%s' - client not active\n", cfg->user, cfg->name);
return -1;
}