From e4c2715842e098e78a59c9ee32d8d89c47fda7e4 Mon Sep 17 00:00:00 2001 From: zhongwencool Date: Fri, 16 Sep 2022 15:36:17 +0800 Subject: [PATCH] fix: add ip to dashboard listener_on --- apps/emqx_management/src/emqx_mgmt.erl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt.erl b/apps/emqx_management/src/emqx_mgmt.erl index 948088f8e..c5062d477 100644 --- a/apps/emqx_management/src/emqx_mgmt.erl +++ b/apps/emqx_management/src/emqx_mgmt.erl @@ -458,7 +458,7 @@ list_listeners(Node) when Node =:= node() -> end, esockd:listeners()), Http = lists:map(fun({Protocol, Opts}) -> #{protocol => Protocol, - listen_on => proplists:get_value(port, Opts), + listen_on => format_http_bind(Opts), acceptors => maps:get( num_acceptors , proplists:get_value(transport_options, Opts, #{}), 0), max_conns => proplists:get_value(max_connections, Opts), @@ -528,7 +528,7 @@ delete_banned(Who) -> %%-------------------------------------------------------------------- -%% Telemtry API +%% Telemetry API %%-------------------------------------------------------------------- -ifndef(EMQX_ENTERPRISE). @@ -570,7 +570,7 @@ item(route, {Topic, Node}) -> #{topic => Topic, node => Node}. %%-------------------------------------------------------------------- -%% Internel Functions. +%% Internal Functions. %%-------------------------------------------------------------------- rpc_call(Node, Fun, Args) -> @@ -603,3 +603,10 @@ max_row_limit() -> application:get_env(?APP, max_row_limit, ?MAX_ROW_LIMIT). table_size(Tab) -> ets:info(Tab, size). + +format_http_bind(Opts) -> + Port = proplists:get_value(port, Opts), + case proplists:get_value(ip, Opts) of + undefined -> Port; + IP -> {IP, Port} + end.