Bounce messages sent to server JID

If a message is sent to the server JID (without node part), generate an
error message rather than dropping the message silently.
This commit is contained in:
Holger Weiss 2016-05-06 13:59:21 +02:00
parent 86d5cf6d6c
commit 51238bff83
1 changed files with 10 additions and 1 deletions

View File

@ -271,7 +271,16 @@ do_route(From, To, Packet) ->
#xmlel{name = Name} = Packet,
case Name of
<<"iq">> -> process_iq(From, To, Packet);
<<"message">> -> ok;
<<"message">> ->
#xmlel{attrs = Attrs} = Packet,
case fxml:get_attr_s(<<"type">>, Attrs) of
<<"headline">> -> ok;
<<"error">> -> ok;
_ ->
Err = jlib:make_error_reply(Packet,
?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err)
end;
<<"presence">> -> ok;
_ -> ok
end;