Merge branch 'emq24'

This commit is contained in:
HuangDan 2018-05-11 13:34:13 +08:00
commit 0bcc692071
5 changed files with 25 additions and 17 deletions

View File

@ -1,6 +1,6 @@
PROJECT = emqttd
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

View File

@ -1,6 +1,6 @@
{application,emqttd,
[{description,"Erlang MQTT Broker"},
{vsn,"2.3.7"},
{vsn,"2.3.8"},
{modules,[]},
{registered,[emqttd_sup]},
{applications,[kernel,stdlib,gproc,lager,esockd,mochiweb,

View File

@ -30,7 +30,7 @@
-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,
listeners/1, vm/1, mnesia/1, trace/1, acl/1]).
@ -152,9 +152,7 @@ cluster(_) ->
{"cluster status", "Cluster status"}]).
%%--------------------------------------------------------------------
%% @doc Users usage
users(Args) -> emq_auth_username:cli(Args).
%% @doc ACL reload
acl(["reload"]) -> emqttd_access_control:reload_acl();
acl(_) -> ?USAGE([{"acl reload", "reload etc/acl.conf"}]).
@ -607,4 +605,3 @@ format(_, Val) ->
Val.
bin(S) -> iolist_to_binary(S).

View File

@ -99,7 +99,7 @@ list() ->
case emqttd:env(plugins_etc_dir) of
{ok, PluginsEtc} ->
CfgFiles = filelib:wildcard("*.{conf,config}", PluginsEtc),
Plugins = [plugin(CfgFile) || CfgFile <- CfgFiles],
Plugins = all_plugin_attrs(CfgFiles),
StartedApps = names(started_app),
lists:map(fun(Plugin = #mqtt_plugin{name = Name}) ->
case lists:member(Name, StartedApps) of
@ -111,12 +111,24 @@ list() ->
[]
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) ->
AppName = app_name(CfgFile),
{ok, Attrs} = application:get_all_key(AppName),
case application:get_all_key(AppName) of
{ok, Attrs} ->
Ver = proplists:get_value(vsn, Attrs, "0"),
Descr = proplists:get_value(description, Attrs, ""),
#mqtt_plugin{name = AppName, version = Ver, descr = Descr}.
#mqtt_plugin{name = AppName, version = Ver, descr = Descr};
_ -> not_found
end.
%% @doc Load a Plugin
-spec(load(atom()) -> ok | {error, term()}).
@ -269,4 +281,3 @@ write_loaded(AppNames) ->
lager:error("Open File ~p Error: ~p", [File, Error]),
{error, Error}
end.

View File

@ -510,7 +510,7 @@ handle_cast({resume, ClientId, ClientPid},
%% Clean Session: true -> false?
if
CleanSess =:= true ->
?LOG(error, "CleanSess changed to false.", [], State1),
?LOG(info, "CleanSess changed to false.", [], State1),
emqttd_sm:register_session(ClientId, false, info(State1));
CleanSess =:= false ->
ok