Merge pull request #13458 from lafirest/fix/banned_bf

fix(banned): let the bootfile of banned be optional
This commit is contained in:
lafirest 2024-07-12 15:00:43 +08:00 committed by GitHub
commit 4e3095b1c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -240,7 +240,7 @@ who(peerhost_net, CIDR) when is_binary(CIDR) ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Import From CSV %% Import From CSV
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init_from_csv(<<>>) -> init_from_csv(undefined) ->
ok; ok;
init_from_csv(File) -> init_from_csv(File) ->
maybe maybe
@ -365,7 +365,9 @@ init([]) ->
{ok, ensure_expiry_timer(#{expiry_timer => undefined}), {continue, init_from_csv}}. {ok, ensure_expiry_timer(#{expiry_timer => undefined}), {continue, init_from_csv}}.
handle_continue(init_from_csv, State) -> handle_continue(init_from_csv, State) ->
File = emqx_schema:naive_env_interpolation(emqx:get_config([banned, bootstrap_file], <<>>)), File = emqx_schema:naive_env_interpolation(
emqx:get_config([banned, bootstrap_file], undefined)
),
_ = init_from_csv(File), _ = init_from_csv(File),
{noreply, State}. {noreply, State}.

View File

@ -1777,7 +1777,7 @@ fields("banned") ->
binary(), binary(),
#{ #{
desc => ?DESC("banned_bootstrap_file"), desc => ?DESC("banned_bootstrap_file"),
default => <<>> require => false
} }
)} )}
]. ].
@ -3355,8 +3355,6 @@ default_listener(SSLListener) ->
%% otherwise always return string. %% otherwise always return string.
naive_env_interpolation(undefined) -> naive_env_interpolation(undefined) ->
undefined; undefined;
naive_env_interpolation(<<>>) ->
<<>>;
naive_env_interpolation(Bin) when is_binary(Bin) -> naive_env_interpolation(Bin) when is_binary(Bin) ->
naive_env_interpolation(unicode:characters_to_list(Bin, utf8)); naive_env_interpolation(unicode:characters_to_list(Bin, utf8));
naive_env_interpolation("$" ++ Maybe = Original) -> naive_env_interpolation("$" ++ Maybe = Original) ->