diff --git a/ChangeLog b/ChangeLog index 9f431eda9..ef6bf63b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-08-09 Badlop + + * 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-04 Jerome Sautret * src/odbc/ejabberd_odbc.erl: Restart the database connection when diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 649f44951..d7216fc6e 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -1,7 +1,7 @@ %%%---------------------------------------------------------------------- %%% File : ejabberd_service.erl %%% Author : Alexey Shchepin -%%% Purpose : External component management +%%% Purpose : External component management (XEP-0114) %%% Created : 6 Dec 2002 by Alexey Shchepin %%% %%% @@ -73,11 +73,19 @@ -define(STREAM_TRAILER, ""). -define(INVALID_HEADER_ERR, - "" + "" "Invalid Stream Header" "" ). +-define(HOST_UNKNOWN_ERR, + "" + "Host Unknown" + "" + ). + -define(INVALID_HANDSHAKE_ERR, "Invalid Handshake" "" @@ -168,13 +176,21 @@ init([{SockMod, Socket}, Opts]) -> %%---------------------------------------------------------------------- wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) -> - % TODO case xml:get_attr_s("xmlns", Attrs) of "jabber:component:accept" -> - Header = io_lib:format(?STREAM_HEADER, - [StateData#state.streamid, ?MYNAME]), - send_text(StateData, Header), - {next_state, wait_for_handshake, StateData}; + %% Check that destination is a served component + To = xml:get_attr_s("to", Attrs), + case lists:member(To, StateData#state.hosts) of + 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), {stop, normal, StateData}