Report some TLS errors

This commit is contained in:
Evgeniy Khramtsov 2017-03-07 18:46:02 +03:00
parent 0aa22e5149
commit d0a185f2d9
2 changed files with 18 additions and 2 deletions

View File

@ -275,6 +275,12 @@ process_terminated(#{sockmod := SockMod, socket := Socket, jid := JID} = State,
end,
bounce_message_queue(),
State1;
process_terminated(#{sockmod := SockMod, socket := Socket,
stop_reason := {tls, no_certfile}} = State, Reason) ->
%% TODO: we probably need to report more TLS errors here
?ERROR_MSG("(~s) Failed to secure c2s connection: ~s",
[SockMod:pp(Socket), format_reason(State, Reason)]),
State;
process_terminated(State, _Reason) ->
State.

View File

@ -168,7 +168,8 @@ handle_stream_start(_StreamStart, #{lserver := LServer} = State) ->
end.
handle_stream_end(Reason, #{server_host := LServer} = State) ->
ejabberd_hooks:run_fold(s2s_in_closed, LServer, State, [Reason]).
State1 = State#{stop_reason => Reason},
ejabberd_hooks:run_fold(s2s_in_closed, LServer, State1, [Reason]).
handle_stream_established(State) ->
set_idle_timeout(State#{established => true}).
@ -284,7 +285,16 @@ handle_cast(Msg, #{server_host := LServer} = State) ->
handle_info(Info, #{server_host := LServer} = State) ->
ejabberd_hooks:run_fold(s2s_in_handle_info, LServer, State, [Info]).
terminate(Reason, #{auth_domains := AuthDomains}) ->
terminate(Reason, #{auth_domains := AuthDomains,
sockmod := SockMod, socket := Socket} = State) ->
case maps:get(stop_reason, State, undefined) of
{tls, no_certfile} = Err ->
%% TODO: we probably need to report more TLS errors here
?ERROR_MSG("(~s) Failed to secure inbound s2s connection: ~s",
[SockMod:pp(Socket), xmpp_stream_in:format_error(Err)]);
_ ->
ok
end,
case Reason of
{process_limit, _} ->
sets:fold(