]> granicus.if.org Git - ejabberd/commitdiff
XEP-0198: Improve handling of non-message stanzas
authorHolger Weiss <holger@zedat.fu-berlin.de>
Tue, 15 Sep 2015 20:42:22 +0000 (22:42 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Tue, 15 Sep 2015 20:42:22 +0000 (22:42 +0200)
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.

src/ejabberd_c2s.erl

index 10ff01b211c5f1d6a5dbee7d66de3e33e0d59b65..2c06fef05fc5ce3a51d0ae538be1f56c9caf590a 100644 (file)
@@ -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 <forwarded/> 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)