Merge branch 'emq24'
This commit is contained in:
commit
0bcc692071
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PROJECT = emqttd
|
PROJECT = emqttd
|
||||||
PROJECT_DESCRIPTION = Erlang MQTT Broker
|
PROJECT_DESCRIPTION = Erlang MQTT Broker
|
||||||
PROJECT_VERSION = 2.3.6
|
PROJECT_VERSION = 2.3.8
|
||||||
|
|
||||||
DEPS = goldrush gproc lager esockd ekka mochiweb pbkdf2 lager_syslog bcrypt clique jsx
|
DEPS = goldrush gproc lager esockd ekka mochiweb pbkdf2 lager_syslog bcrypt clique jsx
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application,emqttd,
|
{application,emqttd,
|
||||||
[{description,"Erlang MQTT Broker"},
|
[{description,"Erlang MQTT Broker"},
|
||||||
{vsn,"2.3.7"},
|
{vsn,"2.3.8"},
|
||||||
{modules,[]},
|
{modules,[]},
|
||||||
{registered,[emqttd_sup]},
|
{registered,[emqttd_sup]},
|
||||||
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
-export([load/0]).
|
-export([load/0]).
|
||||||
|
|
||||||
-export([status/1, broker/1, cluster/1, users/1, clients/1, sessions/1,
|
-export([status/1, broker/1, cluster/1, clients/1, sessions/1,
|
||||||
routes/1, topics/1, subscriptions/1, plugins/1, bridges/1,
|
routes/1, topics/1, subscriptions/1, plugins/1, bridges/1,
|
||||||
listeners/1, vm/1, mnesia/1, trace/1, acl/1]).
|
listeners/1, vm/1, mnesia/1, trace/1, acl/1]).
|
||||||
|
|
||||||
|
@ -152,9 +152,7 @@ cluster(_) ->
|
||||||
{"cluster status", "Cluster status"}]).
|
{"cluster status", "Cluster status"}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% @doc Users usage
|
%% @doc ACL reload
|
||||||
|
|
||||||
users(Args) -> emq_auth_username:cli(Args).
|
|
||||||
|
|
||||||
acl(["reload"]) -> emqttd_access_control:reload_acl();
|
acl(["reload"]) -> emqttd_access_control:reload_acl();
|
||||||
acl(_) -> ?USAGE([{"acl reload", "reload etc/acl.conf"}]).
|
acl(_) -> ?USAGE([{"acl reload", "reload etc/acl.conf"}]).
|
||||||
|
@ -460,7 +458,7 @@ trace_on(Who, Name, LogFile) ->
|
||||||
|
|
||||||
trace_off(Who, Name) ->
|
trace_off(Who, Name) ->
|
||||||
case emqttd_trace:stop_trace({Who, iolist_to_binary(Name)}) of
|
case emqttd_trace:stop_trace({Who, iolist_to_binary(Name)}) of
|
||||||
ok ->
|
ok ->
|
||||||
?PRINT("stop tracing ~s ~s successfully.~n", [Who, Name]);
|
?PRINT("stop tracing ~s ~s successfully.~n", [Who, Name]);
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
?PRINT("stop tracing ~s ~s error: ~p.~n", [Who, Name, Error])
|
?PRINT("stop tracing ~s ~s error: ~p.~n", [Who, Name, Error])
|
||||||
|
@ -607,4 +605,3 @@ format(_, Val) ->
|
||||||
Val.
|
Val.
|
||||||
|
|
||||||
bin(S) -> iolist_to_binary(S).
|
bin(S) -> iolist_to_binary(S).
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ list() ->
|
||||||
case emqttd:env(plugins_etc_dir) of
|
case emqttd:env(plugins_etc_dir) of
|
||||||
{ok, PluginsEtc} ->
|
{ok, PluginsEtc} ->
|
||||||
CfgFiles = filelib:wildcard("*.{conf,config}", PluginsEtc),
|
CfgFiles = filelib:wildcard("*.{conf,config}", PluginsEtc),
|
||||||
Plugins = [plugin(CfgFile) || CfgFile <- CfgFiles],
|
Plugins = all_plugin_attrs(CfgFiles),
|
||||||
StartedApps = names(started_app),
|
StartedApps = names(started_app),
|
||||||
lists:map(fun(Plugin = #mqtt_plugin{name = Name}) ->
|
lists:map(fun(Plugin = #mqtt_plugin{name = Name}) ->
|
||||||
case lists:member(Name, StartedApps) of
|
case lists:member(Name, StartedApps) of
|
||||||
|
@ -111,12 +111,24 @@ list() ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
all_plugin_attrs(CfgFiles) ->
|
||||||
|
lists:foldl(
|
||||||
|
fun(CfgFile, Acc) ->
|
||||||
|
case plugin(CfgFile) of
|
||||||
|
not_found -> Acc;
|
||||||
|
Attr -> Acc ++ [Attr]
|
||||||
|
end
|
||||||
|
end, [], CfgFiles).
|
||||||
|
|
||||||
plugin(CfgFile) ->
|
plugin(CfgFile) ->
|
||||||
AppName = app_name(CfgFile),
|
AppName = app_name(CfgFile),
|
||||||
{ok, Attrs} = application:get_all_key(AppName),
|
case application:get_all_key(AppName) of
|
||||||
Ver = proplists:get_value(vsn, Attrs, "0"),
|
{ok, Attrs} ->
|
||||||
Descr = proplists:get_value(description, Attrs, ""),
|
Ver = proplists:get_value(vsn, Attrs, "0"),
|
||||||
#mqtt_plugin{name = AppName, version = Ver, descr = Descr}.
|
Descr = proplists:get_value(description, Attrs, ""),
|
||||||
|
#mqtt_plugin{name = AppName, version = Ver, descr = Descr};
|
||||||
|
_ -> not_found
|
||||||
|
end.
|
||||||
|
|
||||||
%% @doc Load a Plugin
|
%% @doc Load a Plugin
|
||||||
-spec(load(atom()) -> ok | {error, term()}).
|
-spec(load(atom()) -> ok | {error, term()}).
|
||||||
|
@ -169,7 +181,7 @@ find_plugin(Name) ->
|
||||||
find_plugin(Name, list()).
|
find_plugin(Name, list()).
|
||||||
|
|
||||||
find_plugin(Name, Plugins) ->
|
find_plugin(Name, Plugins) ->
|
||||||
lists:keyfind(Name, 2, Plugins).
|
lists:keyfind(Name, 2, Plugins).
|
||||||
|
|
||||||
%% @doc UnLoad a Plugin
|
%% @doc UnLoad a Plugin
|
||||||
-spec(unload(atom()) -> ok | {error, term()}).
|
-spec(unload(atom()) -> ok | {error, term()}).
|
||||||
|
@ -192,7 +204,7 @@ unload_plugin(App, Persistent) ->
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
stop_app(App) ->
|
stop_app(App) ->
|
||||||
case application:stop(App) of
|
case application:stop(App) of
|
||||||
ok ->
|
ok ->
|
||||||
|
@ -269,4 +281,3 @@ write_loaded(AppNames) ->
|
||||||
lager:error("Open File ~p Error: ~p", [File, Error]),
|
lager:error("Open File ~p Error: ~p", [File, Error]),
|
||||||
{error, Error}
|
{error, Error}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -510,7 +510,7 @@ handle_cast({resume, ClientId, ClientPid},
|
||||||
%% Clean Session: true -> false?
|
%% Clean Session: true -> false?
|
||||||
if
|
if
|
||||||
CleanSess =:= true ->
|
CleanSess =:= true ->
|
||||||
?LOG(error, "CleanSess changed to false.", [], State1),
|
?LOG(info, "CleanSess changed to false.", [], State1),
|
||||||
emqttd_sm:register_session(ClientId, false, info(State1));
|
emqttd_sm:register_session(ClientId, false, info(State1));
|
||||||
CleanSess =:= false ->
|
CleanSess =:= false ->
|
||||||
ok
|
ok
|
||||||
|
|
Loading…
Reference in New Issue