From d7e46b367eefdc93ab8ebe50220763054fb8f1e1 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Thu, 14 Jun 2018 09:56:49 +0800 Subject: [PATCH 1/5] fix bug for issue#1614 --- src/emqttd_session.erl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/emqttd_session.erl b/src/emqttd_session.erl index 4d920fffb..0d27a1cbd 100644 --- a/src/emqttd_session.erl +++ b/src/emqttd_session.erl @@ -386,6 +386,7 @@ handle_cast({subscribe, _From, TopicTable, AckFun}, SubMap1 = case maps:find(Topic, SubMap) of {ok, NewQos} -> + emqttd_hooks:run('session.subscribed', [ClientId, Username], {Topic, Opts}), ?LOG(warning, "Duplicated subscribe: ~s, qos = ~w", [Topic, NewQos], State), SubMap; {ok, OldQos} -> From cad0f1a8588eadc7fd68e6ef1546124251220224 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Sat, 30 Jun 2018 22:23:35 +0800 Subject: [PATCH 2/5] fix bugs about rest api which getting config lists cause errors --- priv/emq.schema | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/emq.schema b/priv/emq.schema index a06d838ed..6ddf9f2a7 100644 --- a/priv/emq.schema +++ b/priv/emq.schema @@ -439,7 +439,7 @@ end}. ConsoleLogLevel = cuttlefish:conf_get("log.console.level", Conf), ConsoleLogFile = cuttlefish:conf_get("log.console.file", Conf), - ConsoleHandler = {lager_console_backend, [ConsoleLogLevel]}, + ConsoleHandler = {lager_console_backend, ConsoleLogLevel}, ConsoleFileHandler = {lager_file_backend, [{file, ConsoleLogFile}, {level, ConsoleLogLevel}, {size, cuttlefish:conf_get("log.console.size", Conf)}, From 9433e563fb69bf2b99be91a8839aa3e5ca738e84 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Thu, 5 Jul 2018 19:19:27 +0800 Subject: [PATCH 3/5] support to start listeners when emqttd is running --- src/emqttd_app.erl | 1 - src/emqttd_cli.erl | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/emqttd_app.erl b/src/emqttd_app.erl index f14229715..ab2a90216 100644 --- a/src/emqttd_app.erl +++ b/src/emqttd_app.erl @@ -239,4 +239,3 @@ merge_sockopts_test_() -> ?_assert(merge_sockopts(Opts) == [{sockopts, ?MQTT_SOCKOPTS} | Opts]). -endif. - diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index ca5534eb2..b68b7a9cf 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -479,11 +479,17 @@ listeners([]) -> end, Info) end, esockd:listeners()); +listeners(["start", Proto, ListenOn]) -> + ListenOn1 = listenon_tokens(ListenOn), + case emqttd_app:start_listener({list_to_atom(Proto), ListenOn1, []}) of + {ok, _Pid} -> + io:format("Start ~s listener on ~s successfully.~n", [Proto, ListenOn]); + {error, Error} -> + io:format("Failed to Start ~s listener on ~s, error:~p~n", [Proto, ListenOn, Error]) + end; + listeners(["restart", Proto, ListenOn]) -> - ListenOn1 = case string:tokens(ListenOn, ":") of - [Port] -> list_to_integer(Port); - [IP, Port] -> {IP, list_to_integer(Port)} - end, + ListenOn1 = listenon_tokens(ListenOn), case emqttd_app:restart_listener({list_to_atom(Proto), ListenOn1, []}) of {ok, _Pid} -> io:format("Restart ~s listener on ~s successfully.~n", [Proto, ListenOn]); @@ -492,10 +498,7 @@ listeners(["restart", Proto, ListenOn]) -> end; listeners(["stop", Proto, ListenOn]) -> - ListenOn1 = case string:tokens(ListenOn, ":") of - [Port] -> list_to_integer(Port); - [IP, Port] -> {IP, list_to_integer(Port)} - end, + ListenOn1 = listenon_tokens(ListenOn), case emqttd_app:stop_listener({list_to_atom(Proto), ListenOn1, []}) of ok -> io:format("Stop ~s listener on ~s successfully.~n", [Proto, ListenOn]); @@ -605,3 +608,9 @@ format(_, Val) -> Val. bin(S) -> iolist_to_binary(S). + +listenon_tokens(ListenOn) -> + case string:tokens(ListenOn, ":") of + [Port] -> {"0.0.0.0", list_to_integer(Port)}; + [IP, Port] -> {IP, list_to_integer(Port)} + end. From 4aa50f0f6e26049f31bdfaa82f89d419dde36b54 Mon Sep 17 00:00:00 2001 From: Gilbert Wong Date: Fri, 6 Jul 2018 17:16:49 +0800 Subject: [PATCH 4/5] Change listenon_tokens to parse_listenon --- src/emqttd_app.erl | 1 + src/emqttd_cli.erl | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/emqttd_app.erl b/src/emqttd_app.erl index ab2a90216..9853c488e 100644 --- a/src/emqttd_app.erl +++ b/src/emqttd_app.erl @@ -203,6 +203,7 @@ merge_sockopts(Options) -> %% @doc Stop Listeners stop_listeners() -> lists:foreach(fun stop_listener/1, emqttd:env(listeners, [])). + %% @private stop_listener({tcp, ListenOn, _Opts}) -> esockd:close('mqtt:tcp', ListenOn); diff --git a/src/emqttd_cli.erl b/src/emqttd_cli.erl index b68b7a9cf..32a0eb5a0 100644 --- a/src/emqttd_cli.erl +++ b/src/emqttd_cli.erl @@ -480,8 +480,7 @@ listeners([]) -> end, esockd:listeners()); listeners(["start", Proto, ListenOn]) -> - ListenOn1 = listenon_tokens(ListenOn), - case emqttd_app:start_listener({list_to_atom(Proto), ListenOn1, []}) of + case emqttd_app:start_listener({list_to_atom(Proto), parse_listenon(ListenOn), []}) of {ok, _Pid} -> io:format("Start ~s listener on ~s successfully.~n", [Proto, ListenOn]); {error, Error} -> @@ -489,8 +488,7 @@ listeners(["start", Proto, ListenOn]) -> end; listeners(["restart", Proto, ListenOn]) -> - ListenOn1 = listenon_tokens(ListenOn), - case emqttd_app:restart_listener({list_to_atom(Proto), ListenOn1, []}) of + case emqttd_app:restart_listener({list_to_atom(Proto), parse_listenon(ListenOn), []}) of {ok, _Pid} -> io:format("Restart ~s listener on ~s successfully.~n", [Proto, ListenOn]); {error, Error} -> @@ -498,8 +496,7 @@ listeners(["restart", Proto, ListenOn]) -> end; listeners(["stop", Proto, ListenOn]) -> - ListenOn1 = listenon_tokens(ListenOn), - case emqttd_app:stop_listener({list_to_atom(Proto), ListenOn1, []}) of + case emqttd_app:stop_listener({list_to_atom(Proto), parse_listenon(ListenOn), []}) of ok -> io:format("Stop ~s listener on ~s successfully.~n", [Proto, ListenOn]); {error, Error} -> @@ -609,8 +606,8 @@ format(_, Val) -> bin(S) -> iolist_to_binary(S). -listenon_tokens(ListenOn) -> +parse_listenon(ListenOn) -> case string:tokens(ListenOn, ":") of - [Port] -> {"0.0.0.0", list_to_integer(Port)}; + [Port] -> list_to_integer(Port); [IP, Port] -> {IP, list_to_integer(Port)} end. From d191ef03032a449cde5f331c07a19981728301e8 Mon Sep 17 00:00:00 2001 From: turtled Date: Fri, 20 Jul 2018 16:21:40 +0800 Subject: [PATCH 5/5] Version 2.3.11 --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c257186f4..e69eb1f4b 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,21 @@ PROJECT = emqttd PROJECT_DESCRIPTION = Erlang MQTT Broker -PROJECT_VERSION = 2.3.10 +PROJECT_VERSION = 2.3.11 DEPS = goldrush gproc lager esockd ekka mochiweb pbkdf2 lager_syslog bcrypt clique jsx dep_goldrush = git https://github.com/basho/goldrush 0.1.9 -dep_gproc = git https://github.com/uwiger/gproc +dep_gproc = git https://github.com/uwiger/gproc 0.8.0 dep_getopt = git https://github.com/jcomellas/getopt v0.8.2 -dep_lager = git https://github.com/basho/lager master +dep_lager = git https://github.com/basho/lager 3.2.4 dep_esockd = git https://github.com/emqtt/esockd v5.2.2 dep_ekka = git https://github.com/emqtt/ekka v0.2.3 dep_mochiweb = git https://github.com/emqtt/mochiweb v4.2.2 dep_pbkdf2 = git https://github.com/emqtt/pbkdf2 2.0.1 -dep_lager_syslog = git https://github.com/basho/lager_syslog -dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt master -dep_clique = git https://github.com/emqtt/clique -dep_jsx = git https://github.com/talentdeficit/jsx +dep_lager_syslog = git https://github.com/basho/lager_syslog 3.0.1 +dep_bcrypt = git https://github.com/smarkets/erlang-bcrypt 0.5.0.3 +dep_clique = git https://github.com/emqtt/clique v0.3.10 +dep_jsx = git https://github.com/talentdeficit/jsx v2.8.3 ERLC_OPTS += +debug_info ERLC_OPTS += +'{parse_transform, lager_transform}' @@ -23,7 +23,7 @@ ERLC_OPTS += +'{parse_transform, lager_transform}' NO_AUTOPATCH = cuttlefish BUILD_DEPS = cuttlefish -dep_cuttlefish = git https://github.com/emqtt/cuttlefish +dep_cuttlefish = git https://github.com/emqtt/cuttlefish v2.0.11 TEST_DEPS = emqttc emq_dashboard dep_emqttc = git https://github.com/emqtt/emqttc