From 65729cd640c28ded666594b16284a61c8341067a Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 29 Dec 2022 17:02:29 +0800 Subject: [PATCH 1/5] fix(clients): fix expiry_interval unit error It should be second not millisecond --- .../src/emqx_mgmt_api_clients.erl | 17 +++++------------ .../test/emqx_mgmt_api_clients_SUITE.erl | 6 +++++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_clients.erl b/apps/emqx_management/src/emqx_mgmt_api_clients.erl index bf025bfc7..8eb4b26e9 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_clients.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_clients.erl @@ -65,7 +65,6 @@ {<<"ip_address">>, ip}, {<<"conn_state">>, atom}, {<<"clean_start">>, atom}, - {<<"proto_name">>, binary}, {<<"proto_ver">>, integer}, {<<"like_clientid">>, binary}, {<<"like_username">>, binary}, @@ -145,14 +144,6 @@ schema("/clients") -> required => false, description => <<"Whether the client uses a new session">> })}, - {proto_name, - hoconsc:mk(hoconsc:enum(['MQTT', 'CoAP', 'LwM2M', 'MQTT-SN']), #{ - in => query, - required => false, - description => - <<"Client protocol name, ", - "the possible values are MQTT,CoAP,LwM2M,MQTT-SN">> - })}, {proto_ver, hoconsc:mk(binary(), #{ in => query, @@ -830,8 +821,6 @@ ms(ip_address, X) -> #{conninfo => #{peername => {X, '_'}}}; ms(clean_start, X) -> #{conninfo => #{clean_start => X}}; -ms(proto_name, X) -> - #{conninfo => #{proto_name => X}}; ms(proto_ver, X) -> #{conninfo => #{proto_ver => X}}; ms(connected_at, X) -> @@ -879,7 +868,8 @@ format_channel_info(WhichNode, {_, ClientInfo0, ClientStats}) -> ClientInfoMap2 = maps:put(node, Node, ClientInfoMap1), ClientInfoMap3 = maps:put(ip_address, IpAddress, ClientInfoMap2), ClientInfoMap4 = maps:put(port, Port, ClientInfoMap3), - ClientInfoMap = maps:put(connected, Connected, ClientInfoMap4), + ClientInfoMap5 = convert_expiry_interval_unit(ClientInfoMap4), + ClientInfoMap = maps:put(connected, Connected, ClientInfoMap5), RemoveList = [ @@ -949,6 +939,9 @@ peername_dispart({Addr, Port}) -> %% PortBinary = integer_to_binary(Port), {AddrBinary, Port}. +convert_expiry_interval_unit(ClientInfoMap = #{expiry_interval := Interval}) -> + ClientInfoMap#{expiry_interval := Interval div 1000}. + format_authz_cache({{PubSub, Topic}, {AuthzResult, Timestamp}}) -> #{ access => PubSub, diff --git a/apps/emqx_management/test/emqx_mgmt_api_clients_SUITE.erl b/apps/emqx_management/test/emqx_mgmt_api_clients_SUITE.erl index 8dd1dabfc..16ba99ad6 100644 --- a/apps/emqx_management/test/emqx_mgmt_api_clients_SUITE.erl +++ b/apps/emqx_management/test/emqx_mgmt_api_clients_SUITE.erl @@ -44,7 +44,10 @@ t_clients(_) -> AuthHeader = emqx_mgmt_api_test_util:auth_header_(), {ok, C1} = emqtt:start_link(#{ - username => Username1, clientid => ClientId1, proto_ver => v5 + username => Username1, + clientid => ClientId1, + proto_ver => v5, + properties => #{'Session-Expiry-Interval' => 120} }), {ok, _} = emqtt:connect(C1), {ok, C2} = emqtt:start_link(#{username => Username2, clientid => ClientId2}), @@ -70,6 +73,7 @@ t_clients(_) -> Client1Response = emqx_json:decode(Client1, [return_maps]), ?assertEqual(Username1, maps:get(<<"username">>, Client1Response)), ?assertEqual(ClientId1, maps:get(<<"clientid">>, Client1Response)), + ?assertEqual(120, maps:get(<<"expiry_interval">>, Client1Response)), %% delete /clients/:clientid kickout Client2Path = emqx_mgmt_api_test_util:api_path(["clients", binary_to_list(ClientId2)]), From ec51fcc834f9b352a9faebf543209234a3bcc3c2 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 29 Dec 2022 17:23:05 +0800 Subject: [PATCH 2/5] chore: update changes --- changes/v5.0.14-en.md | 9 +++++++++ changes/v5.0.14-zh.md | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 changes/v5.0.14-en.md create mode 100644 changes/v5.0.14-zh.md diff --git a/changes/v5.0.14-en.md b/changes/v5.0.14-en.md new file mode 100644 index 000000000..9e428f757 --- /dev/null +++ b/changes/v5.0.14-en.md @@ -0,0 +1,9 @@ +# v5.0.13 + +## Enhancements + + +## Bug fixes + +- Fix the expiry_interval fields of the clients HTTP API to measure in seconds [#9637](https://github.com/emqx/emqx/pull/9637). + diff --git a/changes/v5.0.14-zh.md b/changes/v5.0.14-zh.md new file mode 100644 index 000000000..08459d357 --- /dev/null +++ b/changes/v5.0.14-zh.md @@ -0,0 +1,8 @@ +# v5.0.14 + +## 增强 + +## 修复 + +- 修复 clients HTTP API 下的 expiry_interval 字段的时间单位为秒 [#9637](https://github.com/emqx/emqx/pull/9637)。 + From 5d55e3a7b3e95acc99ac61028afc272bd2ecdfc2 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 29 Dec 2022 17:23:45 +0800 Subject: [PATCH 3/5] chore: updage mgmt app vsn --- apps/emqx_management/src/emqx_management.app.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/emqx_management/src/emqx_management.app.src b/apps/emqx_management/src/emqx_management.app.src index 5df8fe4df..c0cb05401 100644 --- a/apps/emqx_management/src/emqx_management.app.src +++ b/apps/emqx_management/src/emqx_management.app.src @@ -2,7 +2,7 @@ {application, emqx_management, [ {description, "EMQX Management API and CLI"}, % strict semver, bump manually! - {vsn, "5.0.10"}, + {vsn, "5.0.11"}, {modules, []}, {registered, [emqx_management_sup]}, {applications, [kernel, stdlib, emqx_plugins, minirest, emqx]}, From e2e73e7c5937d5e69726585ffdf1893fd439007f Mon Sep 17 00:00:00 2001 From: JianBo He Date: Wed, 4 Jan 2023 11:15:36 +0800 Subject: [PATCH 4/5] chore: Update changes/v5.0.14-en.md Co-authored-by: Ivan Dyachkov --- changes/v5.0.14-en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/v5.0.14-en.md b/changes/v5.0.14-en.md index 9e428f757..7fef4c104 100644 --- a/changes/v5.0.14-en.md +++ b/changes/v5.0.14-en.md @@ -1,4 +1,4 @@ -# v5.0.13 +# v5.0.14 ## Enhancements From 9046913f9c83b97c67e97555b44810acf0bb5897 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 6 Jan 2023 10:37:21 +0800 Subject: [PATCH 5/5] chore: upgrade changes format --- changes/v5.0.14-en.md | 9 --------- changes/v5.0.14-zh.md | 8 -------- changes/v5.0.14/fix-9637.en.md | 1 + changes/v5.0.14/fix-9637.zh.md | 1 + 4 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 changes/v5.0.14-en.md delete mode 100644 changes/v5.0.14-zh.md create mode 100644 changes/v5.0.14/fix-9637.en.md create mode 100644 changes/v5.0.14/fix-9637.zh.md diff --git a/changes/v5.0.14-en.md b/changes/v5.0.14-en.md deleted file mode 100644 index 7fef4c104..000000000 --- a/changes/v5.0.14-en.md +++ /dev/null @@ -1,9 +0,0 @@ -# v5.0.14 - -## Enhancements - - -## Bug fixes - -- Fix the expiry_interval fields of the clients HTTP API to measure in seconds [#9637](https://github.com/emqx/emqx/pull/9637). - diff --git a/changes/v5.0.14-zh.md b/changes/v5.0.14-zh.md deleted file mode 100644 index 08459d357..000000000 --- a/changes/v5.0.14-zh.md +++ /dev/null @@ -1,8 +0,0 @@ -# v5.0.14 - -## 增强 - -## 修复 - -- 修复 clients HTTP API 下的 expiry_interval 字段的时间单位为秒 [#9637](https://github.com/emqx/emqx/pull/9637)。 - diff --git a/changes/v5.0.14/fix-9637.en.md b/changes/v5.0.14/fix-9637.en.md new file mode 100644 index 000000000..d93ed493c --- /dev/null +++ b/changes/v5.0.14/fix-9637.en.md @@ -0,0 +1 @@ +Fix the expiry_interval fields of the clients HTTP API to measure in seconds. diff --git a/changes/v5.0.14/fix-9637.zh.md b/changes/v5.0.14/fix-9637.zh.md new file mode 100644 index 000000000..8164a0bbf --- /dev/null +++ b/changes/v5.0.14/fix-9637.zh.md @@ -0,0 +1 @@ +修复 clients HTTP API 下的 expiry_interval 字段的时间单位为秒。