connect: store connection info when really done

Output the 'Connected to...' info message when the connection has been
fully established and all information is available.

Due to our happy eyeballing, we should not emit info messages in
filters, because they may be part of an eyeballing attempt and may be
discarded later for another chain.

Closes #14897
This commit is contained in:
Stefan Eissing 2024-09-13 13:12:50 +02:00 committed by Daniel Stenberg
parent a33bcc9b53
commit 50166c0de8
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
4 changed files with 27 additions and 4 deletions

View File

@ -189,7 +189,6 @@ static CURLcode baller_connected(struct Curl_cfilter *cf,
switch(cf->conn->alpn) {
case CURL_HTTP_VERSION_3:
infof(data, "using HTTP/3");
break;
case CURL_HTTP_VERSION_2:
#ifdef USE_NGHTTP2
@ -202,10 +201,8 @@ static CURLcode baller_connected(struct Curl_cfilter *cf,
return result;
}
#endif
infof(data, "using HTTP/2");
break;
default:
infof(data, "using HTTP/1.x");
break;
}
ctx->state = CF_HC_SUCCESS;

View File

@ -437,6 +437,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
cf_cntrl_update_info(data, data->conn);
conn_report_connect_stats(data, data->conn);
data->conn->keepalive = Curl_now();
Curl_verboseconnect(data, data->conn, sockindex);
}
else if(result) {
conn_report_connect_stats(data, data->conn);

View File

@ -969,7 +969,17 @@ static CURLcode cf_he_connect(struct Curl_cfilter *cf,
if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
Curl_verboseconnect(data, cf->conn, cf->sockindex);
if(Curl_trc_cf_is_verbose(cf, data)) {
struct ip_quadruple ipquad;
int is_ipv6;
if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
const char *host, *disphost;
int port;
cf->next->cft->get_host(cf->next, data, &host, &disphost, &port);
CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
disphost, ipquad.remote_ip, ipquad.remote_port);
}
}
data->info.numconnects++; /* to track the # of connections made */
}
break;

View File

@ -1274,6 +1274,21 @@ void Curl_verboseconnect(struct Curl_easy *data,
infof(data, "Connected to %s (%s) port %u",
CURL_CONN_HOST_DISPNAME(conn), conn->primary.remote_ip,
conn->primary.remote_port);
#if !defined(CURL_DISABLE_HTTP)
if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
switch(conn->alpn) {
case CURL_HTTP_VERSION_3:
infof(data, "using HTTP/3");
break;
case CURL_HTTP_VERSION_2:
infof(data, "using HTTP/2");
break;
default:
infof(data, "using HTTP/1.x");
break;
}
}
#endif
}
#endif