curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: getting local port number

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 14 Dec 2017 01:36:15 -0500

On 12/13/2017 11:13 AM, Anton Kabakov wrote:
>
> I’m trying to locate in tcpdump a problematic connection issued by
> libcurl that isn’t closed properly,  to do so I need the local port
> used to establish this connection.
>
> I tried to use curl_easy_getinfo CURLINFO_LOCAL_PORT, but it is only
> updated after curl_easy_perform finishes -  In my case it newer does.
>
>  
>
> Is it possible to add local port data to connection information debug
> in Curl_verboseconnect?
>

The local port should be available after the connection is established
except in the case of TCP Fast Open (TFO) due to a bug [1]. You can get
the local port from the progress callback, an example is at [2]. It has
output formatted like

192.168.1.2:53184 -> 192.30.253.112:443

Strictly speaking it's possible that the local ip/port -> primary
ip/port combination may be reused in a subsequent connection. We don't
have a formal transfer-is-now-using-this-connection type of getinfo as
far as I know.

Also I made a patch that adds it to Curl_verboseconnect [3] so you can
use that for your own build. I have no intention to send it upstream.

[1]: https://github.com/curl/curl/issues/1332
[2]: https://gist.github.com/jay/704ef499230c961070fd71424aa91e97
[3]:
https://github.com/curl/curl/compare/master...jay:show_local_ipport_in_verboseconnect?expand=1

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-12-14