Skip to content

Commit

Permalink
chore: check ekka proto dist module type when resolving node address
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesmg committed Sep 25, 2023
1 parent 5e40057 commit 806017e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion apps/emqx_machine/src/emqx_machine.erl
Expand Up @@ -195,7 +195,8 @@ do_check({Node, #{resolved_ips := [IP | _]} = Plan}) ->
node_to_ips(Node) ->
NodeBin0 = atom_to_binary(Node),
HostOrIP = re:replace(NodeBin0, <<"^.+@">>, <<"">>, [{return, list}]),
case inet:gethostbyname(HostOrIP, inet) of
AddressType = resolve_dist_address_type(),
case inet:gethostbyname(HostOrIP, AddressType) of
{ok, #hostent{h_addr_list = AddrList}} ->
AddrList;
_ ->
Expand All @@ -210,3 +211,18 @@ is_tcp_port_open(IP, Port) ->
_ ->
false
end.

resolve_dist_address_type() ->
ProtoDistStr = os:getenv("EKKA_PROTO_DIST_MOD", "inet_tcp"),
case ProtoDistStr of
"inet_tcp" ->
inet;
"inet6_tcp" ->
inet6;
"inet_tls" ->
inet;
"inet6_tls" ->
inet6;
_ ->
inet
end.
2 changes: 1 addition & 1 deletion apps/emqx_machine/test/emqx_machine_SUITE.erl
Expand Up @@ -170,7 +170,7 @@ t_open_ports_check(Config) ->
}
},
erpc:call(Core1, emqx_machine, open_ports_check, []),
#{core2 => Core2}
#{core2 => Core2, gen_rpc_port => GenRPCPort, ekka_port => EkkaPort}
),

ok.

0 comments on commit 806017e

Please sign in to comment.