From: Holger Weiss Date: Tue, 15 Sep 2015 20:42:22 +0000 (+0200) Subject: XEP-0198: Improve handling of non-message stanzas X-Git-Tag: 15.09~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59321ac56e9db15bdeff88591a76f5b86fe42c5b;p=ejabberd XEP-0198: Improve handling of non-message stanzas When an XEP-0198 session times out, always return an error for unacknowledged IQ stanzas, and always drop presence stanzas. That is, the "resend_on_timeout" option no longer applies to those stanzas types, but only to messages. --- diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 10ff01b21..2c06fef05 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -2920,7 +2920,13 @@ handle_unacked_stanzas(StateData) ejabberd_router:route(To, From, Err) end end, - F = fun(From, To, El, Time) -> + F = fun(From, _To, #xmlel{name = <<"presence">>}, _Time) -> + ?DEBUG("Dropping presence stanza from ~s", + [jlib:jid_to_string(From)]); + (From, To, #xmlel{name = <<"iq">>} = El, _Time) -> + Err = jlib:make_error_reply(El, ?ERR_SERVICE_UNAVAILABLE), + ejabberd_router:route(To, From, Err); + (From, To, El, Time) -> %% We'll drop the stanza if it was by some %% encapsulating protocol as per XEP-0297. One such protocol is %% XEP-0280, which says: "When a receiving server attempts to @@ -2930,7 +2936,7 @@ handle_unacked_stanzas(StateData) %% stanza could easily lead to unexpected results as well. case is_encapsulated_forward(El) of true -> - ?DEBUG("Dropping forwarded stanza from ~s", + ?DEBUG("Dropping forwarded message stanza from ~s", [xml:get_attr_s(<<"from">>, El#xmlel.attrs)]); false -> ReRoute(From, To, El, Time)