chore(psk): fix bugs

This commit is contained in:
zhouzb 2021-09-24 09:29:08 +08:00
parent 29277b1d6b
commit d391690505
2 changed files with 10 additions and 12 deletions

View File

@ -33,7 +33,7 @@ prop_lookup() ->
?ALL({ClientPSKID, UserState}, ?ALL({ClientPSKID, UserState},
{client_pskid(), user_state()}, {client_pskid(), user_state()},
begin begin
case emqx_psk:lookup(psk, ClientPSKID, UserState) of case emqx_tls_psk:lookup(psk, ClientPSKID, UserState) of
{ok, _Result} -> true; {ok, _Result} -> true;
error -> true; error -> true;
_Other -> false _Other -> false

View File

@ -106,11 +106,11 @@ stop() ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init(_Opts) -> init(_Opts) ->
case is_enable() of case get_config(enable) of
true -> load(); true -> load();
false -> ok false -> ok
end, end,
case init_file() of case get_config(init_file) of
undefined -> ok; undefined -> ok;
BootFile -> import_psks(BootFile) BootFile -> import_psks(BootFile)
end, end,
@ -142,13 +142,11 @@ code_change(_OldVsn, State, _Extra) ->
%% Internal functions %% Internal functions
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
is_enable() -> get_config(enable) ->
emqx_config:get([psk, enable]). emqx_config:get([psk, enable]);
get_config(init_file) ->
init_file() -> emqx_config:get([psk, init_file], undefined);
emqx_config:get([psk, init_file], undefined). get_config(separator) ->
separator() ->
emqx_config:get([psk, separator], ?DEFAULT_DELIMITER). emqx_config:get([psk, separator], ?DEFAULT_DELIMITER).
import_psks(SrcFile) -> import_psks(SrcFile) ->
@ -156,10 +154,10 @@ import_psks(SrcFile) ->
{error, Reason} -> {error, Reason} ->
{error, Reason}; {error, Reason};
{ok, Io} -> {ok, Io} ->
case Result = import_psks(Io, separator()) of case Result = import_psks(Io, get_config(separator)) of
ok -> ignore; ok -> ignore;
{error, Reason} -> {error, Reason} ->
?LOG("Failed to import psk from ~s due to ~p", [SrcFile, Reason]) ?LOG(warning, "Failed to import psk from ~s due to ~p", [SrcFile, Reason])
end, end,
_ = file:close(Io), _ = file:close(Io),
Result Result