chore(psk): fix bugs
This commit is contained in:
parent
29277b1d6b
commit
d391690505
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue