From 7ffdd95aa33d598a76f882c9b4e895379e39d17e Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 19 Aug 2022 11:10:05 +0800 Subject: [PATCH 1/2] chore: bind option support `:1883` style config see: https://github.com/emqx/emqx/pull/8571 --- apps/emqx/src/emqx_schema.erl | 4 ++++ .../src/emqx_mgmt_api_listeners.erl | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index ed9821eac..94ce36c9a 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -2162,8 +2162,12 @@ to_bar_separated_list(Str) -> %% - 127.0.0.1:1883 %% - ::1:1883 %% - [::1]:1883 +%% - :1883 +%% - :::1883 to_ip_port(Str) -> case split_ip_port(Str) of + {"", Port} -> + {ok, {{0, 0, 0, 0}, list_to_integer(Port)}}; {Ip, Port} -> PortVal = list_to_integer(Port), case inet:parse_address(Ip) of diff --git a/apps/emqx_management/src/emqx_mgmt_api_listeners.erl b/apps/emqx_management/src/emqx_mgmt_api_listeners.erl index 24fe710c7..31678e0f6 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_listeners.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_listeners.erl @@ -342,11 +342,18 @@ list_listeners(get, #{query_string := Query}) -> {200, listener_status_by_id(NodeL)}. crud_listeners_by_id(get, #{bindings := #{id := Id0}}) -> - Listeners = [ - Conf#{<<"id">> => Id, <<"type">> => Type} - || {Id, Type, Conf} <- emqx_listeners:list_raw(), - Id =:= Id0 - ], + Listeners = + [ + Conf#{ + <<"id">> => Id, + <<"type">> => Type, + <<"bind">> := iolist_to_binary( + emqx_listeners:format_bind(maps:get(<<"bind">>, Conf)) + ) + } + || {Id, Type, Conf} <- emqx_listeners:list_raw(), + Id =:= Id0 + ], case Listeners of [] -> {404, #{code => 'BAD_LISTENER_ID', message => ?LISTENER_NOT_FOUND}}; [L] -> {200, L} From f612908b176b9b192c09e9b4f5d586d60fef41e3 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 19 Aug 2022 11:15:19 +0800 Subject: [PATCH 2/2] chore: update changes --- CHANGES-5.0.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES-5.0.md b/CHANGES-5.0.md index 734b88515..885e0a4c1 100644 --- a/CHANGES-5.0.md +++ b/CHANGES-5.0.md @@ -13,6 +13,7 @@ * Updated `/nodes` API node_status from `Running/Stopped` to `running/stopped`. [#8642](https://github.com/emqx/emqx/pull/8642) * Improve handling of placeholder interpolation errors [#8635](https://github.com/emqx/emqx/pull/8635) * Better logging on unknown object IDs. [#8670](https://github.com/emqx/emqx/pull/8670) +* The bind option support `:1883` style. [#8758](https://github.com/emqx/emqx/pull/8758) # 5.0.4