From f4e35033e7b84efd7f7491e42c82bdae53d6780c Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 6 Oct 2009 10:05:10 +0000 Subject: [PATCH] Improve stream error stanza when receives invalid handshake from component. SVN Revision: 2641 --- src/ejabberd_service.erl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 1fe22afae..3f0620558 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -198,9 +198,23 @@ wait_for_handshake({xmlstreamelement, El}, StateData) -> end, StateData#state.hosts), {next_state, stream_established, StateData}; _ -> - send_element(StateData, - #xmlel{ns = ?NS_XMPP, name = 'error', children = [ - #xmlcdata{cdata = <<"Invalid Handshake">>}]}), + TextEl = + #xmlel{ns = ?NS_STANZA_ERRORS, + name = 'text', + children = + [#xmlcdata{cdata = <<"Invalid Handshake">>}] + }, + NotAuthorizedEl = + #xmlel{ns = ?NS_STANZA_ERRORS, + name = 'not-authorized', + children = [TextEl] + }, + InvalidHandshakeEl = + #xmlel{ns = ?NS_XMPP, + name = 'error', + children = [NotAuthorizedEl] + }, + send_element(StateData, InvalidHandshakeEl), send_element(StateData, exmpp_stream:closing()), {stop, normal, StateData} end;