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

improve connection to remote #737

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
handle localhost
benoitc committed Oct 10, 2024
commit c719c78f3daabd1082cb37a97390875754b2b75e
2 changes: 2 additions & 0 deletions src/hackney_happy.erl
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ getaddrs(Hostname) ->
IP4Addrs = [{Addr, 'inet'} || Addr <- getbyname(Hostname, 'a')],
IP6Addrs ++ IP4Addrs.

Choose a reason for hiding this comment

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

👋 @benoitc

I wonder if it would make sense to "intersperse" the addresses here like [ipv6, ipv4, ipv6, ipv4, etc.]?

Choose a reason for hiding this comment

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


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);