26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Don't use 'unsupported-version' inside SM <failed/> element

This error condition is defined within stream errors, however,
XEP-0198 says:

> This element SHOULD contain an error condition, which MUST
> be one of the **stanza** error conditions defined in RFC 6120.
This commit is contained in:
Evgeniy Khramtsov 2018-06-25 09:56:44 +03:00
parent ac31c85866
commit 499ae96254

View File

@ -142,13 +142,15 @@ c2s_stream_features(Acc, Host) ->
Acc Acc
end. end.
c2s_unauthenticated_packet(State, Pkt) when ?is_sm_packet(Pkt) -> c2s_unauthenticated_packet(#{lang := Lang} = State, Pkt) when ?is_sm_packet(Pkt) ->
%% XEP-0198 says: "For client-to-server connections, the client MUST NOT %% XEP-0198 says: "For client-to-server connections, the client MUST NOT
%% attempt to enable stream management until after it has completed Resource %% attempt to enable stream management until after it has completed Resource
%% Binding unless it is resuming a previous session". However, it also %% Binding unless it is resuming a previous session". However, it also
%% says: "Stream management errors SHOULD be considered recoverable", so we %% says: "Stream management errors SHOULD be considered recoverable", so we
%% won't bail out. %% won't bail out.
Err = #sm_failed{reason = 'unexpected-request', xmlns = ?NS_STREAM_MGMT_3}, Err = #sm_failed{reason = 'not-authorized',
text = xmpp:mk_text(<<"Unauthorized">>, Lang),
xmlns = ?NS_STREAM_MGMT_3},
{stop, send(State, Err)}; {stop, send(State, Err)};
c2s_unauthenticated_packet(State, _Pkt) -> c2s_unauthenticated_packet(State, _Pkt) ->
State. State.
@ -351,7 +353,7 @@ negotiate_stream_mgmt(Pkt, State) ->
end. end.
-spec perform_stream_mgmt(xmpp_element(), state()) -> state(). -spec perform_stream_mgmt(xmpp_element(), state()) -> state().
perform_stream_mgmt(Pkt, #{mgmt_xmlns := Xmlns} = State) -> perform_stream_mgmt(Pkt, #{mgmt_xmlns := Xmlns, lang := Lang} = State) ->
case xmpp:get_ns(Pkt) of case xmpp:get_ns(Pkt) of
Xmlns -> Xmlns ->
case Pkt of case Pkt of
@ -368,7 +370,10 @@ perform_stream_mgmt(Pkt, #{mgmt_xmlns := Xmlns} = State) ->
xmlns = Xmlns}) xmlns = Xmlns})
end; end;
_ -> _ ->
send(State, #sm_failed{reason = 'unsupported-version', xmlns = Xmlns}) Txt = <<"Unsupported version">>,
send(State, #sm_failed{reason = 'unexpected-request',
text = xmpp:mk_text(Txt, Lang),
xmlns = Xmlns})
end. end.
-spec handle_enable(state(), sm_enable()) -> state(). -spec handle_enable(state(), sm_enable()) -> state().