Просмотр исходного кода

Merge pull request #13458 from lafirest/fix/banned_bf

fix(banned): let the bootfile of banned be optional
lafirest 1 год назад
Родитель
Сommit
4e3095b1c4
2 измененных файлов с 5 добавлено и 5 удалено
  1. 4 2
      apps/emqx/src/emqx_banned.erl
  2. 1 3
      apps/emqx/src/emqx_schema.erl

+ 4 - 2
apps/emqx/src/emqx_banned.erl

@@ -240,7 +240,7 @@ who(peerhost_net, CIDR) when is_binary(CIDR) ->
 %%--------------------------------------------------------------------
 %% Import From CSV
 %%--------------------------------------------------------------------
-init_from_csv(<<>>) ->
+init_from_csv(undefined) ->
     ok;
 init_from_csv(File) ->
     maybe
@@ -365,7 +365,9 @@ init([]) ->
     {ok, ensure_expiry_timer(#{expiry_timer => undefined}), {continue, init_from_csv}}.
 
 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),
     {noreply, State}.
 

+ 1 - 3
apps/emqx/src/emqx_schema.erl

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