24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-10 21:47:01 +02:00

* src/ejabberd_service.erl: Fix XEP-0114 compliance: define xmlns

in header of error response; check the connection is attempted to
a served component; include in response the JID of served
component not server (thanks to Sergei Golovan)

SVN Revision: 1516
This commit is contained in:
Badlop 2008-08-09 18:08:00 +00:00
parent 469f1c43a6
commit 9147a1d2dd
2 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2008-08-09 Badlop <badlop@process-one.net>
* src/ejabberd_service.erl: Fix XEP-0114 compliance: define xmlns
in header of error response; check the connection is attempted to
a served component; include in response the JID of served
component not server (thanks to Sergei Golovan)
2008-08-01 Badlop <badlop@process-one.net> 2008-08-01 Badlop <badlop@process-one.net>
* doc/release_notes_2.0.2.txt: Added for ejabberd 2.0.2-beta1 * doc/release_notes_2.0.2.txt: Added for ejabberd 2.0.2-beta1

View File

@ -1,7 +1,7 @@
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% File : ejabberd_service.erl %%% File : ejabberd_service.erl
%%% Author : Alexey Shchepin <alexey@process-one.net> %%% Author : Alexey Shchepin <alexey@process-one.net>
%%% Purpose : External component management %%% Purpose : External component management (XEP-0114)
%%% Created : 6 Dec 2002 by Alexey Shchepin <alexey@process-one.net> %%% Created : 6 Dec 2002 by Alexey Shchepin <alexey@process-one.net>
%%% %%%
%%% %%%
@ -73,11 +73,19 @@
-define(STREAM_TRAILER, "</stream:stream>"). -define(STREAM_TRAILER, "</stream:stream>").
-define(INVALID_HEADER_ERR, -define(INVALID_HEADER_ERR,
"<stream:stream>" "<stream:stream "
"xmlns:stream='http://etherx.jabber.org/streams'>"
"<stream:error>Invalid Stream Header</stream:error>" "<stream:error>Invalid Stream Header</stream:error>"
"</stream:stream>" "</stream:stream>"
). ).
-define(HOST_UNKNOWN_ERR,
"<stream:stream "
"xmlns:stream='http://etherx.jabber.org/streams'>"
"<stream:error>Host Unknown</stream:error>"
"</stream:stream>"
).
-define(INVALID_HANDSHAKE_ERR, -define(INVALID_HANDSHAKE_ERR,
"<stream:error>Invalid Handshake</stream:error>" "<stream:error>Invalid Handshake</stream:error>"
"</stream:stream>" "</stream:stream>"
@ -168,13 +176,21 @@ init([{SockMod, Socket}, Opts]) ->
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) -> wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
% TODO
case xml:get_attr_s("xmlns", Attrs) of case xml:get_attr_s("xmlns", Attrs) of
"jabber:component:accept" -> "jabber:component:accept" ->
Header = io_lib:format(?STREAM_HEADER, %% Check that destination is a served component
[StateData#state.streamid, ?MYNAME]), To = xml:get_attr_s("to", Attrs),
send_text(StateData, Header), case lists:member(To, StateData#state.hosts) of
{next_state, wait_for_handshake, StateData}; true ->
Header = io_lib:format(?STREAM_HEADER,
[StateData#state.streamid,
xml:crypt(To)]),
send_text(StateData, Header),
{next_state, wait_for_handshake, StateData};
_ ->
send_text(StateData, ?HOST_UNKNOWN_ERR),
{stop, normal, StateData}
end;
_ -> _ ->
send_text(StateData, ?INVALID_HEADER_ERR), send_text(StateData, ?INVALID_HEADER_ERR),
{stop, normal, StateData} {stop, normal, StateData}