From f900e4ea3f5bdbb6a4c7c51675d48e096b5d21f6 Mon Sep 17 00:00:00 2001 From: DDDHuang <44492639+DDDHuang@users.noreply.github.com> Date: Wed, 1 Jun 2022 15:35:09 +0800 Subject: [PATCH] feat: add rpc server listener bind ip config --- etc/emqx.conf | 11 ++++++++++- priv/emqx.schema | 17 +++++++++++++++++ rebar.config | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index 858079d15..a4892c610 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -352,7 +352,16 @@ rpc.async_batch_size = 256 ## Defaults to `stateless`. rpc.port_discovery = stateless -rpc.tcp_server_ip = 0.0.0.0 +## If the host of an Erlang node has many network interfaces, +## this parameter specifies which one for RPC server to listen on. +## For the type definition of ip_address(), see inet(3). +## +## See: http://www.erlang.org/doc/man/kernel_app.html +## +## Value: IP Address, [0-255].[0-255].[0-255].[0-255] +## Default: 0.0.0.0 +## 0.0.0.0 means all network interfaces. +#rpc.tcp_server_ip = 0.0.0.0 ## TCP port number for RPC server to listen on. ## diff --git a/priv/emqx.schema b/priv/emqx.schema index e5bd24633..b4f456f36 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -406,6 +406,23 @@ end}. {datatype, integer} ]}. +%% RPC server, network interface. +{mapping, "rpc.tcp_server_ip", "gen_rpc.socket_ip", [ + {default, "0.0.0.0"}, + {datatype, string} +]}. + +{translation, "gen_rpc.socket_ip", +fun(Conf) -> + Addr = cuttlefish:conf_get("rpc.tcp_server_ip", Conf, "0.0.0.0"), + case inet:parse_address(Addr) of + {ok, IP} -> + IP; + _ -> + error({bad_gen_rpc_socket_ip, Addr}) + end +end}. + %% Number of tcp connections when connecting to RPC server {mapping, "rpc.tcp_client_num", "gen_rpc.tcp_client_num", [ {default, 0}, diff --git a/rebar.config b/rebar.config index 2307f3620..4288bcd84 100644 --- a/rebar.config +++ b/rebar.config @@ -46,7 +46,7 @@ , {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.8.2"}}} , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.8.5"}}} , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.8.1.10"}}} - , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} + , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.2"}}} , {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.3.6"}}} , {minirest, {git, "https://github.com/emqx/minirest", {tag, "0.3.7"}}} , {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}