mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-18 22:15:20 +02:00
Improve logging of dialback failures
This commit is contained in:
parent
f3594ec881
commit
95a8f58314
|
@ -248,8 +248,10 @@ s2s_out_packet(#{server := LServer, remote_server := RServer} = State,
|
||||||
State2 = ejabberd_s2s_out:handle_auth_success(<<"dialback">>, State1),
|
State2 = ejabberd_s2s_out:handle_auth_success(<<"dialback">>, State1),
|
||||||
ejabberd_s2s_out:establish(State2);
|
ejabberd_s2s_out:establish(State2);
|
||||||
_ ->
|
_ ->
|
||||||
Reason = format_error(Result),
|
Reason = str:format("Peer responded with error: ~s",
|
||||||
ejabberd_s2s_out:handle_auth_failure(<<"dialback">>, {auth, Reason}, State1)
|
[format_error(Result)]),
|
||||||
|
ejabberd_s2s_out:handle_auth_failure(
|
||||||
|
<<"dialback">>, {auth, Reason}, State1)
|
||||||
end;
|
end;
|
||||||
s2s_out_packet(State, Pkt) when is_record(Pkt, db_result);
|
s2s_out_packet(State, Pkt) when is_record(Pkt, db_result);
|
||||||
is_record(Pkt, db_verify) ->
|
is_record(Pkt, db_verify) ->
|
||||||
|
@ -298,7 +300,8 @@ send_db_result(State, #db_verify{from = From, to = To,
|
||||||
From, <<"dialback">>, undefined, State1),
|
From, <<"dialback">>, undefined, State1),
|
||||||
ejabberd_s2s_in:establish(State2);
|
ejabberd_s2s_in:establish(State2);
|
||||||
_ ->
|
_ ->
|
||||||
Reason = format_error(Response),
|
Reason = str:format("Verification failed: ~s",
|
||||||
|
[format_error(Response)]),
|
||||||
ejabberd_s2s_in:handle_auth_failure(
|
ejabberd_s2s_in:handle_auth_failure(
|
||||||
From, <<"dialback">>, Reason, State1)
|
From, <<"dialback">>, Reason, State1)
|
||||||
end.
|
end.
|
||||||
|
@ -334,10 +337,25 @@ format_error(#db_result{type = invalid}) ->
|
||||||
format_error(#db_result{type = error, sub_els = Els}) ->
|
format_error(#db_result{type = error, sub_els = Els}) ->
|
||||||
%% TODO: improve xmpp.erl
|
%% TODO: improve xmpp.erl
|
||||||
case xmpp:get_error(#message{sub_els = Els}) of
|
case xmpp:get_error(#message{sub_els = Els}) of
|
||||||
#stanza_error{reason = Reason} ->
|
#stanza_error{} = Err ->
|
||||||
erlang:atom_to_binary(Reason, latin1);
|
format_stanza_error(Err);
|
||||||
undefined ->
|
undefined ->
|
||||||
<<"unrecognized error">>
|
<<"unrecognized error">>
|
||||||
end;
|
end;
|
||||||
format_error(_) ->
|
format_error(_) ->
|
||||||
<<"unexpected dialback result">>.
|
<<"unexpected dialback result">>.
|
||||||
|
|
||||||
|
-spec format_stanza_error(stanza_error()) -> binary().
|
||||||
|
format_stanza_error(#stanza_error{reason = Reason, text = Txt}) ->
|
||||||
|
Slogan = case Reason of
|
||||||
|
undefined -> <<"no reason">>;
|
||||||
|
#gone{} -> <<"gone">>;
|
||||||
|
#redirect{} -> <<"redirect">>;
|
||||||
|
_ -> erlang:atom_to_binary(Reason, latin1)
|
||||||
|
end,
|
||||||
|
case Txt of
|
||||||
|
undefined -> Slogan;
|
||||||
|
#text{data = <<"">>} -> Slogan;
|
||||||
|
#text{data = Data} ->
|
||||||
|
<<Data/binary, " (", Slogan/binary, ")">>
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user