curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Retrieve all addresses mapped to specific host, not just one IP

From: myLC--- via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 15 Aug 2018 11:41:47 +0200

Just upfront: you make it sound like my request for being
able to get all associated IPs is a bizarre idea. I feel the
need to state that many libraries have this implemented
naturally for a good reason (a: it doesn't cost anything +
b: in some scenarios, you need it).

The upcoming C++ networking will have this:
"The class template basic_resolver_results satisfies the
  requirements of a sequence container ... The class template
  basic_resolver_results supports forward iterators."
Translation: You get the list of IPs.

Qt has this:
"QList<QHostAddress> QHostInfo::addresses() const
  Returns the list of IP addresses associated with hostName()."

Many others have this as well. The C++ standard committee
rarely implements anything that is not going to be used.

On Tue, 14 Aug 2018, Gisle Vanem wrote:

> "should favour" how? Based on what; that IPv6 is
> better/speedier than IPv4, or some addresses based on Geo-
> location is best? libcurl knows zero about this. It would
> be cool if it did though.

This should be handled by the layers below libcurl. The
function(s) used by libcurl can or should return the list
with prioritization in mind. A short discussion about this
can be found here:

https://stackoverflow.com/questions/11241339/will-getaddrinfo-return-ipv6-addresses-first

On Tue, 14 Aug 2018, Richard Gray wrote:

> OK, filtering - got it.

That's not a small area, btw. ;-)

> You still haven't indicated what kind of access(es) you
> are trying to perform with the potentially multiple
> addresses. Are trying to just find the first one that
> works? Are you trying to actually access more than one of
> them? The later case might be something like testing the
> various hosts behind a load leveler.

Your application might simply choose to exclude some for
particular reasons, while preferring others. Or it might
simply want to document the mappings. There are many
applications for this...

> No, you would do the resolves then tell libcurl to operate
> on any returned address(es) you are interested in.

Yes, this would essentially result in having the same code
twice and having to maintain that code. Most/many other
libraries didn't go for that approach. They simply hand you
the list, which they have anyhow.

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-08-15