curl / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Gisle Vanem via curl-library <curl-library_at_cool.haxx.se>
Date: Sat, 11 Aug 2018 14:24:22 +0200

myLC---wrote:

> I would like to know how we can retrieve all the IP
> addresses which are mapped to a host.
>
> Assuming we have the URL
> https://example.buzz/bingo_results/
>
> and assuming further that there are 5 addresses mapped to
> this hostname:
> 10.0.0.11, 10.0.0.12, 10.0.0.13,
> fd0e:34f4:760f:5bd6:0123:4567:89ab:cdef,
> fd0e:34f4:760f:5bd6:aaaa:bbbb:cccc:dddd
>
> How would I get them from libcurl?

Not sure you can get them all (unless one of them
fail). But the "primary IP" could be fetched by:
   char ip [5*16]; // enough for IPv6?
   curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, ip);

Or try my old 'sock_snoop.c' example attached.

c:\>sock_snoop.exe -v http://www.vg.no

* STATE: INIT => CONNECT handle 0x24bb028; line 1447 (connection #-5000)
* Rebuilt URL to: www.vg.no/
* Added connection 0. The cache now contains 1 members
* STATE: CONNECT => WAITRESOLVE handle 0x24bb028; line 1483 (connection #0)
AF_INET: 195.88.54.16

* Trying 195.88.54.16...
* Could not set TCP_NODELAY: Descriptor is not a socket
* Immediate connect fail for 195.88.54.16: Descriptor is not a socket
AF_INET: 195.88.55.16

* Trying 195.88.55.16...
* Could not set TCP_NODELAY: Descriptor is not a socket
* Immediate connect fail for 195.88.55.16: Descriptor is not a socket
AF_INET6: 2001:67c:21e0::16

* Trying 2001:67c:21e0::16...
* Could not set TCP_NODELAY: Descriptor is not a socket
* Immediate connect fail for 2001:67c:21e0::16: Descriptor is not a socket
* Closing connection 0
* The cache now contains 0 members
* Expire cleared

-- 
--gv


-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html

Received on 2018-08-11