Re: IP address of failed/tried connections?
you might get something out of this discussion https://github.com/curl/curl/issues/2126 summary - failed connections intentionally do not report back ip address hope that helps, Jim Fuller On Thu, 2 Jan 2020 at 05:25, Arthur Murray via curl-library wrote: > > Hi, > > I would like to get the IP#(s) of both successful and failed > connections after "curl_easy_perform". For example: If I try to: > > curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com:999;); > res = curl_easy_perform(curl); > > It will timeout for port 999 but both of these getinfo entries are empty: > > curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, ); > curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, ); > > How do I programmatically get the tried IPs? (curl -v shows "Trying > [IP#]...", but I'm not looking for debug strings) > > Hostnames resolve to many IP #s, different ones at different times of > day and from different geo locations. How can my software access and > use them from libcurl? > --- > Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library > Etiquette: https://curl.haxx.se/mail/etiquette.html --- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html
Re: IP address of failed/tried connections?
On 1/2/2020 12:34 AM, Ray Satiro wrote: libcurl saves that information only if a connection is made [1]. You may not be looking for debug strings but CURLINFO_TEXT is the fastest way I can think of to do what you're asking [2][3][4][5]. Either that or you modify libcurl for your own purposes to do it. (I don't think there's any interest to add such a feature upstream, but I'm sure I'll be shortly corrected if there is). hm I'm a little scattered today, I just thought of CURLOPT_OPENSOCKETFUNCTION [1] and CURLOPT_SOCKOPTFUNCTION [2]. You could record the addresses on open and then use primary_ip to see which one curl is using for the transfer. Also you could choose on open to do the connection yourself and return CURL_SOCKOPT_ALREADY_CONNECTED if you need that type information, such as you need to know always whether a connection succeeded or not (remember libcurl may discard a successful connection if another connection beat it due to happy eyeballs). [1]: https://curl.haxx.se/libcurl/c/CURLOPT_OPENSOCKETFUNCTION.html [2]: https://curl.haxx.se/libcurl/c/CURLOPT_SOCKOPTFUNCTION.html --- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html
Re: IP address of failed/tried connections?
On 1/2/2020 12:34 AM, Ray Satiro wrote: Note libcurl may attempt two connections at once and then goes with the fastest connection in what is known as "happy eyeballs". Oops I meant it attempts both connections simultaneously and then uses the first completed connection. You can read more about it at https://en.wikipedia.org/wiki/Happy_Eyeballs Also the debug strings aren't guaranteed the remain the same, they may change in future versions. --- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html
Re: IP address of failed/tried connections?
On 1/1/2020 10:48 PM, Arthur Murray via curl-library wrote: I would like to get the IP#(s) of both successful and failed connections after "curl_easy_perform". For example: If I try to: curl_easy_setopt(curl, CURLOPT_URL,"http://www.google.com:999;); res = curl_easy_perform(curl); It will timeout for port 999 but both of these getinfo entries are empty: curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, ); curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, ); How do I programmatically get the tried IPs? (curl -v shows "Trying [IP#]...", but I'm not looking for debug strings) Hostnames resolve to many IP #s, different ones at different times of day and from different geo locations. How can my software access and use them from libcurl? libcurl saves that information only if a connection is made [1]. You may not be looking for debug strings but CURLINFO_TEXT is the fastest way I can think of to do what you're asking [2][3][4][5]. Either that or you modify libcurl for your own purposes to do it. (I don't think there's any interest to add such a feature upstream, but I'm sure I'll be shortly corrected if there is). Note libcurl may attempt two connections at once and then goes with the fastest connection in what is known as "happy eyeballs". happy eyeballs occurs if one ip address is ipv4 and the other is ipv6, however iirc due to a bug old versions of libcurl allowed happy eyeballs of two ip addresses of same family if only that family was present. [1]: https://github.com/curl/curl/blob/curl-7_67_0/lib/connect.c#L913 [2]: https://curl.haxx.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html [3]: https://github.com/curl/curl/blob/curl-7_67_0/lib/connect.c#L1129 [4]: https://github.com/curl/curl/blob/curl-7_67_0/lib/connect.c#L938-L940 [5]: https://github.com/curl/curl/blob/curl-7_67_0/lib/url.c#L1393-L1399 --- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html
IP address of failed/tried connections?
Hi, I would like to get the IP#(s) of both successful and failed connections after "curl_easy_perform". For example: If I try to: curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com:999;); res = curl_easy_perform(curl); It will timeout for port 999 but both of these getinfo entries are empty: curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, ); curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, ); How do I programmatically get the tried IPs? (curl -v shows "Trying [IP#]...", but I'm not looking for debug strings) Hostnames resolve to many IP #s, different ones at different times of day and from different geo locations. How can my software access and use them from libcurl? --- Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library Etiquette: https://curl.haxx.se/mail/etiquette.html