Skip to content

Commit

Permalink
match localhost directly
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Oct 10, 2024
1 parent cf298cd commit 8a45b03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hackney_happy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ parse_address(IPString) ->
{error, _} -> IPString
end.



getaddrs("localhost") ->
[{{0,0,0,0,0,0,0,1}, 'inet6'}, {{127,0,0,1}, 'inet'}];
getaddrs(Hostname) ->
IP6Addrs = [{Addr, 'inet6'} || Addr <- getbyname(Hostname, 'aaaa')],
IP4Addrs = [{Addr, 'inet'} || Addr <- getbyname(Hostname, 'a')],
IP6Addrs ++ IP4Addrs.

getbyname("localhost", 'aaaa') -> [{0,0,0,0,0,0,0,1}];
getbyname("localhost", 'a') -> [{127,0,0,1}];
getbyname(Hostname, Type) ->
case (catch inet_res:getbyname(Hostname, Type)) of
{'ok', #hostent{h_addr_list=AddrList}} -> lists:usort(AddrList);
Expand Down

0 comments on commit 8a45b03

Please sign in to comment.