chore(plugins): rm emqx-pks-file plugin
This commit is contained in:
parent
434beef3ad
commit
33036a1a91
|
@ -1,16 +0,0 @@
|
||||||
.eunit
|
|
||||||
deps
|
|
||||||
*.o
|
|
||||||
*.beam
|
|
||||||
*.plt
|
|
||||||
erl_crash.dump
|
|
||||||
ebin
|
|
||||||
rel/example_project
|
|
||||||
.concrete/DEV_MODE
|
|
||||||
.rebar
|
|
||||||
.erlang.mk/
|
|
||||||
data/
|
|
||||||
emqx_actorcloud_schema_parser.d
|
|
||||||
.DS_Store
|
|
||||||
_build
|
|
||||||
rebar.lock
|
|
|
@ -1,2 +0,0 @@
|
||||||
## EMQX TLS/DTLS PSK Plugin from file
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
psk.file.path = "{{ platform_etc_dir }}/psk.txt"
|
|
||||||
psk.file.delimiter = ":"
|
|
|
@ -1,2 +0,0 @@
|
||||||
client1:1234
|
|
||||||
client2:abcd
|
|
|
@ -1,10 +0,0 @@
|
||||||
%%-*- mode: erlang -*-
|
|
||||||
%% emqx_psk_file config mapping
|
|
||||||
|
|
||||||
{mapping, "psk.file.path", "emqx_psk_file.path", [
|
|
||||||
{datatype, string}
|
|
||||||
]}.
|
|
||||||
|
|
||||||
{mapping, "psk.file.delimiter", "emqx_psk_file.delimiter", [
|
|
||||||
{datatype, string}
|
|
||||||
]}.
|
|
|
@ -1,16 +0,0 @@
|
||||||
{deps, []}.
|
|
||||||
|
|
||||||
{edoc_opts, [{preprocess, true}]}.
|
|
||||||
{erl_opts, [warn_unused_vars,
|
|
||||||
warn_shadow_vars,
|
|
||||||
warn_unused_import,
|
|
||||||
warn_obsolete_guard,
|
|
||||||
debug_info,
|
|
||||||
{parse_transform}]}.
|
|
||||||
|
|
||||||
{xref_checks, [undefined_function_calls, undefined_functions,
|
|
||||||
locals_not_used, deprecated_function_calls,
|
|
||||||
warnings_as_errors, deprecated_functions]}.
|
|
||||||
{cover_enabled, true}.
|
|
||||||
{cover_opts, [verbose]}.
|
|
||||||
{cover_export_enabled, true}.
|
|
|
@ -1,14 +0,0 @@
|
||||||
{application, emqx_psk_file,
|
|
||||||
[{description,"EMQX PSK Plugin from File"},
|
|
||||||
{vsn, "4.3.1"}, % strict semver, bump manually!
|
|
||||||
{modules,[]},
|
|
||||||
{registered,[emqx_psk_file_sup]},
|
|
||||||
{applications,[kernel,stdlib]},
|
|
||||||
{mod,{emqx_psk_file_app,[]}},
|
|
||||||
{env, []},
|
|
||||||
{licenses, ["Apache-2.0"]},
|
|
||||||
{maintainers, ["EMQ X Team <contact@emqx.io>"]},
|
|
||||||
{links, [{"Homepage", "https://emqx.io/"},
|
|
||||||
{"Github", "https://github.com/emqx/emqx-psk-file"}
|
|
||||||
]}
|
|
||||||
]}.
|
|
|
@ -1,13 +0,0 @@
|
||||||
%% -*-: erlang -*-
|
|
||||||
{VSN,
|
|
||||||
[
|
|
||||||
{"4.3.0", [
|
|
||||||
{restart_application, emqx_psk_file}
|
|
||||||
]}
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{"4.3.0", [
|
|
||||||
{restart_application, emqx_psk_file}
|
|
||||||
]}
|
|
||||||
]
|
|
||||||
}.
|
|
|
@ -1,82 +0,0 @@
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%
|
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
%% you may not use this file except in compliance with the License.
|
|
||||||
%% You may obtain a copy of the License at
|
|
||||||
%%
|
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
%%
|
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
%% See the License for the specific language governing permissions and
|
|
||||||
%% limitations under the License.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
-module(emqx_psk_file).
|
|
||||||
|
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
|
||||||
-include_lib("emqx/include/logger.hrl").
|
|
||||||
|
|
||||||
-import(proplists, [get_value/2]).
|
|
||||||
|
|
||||||
-export([load/1, unload/0]).
|
|
||||||
|
|
||||||
%% Hooks functions
|
|
||||||
-export([on_psk_lookup/2]).
|
|
||||||
|
|
||||||
-define(TAB, ?MODULE).
|
|
||||||
-define(LF, 10).
|
|
||||||
|
|
||||||
-record(psk_entry, {psk_id :: binary(),
|
|
||||||
psk_str :: binary()}).
|
|
||||||
|
|
||||||
%% Called when the plugin application start
|
|
||||||
load(Env) ->
|
|
||||||
_ = ets:new(?TAB, [set, named_table, {keypos, #psk_entry.psk_id}]),
|
|
||||||
{ok, PskFile} = file:open(get_value(path, Env), [read, raw, binary, read_ahead]),
|
|
||||||
preload_psks(PskFile, bin(get_value(delimiter, Env))),
|
|
||||||
_ = file:close(PskFile),
|
|
||||||
emqx:hook('tls_handshake.psk_lookup', {?MODULE, on_psk_lookup, []}).
|
|
||||||
|
|
||||||
%% Called when the plugin application stop
|
|
||||||
unload() ->
|
|
||||||
emqx:unhook('tls_handshake.psk_lookup', {?MODULE, on_psk_lookup}).
|
|
||||||
|
|
||||||
on_psk_lookup(ClientPSKID, UserState) ->
|
|
||||||
case ets:lookup(?TAB, ClientPSKID) of
|
|
||||||
[#psk_entry{psk_str = PskStr}] ->
|
|
||||||
{stop, PskStr};
|
|
||||||
[] ->
|
|
||||||
{ok, UserState}
|
|
||||||
end.
|
|
||||||
|
|
||||||
preload_psks(FileHandler, Delimiter) ->
|
|
||||||
case file:read_line(FileHandler) of
|
|
||||||
{ok, Line} ->
|
|
||||||
case binary:split(Line, Delimiter) of
|
|
||||||
[Key, Rem] ->
|
|
||||||
ets:insert(?TAB, #psk_entry{psk_id = Key, psk_str = trim_lf(Rem)}),
|
|
||||||
preload_psks(FileHandler, Delimiter);
|
|
||||||
[Line] ->
|
|
||||||
?LOG(warning, "[~p] - Invalid line: ~p, delimiter: ~p", [?MODULE, Line, Delimiter])
|
|
||||||
end;
|
|
||||||
eof ->
|
|
||||||
?LOG(info, "[~p] - PSK file is preloaded", [?MODULE]);
|
|
||||||
{error, Reason} ->
|
|
||||||
?LOG(error, "[~p] - Read lines from PSK file: ~p", [?MODULE, Reason])
|
|
||||||
end.
|
|
||||||
|
|
||||||
bin(Str) when is_list(Str) -> list_to_binary(Str);
|
|
||||||
bin(Bin) when is_binary(Bin) -> Bin.
|
|
||||||
|
|
||||||
%% Trim the tailing LF
|
|
||||||
trim_lf(<<>>) -> <<>>;
|
|
||||||
trim_lf(Bin) ->
|
|
||||||
Size = byte_size(Bin),
|
|
||||||
case binary:at(Bin, Size-1) of
|
|
||||||
?LF -> binary_part(Bin, 0, Size-1);
|
|
||||||
_ -> Bin
|
|
||||||
end.
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%
|
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
%% you may not use this file except in compliance with the License.
|
|
||||||
%% You may obtain a copy of the License at
|
|
||||||
%%
|
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
%%
|
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
%% See the License for the specific language governing permissions and
|
|
||||||
%% limitations under the License.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
-module(emqx_psk_file_app).
|
|
||||||
|
|
||||||
-behaviour(application).
|
|
||||||
|
|
||||||
-emqx_plugin(?MODULE).
|
|
||||||
|
|
||||||
%% Application callbacks
|
|
||||||
-export([start/2, stop/1]).
|
|
||||||
|
|
||||||
start(_StartType, _StartArgs) ->
|
|
||||||
{ok, Sup} = emqx_psk_file_sup:start_link(),
|
|
||||||
_ = emqx_psk_file:load(
|
|
||||||
application:get_all_env(emqx_psk_file)),
|
|
||||||
{ok, Sup}.
|
|
||||||
|
|
||||||
stop(_State) ->
|
|
||||||
emqx_psk_file:unload().
|
|
|
@ -1,32 +0,0 @@
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%
|
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
%% you may not use this file except in compliance with the License.
|
|
||||||
%% You may obtain a copy of the License at
|
|
||||||
%%
|
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
%%
|
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
%% See the License for the specific language governing permissions and
|
|
||||||
%% limitations under the License.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
-module(emqx_psk_file_sup).
|
|
||||||
|
|
||||||
-behaviour(supervisor).
|
|
||||||
|
|
||||||
%% API
|
|
||||||
-export([start_link/0]).
|
|
||||||
|
|
||||||
%% Supervisor callbacks
|
|
||||||
-export([init/1]).
|
|
||||||
|
|
||||||
start_link() ->
|
|
||||||
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
|
|
||||||
|
|
||||||
init([]) ->
|
|
||||||
{ok, { {one_for_one, 0, 1}, []} }.
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
%% Copyright (c) 2020-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
||||||
%%
|
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
%% you may not use this file except in compliance with the License.
|
|
||||||
%% You may obtain a copy of the License at
|
|
||||||
%%
|
|
||||||
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
%%
|
|
||||||
%% Unless required by applicable law or agreed to in writing, software
|
|
||||||
%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
%% See the License for the specific language governing permissions and
|
|
||||||
%% limitations under the License.
|
|
||||||
%%--------------------------------------------------------------------
|
|
||||||
|
|
||||||
-module(emqx_psk_file_SUITE).
|
|
||||||
-compile(nowarn_export_all).
|
|
||||||
-compile(export_all).
|
|
||||||
|
|
||||||
all() -> [].
|
|
||||||
|
|
||||||
groups() ->
|
|
||||||
[].
|
|
|
@ -297,7 +297,6 @@ relx_plugin_apps_per_rel(cloud) ->
|
||||||
, emqx_exhook
|
, emqx_exhook
|
||||||
, emqx_exproto
|
, emqx_exproto
|
||||||
, emqx_prometheus
|
, emqx_prometheus
|
||||||
, emqx_psk_file
|
|
||||||
];
|
];
|
||||||
relx_plugin_apps_per_rel(edge) ->
|
relx_plugin_apps_per_rel(edge) ->
|
||||||
[].
|
[].
|
||||||
|
@ -355,7 +354,6 @@ etc_overlay(ReleaseType) ->
|
||||||
|
|
||||||
extra_overlay(cloud) ->
|
extra_overlay(cloud) ->
|
||||||
[ {copy,"{{base_dir}}/lib/emqx_lwm2m/lwm2m_xml","etc/"}
|
[ {copy,"{{base_dir}}/lib/emqx_lwm2m/lwm2m_xml","etc/"}
|
||||||
, {copy, "{{base_dir}}/lib/emqx_psk_file/etc/psk.txt", "etc/psk.txt"}
|
|
||||||
];
|
];
|
||||||
extra_overlay(edge) ->
|
extra_overlay(edge) ->
|
||||||
[].
|
[].
|
||||||
|
|
|
@ -44,7 +44,6 @@ edge_excludes() ->
|
||||||
, emqx_exhook
|
, emqx_exhook
|
||||||
, emqx_exproto
|
, emqx_exproto
|
||||||
, emqx_prometheus
|
, emqx_prometheus
|
||||||
, emqx_psk_file
|
|
||||||
].
|
].
|
||||||
|
|
||||||
base_deps() ->
|
base_deps() ->
|
||||||
|
|
Loading…
Reference in New Issue