From 1f077009307b84051a8406bc8ca33def0852ea33 Mon Sep 17 00:00:00 2001 From: terry-xiaoyu <506895667@qq.com> Date: Sat, 16 May 2020 08:48:05 +0800 Subject: [PATCH 1/8] Print helpful messages when no commands available --- src/emqx_ctl.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index 4b6c375d1..d42862fc1 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -125,9 +125,15 @@ get_commands() -> [{Cmd, M, F} || {{_Seq, Cmd}, {M, F}, _Opts} <- ets:tab2list(?CMD_TAB)]. help() -> - print("Usage: ~s~n", [?MODULE]), - [begin print("~110..-s~n", [""]), Mod:Cmd(usage) end - || {_, {Mod, Cmd}, _} <- ets:tab2list(?CMD_TAB)]. + case ets:tab2list(?CMD_TAB) of + [] -> + print("No commands available, make sure you have plugin emqx_management started.~n"); + Cmds -> + print("Usage: ~s~n", [?MODULE]), + list:foreach(fun({_, {Mod, Cmd}, _}) -> + print("~110..-s~n", [""]), Mod:Cmd(usage) + end, Cmds) + end. -spec(print(io:format()) -> ok). print(Msg) -> From ce180ca38f3c1e20011d5b28a1db53a68f05392b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=A5=87=E6=80=AA?= Date: Tue, 19 May 2020 10:05:35 +0800 Subject: [PATCH 2/8] Update weekly-digest.yml chore(weekly-digest): change publishDay --- .github/weekly-digest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/weekly-digest.yml b/.github/weekly-digest.yml index 6d4ba7e83..401ea7638 100644 --- a/.github/weekly-digest.yml +++ b/.github/weekly-digest.yml @@ -1,7 +1,7 @@ # Configuration for weekly-digest - https://github.com/apps/weekly-digest -publishDay: sun +publishDay: monday canPublishIssues: true canPublishPullRequests: true canPublishContributors: true canPublishStargazers: true -canPublishCommits: true \ No newline at end of file +canPublishCommits: true From 18ae15ef9a25bb617f4551ea718eb9505b271f30 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 21 May 2020 17:51:22 +0800 Subject: [PATCH 3/8] Fix typos --- src/emqx_ctl.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index d42862fc1..cb36340ab 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -130,7 +130,7 @@ help() -> print("No commands available, make sure you have plugin emqx_management started.~n"); Cmds -> print("Usage: ~s~n", [?MODULE]), - list:foreach(fun({_, {Mod, Cmd}, _}) -> + lists:foreach(fun({_, {Mod, Cmd}, _}) -> print("~110..-s~n", [""]), Mod:Cmd(usage) end, Cmds) end. From 639d0ca25e11a88d27d316bf40c293959dda9392 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 22 May 2020 09:27:23 +0800 Subject: [PATCH 4/8] Upgrade ekka to 0.7.3 --- rebar.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 4716a29da..50d430c44 100644 --- a/rebar.config +++ b/rebar.config @@ -5,7 +5,7 @@ {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.4"}}}, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.7.1"}}}, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.6.1"}}}, - {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.7.2"}}}, + {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.7.3"}}}, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.4.1"}}}, {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}} ]}. From 361730558fb69e694d8a8e25c58b4a811f9f0c8b Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 22 May 2020 10:09:52 +0800 Subject: [PATCH 5/8] Check xref --- .github/workflows/run_test_case.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_test_case.yaml b/.github/workflows/run_test_case.yaml index 7de8efd8c..df0f622ea 100644 --- a/.github/workflows/run_test_case.yaml +++ b/.github/workflows/run_test_case.yaml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v1 - name: Run tests run: | + make xref make eunit make ct make cover From 83b1f3e6c8c4d40a3afdba418356763bacfc62e1 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Thu, 21 May 2020 16:37:46 +0800 Subject: [PATCH 6/8] Fix unexpected packet before connected --- src/emqx_channel.erl | 9 +++++++-- test/emqx_channel_SUITE.erl | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index 59f8a0cba..be8a1f572 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -250,8 +250,10 @@ handle_in(Packet = ?AUTH_PACKET(?RC_CONTINUE_AUTHENTICATION, _Properties), Chann case ConnState of connecting -> process_connect(NProperties, ensure_connected(NChannel)); + connected -> + handle_out(auth, {?RC_SUCCESS, NProperties}, NChannel); _ -> - handle_out(auth, {?RC_SUCCESS, NProperties}, NChannel) + handle_out(disconnect, ?RC_PROTOCOL_ERROR, Channel) end; {continue, NProperties, NChannel} -> handle_out(auth, {?RC_CONTINUE_AUTHENTICATION, NProperties}, NChannel); @@ -259,7 +261,7 @@ handle_in(Packet = ?AUTH_PACKET(?RC_CONTINUE_AUTHENTICATION, _Properties), Chann handle_out(connack, NReasonCode, NChannel) end; -handle_in(Packet = ?AUTH_PACKET(?RC_RE_AUTHENTICATE, _Properties), Channel) -> +handle_in(Packet = ?AUTH_PACKET(?RC_RE_AUTHENTICATE, _Properties), Channel = #channel{conn_state = connected}) -> case enhanced_auth(Packet, Channel) of {ok, NProperties, NChannel} -> handle_out(auth, {?RC_SUCCESS, NProperties}, NChannel); @@ -269,6 +271,9 @@ handle_in(Packet = ?AUTH_PACKET(?RC_RE_AUTHENTICATE, _Properties), Channel) -> handle_out(disconnect, NReasonCode, NChannel) end; +handle_in(?PACKET(_), Channel = #channel{conn_state = ConnState}) when ConnState =/= connected -> + handle_out(disconnect, ?RC_PROTOCOL_ERROR, Channel); + handle_in(Packet = ?PUBLISH_PACKET(_QoS), Channel) -> case emqx_packet:check(Packet) of ok -> process_publish(Packet, Channel); diff --git a/test/emqx_channel_SUITE.erl b/test/emqx_channel_SUITE.erl index 0bddae09d..086ff557e 100644 --- a/test/emqx_channel_SUITE.erl +++ b/test/emqx_channel_SUITE.erl @@ -112,6 +112,12 @@ t_handle_in_unexpected_connect_packet(_) -> {ok, [{outgoing, Packet}, {close, protocol_error}], Channel} = emqx_channel:handle_in(?CONNECT_PACKET(connpkt()), Channel). +t_handle_in_unexpected_packet(_) -> + Channel = emqx_channel:set_field(conn_state, idle, channel()), + Packet = ?DISCONNECT_PACKET(?RC_PROTOCOL_ERROR), + {ok, [{outgoing, Packet}, {close, protocol_error}], Channel} = + emqx_channel:handle_in(?PUBLISH_PACKET(?QOS_0), Channel). + t_handle_in_connect_auth_failed(_) -> ConnPkt = #mqtt_packet_connect{ proto_name = <<"MQTT">>, From 59f95f8421f6ede6e0d677a8bf7c483565b5960a Mon Sep 17 00:00:00 2001 From: terry-xiaoyu <506895667@qq.com> Date: Sat, 23 May 2020 09:41:25 +0800 Subject: [PATCH 7/8] Helpful message when no commands available --- src/emqx_ctl.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emqx_ctl.erl b/src/emqx_ctl.erl index cb36340ab..4abe0ebf3 100644 --- a/src/emqx_ctl.erl +++ b/src/emqx_ctl.erl @@ -127,7 +127,7 @@ get_commands() -> help() -> case ets:tab2list(?CMD_TAB) of [] -> - print("No commands available, make sure you have plugin emqx_management started.~n"); + print("No commands available.~n"); Cmds -> print("Usage: ~s~n", [?MODULE]), lists:foreach(fun({_, {Mod, Cmd}, _}) -> From 9a7dd4579eea285cc0a9e53579230efb03df73be Mon Sep 17 00:00:00 2001 From: turtleDeng Date: Sat, 23 May 2020 10:04:59 +0800 Subject: [PATCH 8/8] Update run_test_case.yaml --- .github/workflows/run_test_case.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_test_case.yaml b/.github/workflows/run_test_case.yaml index df0f622ea..8bb918294 100644 --- a/.github/workflows/run_test_case.yaml +++ b/.github/workflows/run_test_case.yaml @@ -16,8 +16,11 @@ jobs: - name: Run tests run: | make xref + rm -f rebar.lock make eunit + rm -f rebar.lock make ct + rm -f rebar.lock make cover - name: Coveralls env: