refactor(ssl): Move data dir for ssl certs upload down to lib module
This commit is contained in:
parent
8a41a4ee00
commit
71559dd001
|
@ -567,8 +567,7 @@ options(Options, PoolName, ResId) ->
|
|||
maybe_ssl(_Options, false, _ResId) ->
|
||||
[];
|
||||
maybe_ssl(Options, true, ResId) ->
|
||||
Dir = filename:join([emqx:get_env(data_dir), "rules", ResId]),
|
||||
[{ssl, true}, {ssl_opts, emqx_plugin_libs_ssl:save_files_return_opts(Options, Dir)}].
|
||||
[{ssl, true}, {ssl_opts, emqx_plugin_libs_ssl:save_files_return_opts(Options, "rules", ResId)}].
|
||||
|
||||
mqtt_ver(ProtoVer) ->
|
||||
case ProtoVer of
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
-module(emqx_plugin_libs_ssl).
|
||||
|
||||
-export([save_files_return_opts/2]).
|
||||
-export([save_files_return_opts/2,
|
||||
save_files_return_opts/3
|
||||
]).
|
||||
|
||||
-type file_input_key() :: binary(). %% <<"file">> | <<"filename">>
|
||||
-type file_input() :: #{file_input_key() => binary()}.
|
||||
|
@ -36,6 +38,14 @@
|
|||
-type opt_value() :: term().
|
||||
-type opts() :: [{opt_key(), opt_value()}].
|
||||
|
||||
%% @doc Parse ssl options input.
|
||||
%% If the input contains file content, save the files in the given dir.
|
||||
%% Returns ssl options for Erlang's ssl application.
|
||||
-spec save_files_return_opts(opts_input(), string(), string() | binary()) -> opts().
|
||||
save_files_return_opts(Options, SubDir, ResId) ->
|
||||
Dir = filename:join([emqx:get_env(data_dir), SubDir, ResId]),
|
||||
save_files_return_opts(Options, Dir).
|
||||
|
||||
%% @doc Parse ssl options input.
|
||||
%% If the input contains file content, save the files in the given dir.
|
||||
%% Returns ssl options for Erlang's ssl application.
|
||||
|
|
|
@ -346,8 +346,7 @@ pool_name(ResId) ->
|
|||
list_to_atom("webhook:" ++ str(ResId)).
|
||||
|
||||
get_ssl_opts(Opts, ResId) ->
|
||||
Dir = filename:join([emqx:get_env(data_dir), "rules", ResId]),
|
||||
[{ssl, true}, {ssl_opts, emqx_plugin_libs_ssl:save_files_return_opts(Opts, Dir)}].
|
||||
[{ssl, true}, {ssl_opts, emqx_plugin_libs_ssl:save_files_return_opts(Opts, "rules", ResId)}].
|
||||
|
||||
parse_host(Host) ->
|
||||
case inet:parse_address(Host) of
|
||||
|
|
Loading…
Reference in New Issue