[Asterisk-code-review] res xmpp: Does not connect in component mode (asterisk[11])
Karsten Wemheuer
asteriskteam at digium.com
Tue Feb 2 04:08:52 CST 2016
Karsten Wemheuer has uploaded a new change for review.
https://gerrit.asterisk.org/2141
Change subject: res_xmpp: Does not connect in component mode
......................................................................
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
Change-Id: I70e036f931c3124ebb2ad1e56f93ed35cfdd9d5c
---
M res/res_xmpp.c
1 file changed, 10 insertions(+), 6 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/41/2141/1
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index df04662..51a3c88 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -2994,6 +2994,10 @@
/*! \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;
@@ -3149,6 +3153,11 @@
char *type = iks_find_attrib(pak->x, "type");
int status = pak->show ? pak->show : STATUS_DISAPPEAR;
+ /* 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;
@@ -3161,11 +3170,6 @@
pak->from->partial, client->name);
}
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);
@@ -3702,7 +3706,7 @@
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;
}
--
To view, visit https://gerrit.asterisk.org/2141
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I70e036f931c3124ebb2ad1e56f93ed35cfdd9d5c
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Karsten Wemheuer <kwe-digium at iptam.com>
More information about the asterisk-code-review
mailing list