chore(psk): improve logs for psk
This commit is contained in:
parent
84bb486c62
commit
f9aa345787
|
@ -26,13 +26,23 @@
|
|||
|
||||
-spec lookup(psk, psk_identity(), psk_user_state()) -> {ok, SharedSecret :: binary()} | error.
|
||||
lookup(psk, PSKIdentity, UserState) ->
|
||||
try emqx_hooks:run_fold('tls_handshake.psk_lookup', [PSKIdentity], UserState) of
|
||||
SharedSecret when is_binary(SharedSecret) -> {ok, SharedSecret};
|
||||
Error ->
|
||||
?LOG(error, "Look PSK for PSKID ~p error: ~p", [PSKIdentity, Error]),
|
||||
try emqx_hooks:run_fold('tls_handshake.psk_lookup', [PSKIdentity, UserState], normal) of
|
||||
{ok, SharedSecret} when is_binary(SharedSecret) ->
|
||||
{ok, SharedSecret};
|
||||
normal ->
|
||||
?SLOG(info, #{msg => "psk_identity_not_found",
|
||||
psk_identity => PSKIdentity}),
|
||||
error;
|
||||
{error, Reason} ->
|
||||
?SLOG(warning, #{msg => "psk_identity_not_found",
|
||||
psk_identity => PSKIdentity,
|
||||
reason => Reason}),
|
||||
error
|
||||
catch
|
||||
Except:Error:Stacktrace ->
|
||||
?LOG(error, "Lookup PSK failed, ~0p: ~0p", [{Except,Error}, Stacktrace]),
|
||||
Class:Reason:Stacktrace ->
|
||||
?SLOG(error, #{msg => "lookup_psk_failed",
|
||||
class => Class,
|
||||
reason => Reason,
|
||||
stacktrace => Stacktrace}),
|
||||
error
|
||||
end.
|
||||
|
|
|
@ -88,7 +88,7 @@ unload() ->
|
|||
on_psk_lookup(PSKIdentity, _UserState) ->
|
||||
case mnesia:dirty_read(?TAB, PSKIdentity) of
|
||||
[#psk_entry{shared_secret = SharedSecret}] ->
|
||||
{stop, SharedSecret};
|
||||
{stop, {ok, SharedSecret}};
|
||||
_ ->
|
||||
ignore
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue