mirror of
https://github.com/moparisthebest/curl
synced 2024-12-24 00:58:48 -05:00
connect: store connection info for QUIC connections
Restores the --head functionality to the curl utility which extracts 'protocol' that is stored that way. Reported-by: James Fuller Fixes #5196 Closes #5198
This commit is contained in:
parent
860eaebae6
commit
0bcf975c38
@ -679,58 +679,56 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
|||||||
connection */
|
connection */
|
||||||
void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
|
void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
|
||||||
{
|
{
|
||||||
if(conn->transport != TRNSPRT_TCP)
|
if(conn->transport == TRNSPRT_TCP) {
|
||||||
/* there's no TCP connection! */
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME)
|
#if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME)
|
||||||
if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
|
if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
|
||||||
struct Curl_easy *data = conn->data;
|
struct Curl_easy *data = conn->data;
|
||||||
char buffer[STRERROR_LEN];
|
char buffer[STRERROR_LEN];
|
||||||
struct Curl_sockaddr_storage ssrem;
|
struct Curl_sockaddr_storage ssrem;
|
||||||
struct Curl_sockaddr_storage ssloc;
|
struct Curl_sockaddr_storage ssloc;
|
||||||
curl_socklen_t plen;
|
curl_socklen_t plen;
|
||||||
curl_socklen_t slen;
|
curl_socklen_t slen;
|
||||||
#ifdef HAVE_GETPEERNAME
|
#ifdef HAVE_GETPEERNAME
|
||||||
plen = sizeof(struct Curl_sockaddr_storage);
|
plen = sizeof(struct Curl_sockaddr_storage);
|
||||||
if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
|
if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
|
||||||
int error = SOCKERRNO;
|
int error = SOCKERRNO;
|
||||||
failf(data, "getpeername() failed with errno %d: %s",
|
failf(data, "getpeername() failed with errno %d: %s",
|
||||||
error, Curl_strerror(error, buffer, sizeof(buffer)));
|
error, Curl_strerror(error, buffer, sizeof(buffer)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETSOCKNAME
|
#ifdef HAVE_GETSOCKNAME
|
||||||
slen = sizeof(struct Curl_sockaddr_storage);
|
slen = sizeof(struct Curl_sockaddr_storage);
|
||||||
memset(&ssloc, 0, sizeof(ssloc));
|
memset(&ssloc, 0, sizeof(ssloc));
|
||||||
if(getsockname(sockfd, (struct sockaddr*) &ssloc, &slen)) {
|
if(getsockname(sockfd, (struct sockaddr*) &ssloc, &slen)) {
|
||||||
int error = SOCKERRNO;
|
int error = SOCKERRNO;
|
||||||
failf(data, "getsockname() failed with errno %d: %s",
|
failf(data, "getsockname() failed with errno %d: %s",
|
||||||
error, Curl_strerror(error, buffer, sizeof(buffer)));
|
error, Curl_strerror(error, buffer, sizeof(buffer)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETPEERNAME
|
#ifdef HAVE_GETPEERNAME
|
||||||
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
|
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
|
||||||
conn->primary_ip, &conn->primary_port)) {
|
conn->primary_ip, &conn->primary_port)) {
|
||||||
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
|
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
|
||||||
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
|
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
|
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETSOCKNAME
|
#ifdef HAVE_GETSOCKNAME
|
||||||
if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
|
if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
|
||||||
conn->local_ip, &conn->local_port)) {
|
conn->local_ip, &conn->local_port)) {
|
||||||
failf(data, "ssloc inet_ntop() failed with errno %d: %s",
|
failf(data, "ssloc inet_ntop() failed with errno %d: %s",
|
||||||
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
|
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else /* !HAVE_GETSOCKNAME && !HAVE_GETPEERNAME */
|
#else /* !HAVE_GETSOCKNAME && !HAVE_GETPEERNAME */
|
||||||
(void)sockfd; /* unused */
|
(void)sockfd; /* unused */
|
||||||
#endif
|
#endif
|
||||||
|
} /* end of TCP-only section */
|
||||||
|
|
||||||
/* persist connection info in session handle */
|
/* persist connection info in session handle */
|
||||||
Curl_persistconninfo(conn);
|
Curl_persistconninfo(conn);
|
||||||
@ -872,6 +870,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
|||||||
conn->sock[sockindex] = conn->tempsock[i];
|
conn->sock[sockindex] = conn->tempsock[i];
|
||||||
conn->ip_addr = conn->tempaddr[i];
|
conn->ip_addr = conn->tempaddr[i];
|
||||||
conn->tempsock[i] = CURL_SOCKET_BAD;
|
conn->tempsock[i] = CURL_SOCKET_BAD;
|
||||||
|
post_SOCKS(conn, sockindex, connected);
|
||||||
connkeep(conn, "HTTP/3 default");
|
connkeep(conn, "HTTP/3 default");
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user