aboutsummaryrefslogtreecommitdiff
path: root/src/mod_stream_mgmt.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-06-25 09:56:44 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-06-25 09:56:44 +0300
commit499ae96254a047526eecc316b46fece324b27c14 (patch)
treeb83f419515903b2f6817afa983c94de0781d120c /src/mod_stream_mgmt.erl
parentUse error formatting functions from xmpp library (diff)
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.
Diffstat (limited to 'src/mod_stream_mgmt.erl')
-rw-r--r--src/mod_stream_mgmt.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl
index c0ab394ad..62124b22e 100644
--- a/src/mod_stream_mgmt.erl
+++ b/src/mod_stream_mgmt.erl
@@ -142,13 +142,15 @@ c2s_stream_features(Acc, Host) ->
Acc
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
%% attempt to enable stream management until after it has completed Resource
%% Binding unless it is resuming a previous session". However, it also
%% says: "Stream management errors SHOULD be considered recoverable", so we
%% 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)};
c2s_unauthenticated_packet(State, _Pkt) ->
State.
@@ -351,7 +353,7 @@ negotiate_stream_mgmt(Pkt, State) ->
end.
-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
Xmlns ->
case Pkt of
@@ -368,7 +370,10 @@ perform_stream_mgmt(Pkt, #{mgmt_xmlns := Xmlns} = State) ->
xmlns = Xmlns})
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.
-spec handle_enable(state(), sm_enable()) -> state().