Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve a failover RADIUS server hostname if need #222

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/eradius_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,14 @@ find_suitable_peer(undefined) ->
[];
find_suitable_peer([]) ->
[];
find_suitable_peer([{Host, Port, Secret} | Pool]) when is_list(Host) ->
try
IP = get_ip(Host),
find_suitable_peer([{IP, Port, Secret} | Pool])
catch _:_ ->
% can't resolve ip by some reasons, just ignore it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make sense to add log here for this case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any sense in it

find_suitable_peer(Pool)
end;
find_suitable_peer([{IP, Port, Secret} | Pool]) ->
case ets:lookup(?MODULE, {IP, Port}) of
[] ->
Expand Down
2 changes: 1 addition & 1 deletion test/eradius_test_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ start() ->
application:set_env(eradius, unreachable_timeout, 2),
application:set_env(eradius, servers_pool, [{test_pool, [{localhost(tuple), 1812, "secret"},
% fake upstream server for fail-over
{localhost(tuple), 1820, "secret"}]}]),
{localhost(string), 1820, "secret"}]}]),
application:ensure_all_started(eradius),
eradius:modules_ready([?MODULE]).

Expand Down