Skip to content

Commit

Permalink
Check for dist_blocker in mongoose_epmd
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Mar 5, 2024
1 parent 3041e11 commit db689ba
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/mongoose_epmd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,22 @@ open(A) -> erl_epmd:open(A).
open(A, B) -> erl_epmd:open(A, B).

address_please(Name, Host, AddressFamily) ->
Node = list_to_binary(Name ++ "@" ++ Host),
case lookup_ip(Node) of
NodeString = Name ++ "@" ++ Host,
NodeAtom = list_to_atom(NodeString),
NodeBin = list_to_binary(NodeString),
try mongoose_dist_blocker:is_blocked(NodeAtom) of
true ->
%% Do not create connections if they would be rejected by dist_blocker anyway
{error, node_blocked};

Check warning on line 61 in src/mongoose_epmd.erl

View check run for this annotation

Codecov / codecov/patch

src/mongoose_epmd.erl#L61

Added line #L61 was not covered by tests
false ->
do_address_please(NodeBin, Host, AddressFamily)
catch _:_ ->
%% Ignore if dist_blocker is not loaded
do_address_please(NodeBin, Host, AddressFamily)

Check warning on line 66 in src/mongoose_epmd.erl

View check run for this annotation

Codecov / codecov/patch

src/mongoose_epmd.erl#L66

Added line #L66 was not covered by tests
end.

do_address_please(NodeBin, Host, AddressFamily) ->
case lookup_ip(NodeBin) of
{ok, _IP} = Res ->
Res;
_ ->
Expand Down

0 comments on commit db689ba

Please sign in to comment.