mirror of
https://github.com/moparisthebest/curl
synced 2024-12-25 09:38:54 -05:00
urldata: remove duplicate port number storage
... and use 'int' for ports. We don't use 'unsigned short' since -1 is still often used internally to signify "unknown value" and 0 - 65535 are all valid port numbers. Closes #6534
This commit is contained in:
parent
642d78026f
commit
764c6bd3bf
@ -616,7 +616,7 @@ void Curl_persistconninfo(struct Curl_easy *data, struct connectdata *conn)
|
|||||||
memcpy(data->info.conn_local_ip, conn->local_ip, MAX_IPADR_LEN);
|
memcpy(data->info.conn_local_ip, conn->local_ip, MAX_IPADR_LEN);
|
||||||
data->info.conn_scheme = conn->handler->scheme;
|
data->info.conn_scheme = conn->handler->scheme;
|
||||||
data->info.conn_protocol = conn->handler->protocol;
|
data->info.conn_protocol = conn->handler->protocol;
|
||||||
data->info.conn_primary_port = conn->primary_port;
|
data->info.conn_primary_port = conn->port;
|
||||||
data->info.conn_local_port = conn->local_port;
|
data->info.conn_local_port = conn->local_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -686,6 +686,7 @@ void Curl_conninfo_remote(struct Curl_easy *data,
|
|||||||
char buffer[STRERROR_LEN];
|
char buffer[STRERROR_LEN];
|
||||||
struct Curl_sockaddr_storage ssrem;
|
struct Curl_sockaddr_storage ssrem;
|
||||||
curl_socklen_t plen;
|
curl_socklen_t plen;
|
||||||
|
long port;
|
||||||
plen = sizeof(struct Curl_sockaddr_storage);
|
plen = sizeof(struct Curl_sockaddr_storage);
|
||||||
memset(&ssrem, 0, sizeof(ssrem));
|
memset(&ssrem, 0, sizeof(ssrem));
|
||||||
if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
|
if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
|
||||||
@ -695,7 +696,7 @@ void Curl_conninfo_remote(struct Curl_easy *data,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
|
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
|
||||||
conn->primary_ip, &conn->primary_port)) {
|
conn->primary_ip, &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;
|
||||||
|
@ -2319,7 +2319,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
|
|||||||
curl_proxytype proxytype)
|
curl_proxytype proxytype)
|
||||||
{
|
{
|
||||||
char *portptr = NULL;
|
char *portptr = NULL;
|
||||||
long port = -1;
|
int port = -1;
|
||||||
char *proxyuser = NULL;
|
char *proxyuser = NULL;
|
||||||
char *proxypasswd = NULL;
|
char *proxypasswd = NULL;
|
||||||
char *host;
|
char *host;
|
||||||
@ -2408,14 +2408,14 @@ static CURLcode parse_proxy(struct Curl_easy *data,
|
|||||||
curl_url_get(uhp, CURLUPART_PORT, &portptr, 0);
|
curl_url_get(uhp, CURLUPART_PORT, &portptr, 0);
|
||||||
|
|
||||||
if(portptr) {
|
if(portptr) {
|
||||||
port = strtol(portptr, NULL, 10);
|
port = (int)strtol(portptr, NULL, 10);
|
||||||
free(portptr);
|
free(portptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(data->set.proxyport)
|
if(data->set.proxyport)
|
||||||
/* None given in the proxy string, then get the default one if it is
|
/* None given in the proxy string, then get the default one if it is
|
||||||
given */
|
given */
|
||||||
port = data->set.proxyport;
|
port = (int)data->set.proxyport;
|
||||||
else {
|
else {
|
||||||
if(proxytype == CURLPROXY_HTTPS)
|
if(proxytype == CURLPROXY_HTTPS)
|
||||||
port = CURL_DEFAULT_HTTPS_PROXY_PORT;
|
port = CURL_DEFAULT_HTTPS_PROXY_PORT;
|
||||||
|
@ -782,7 +782,7 @@ struct Curl_handler {
|
|||||||
struct connectdata *conn,
|
struct connectdata *conn,
|
||||||
unsigned int checks_to_perform);
|
unsigned int checks_to_perform);
|
||||||
|
|
||||||
long defport; /* Default port. */
|
int defport; /* Default port. */
|
||||||
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
|
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
|
||||||
specific protocol bit */
|
specific protocol bit */
|
||||||
unsigned int family; /* single bit for protocol family; basically the
|
unsigned int family; /* single bit for protocol family; basically the
|
||||||
@ -961,7 +961,7 @@ struct connectdata {
|
|||||||
struct proxy_info socks_proxy;
|
struct proxy_info socks_proxy;
|
||||||
struct proxy_info http_proxy;
|
struct proxy_info http_proxy;
|
||||||
#endif
|
#endif
|
||||||
long port; /* which port to use locally */
|
int port; /* which port to use locally - to connect to */
|
||||||
int remote_port; /* the remote port, not the proxy port! */
|
int remote_port; /* the remote port, not the proxy port! */
|
||||||
int conn_to_port; /* the remote port to connect to. valid only if
|
int conn_to_port; /* the remote port to connect to. valid only if
|
||||||
bits.conn_to_port is set */
|
bits.conn_to_port is set */
|
||||||
@ -976,7 +976,6 @@ struct connectdata {
|
|||||||
these are updated with data which comes directly from the socket. */
|
these are updated with data which comes directly from the socket. */
|
||||||
|
|
||||||
char primary_ip[MAX_IPADR_LEN];
|
char primary_ip[MAX_IPADR_LEN];
|
||||||
long primary_port;
|
|
||||||
|
|
||||||
/* 'local_ip' and 'local_port' get filled with local's numerical
|
/* 'local_ip' and 'local_port' get filled with local's numerical
|
||||||
ip address and port number whenever an outgoing connection is
|
ip address and port number whenever an outgoing connection is
|
||||||
|
Loading…
Reference in New Issue
Block a user