mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Enabled support for IPv6-style IP-addresses if ENABLE_IPV6 is set. If it isn't,
curl will return an error when such an address is used.
This commit is contained in:
parent
210aa4371c
commit
7872cc131a
46
lib/url.c
46
lib/url.c
@ -635,6 +635,7 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
char resumerange[40]="";
|
char resumerange[40]="";
|
||||||
struct UrlData *data = curl;
|
struct UrlData *data = curl;
|
||||||
struct connectdata *conn;
|
struct connectdata *conn;
|
||||||
|
char endbracket;
|
||||||
#ifdef HAVE_SIGACTION
|
#ifdef HAVE_SIGACTION
|
||||||
struct sigaction sigact;
|
struct sigaction sigact;
|
||||||
#endif
|
#endif
|
||||||
@ -1146,15 +1147,40 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No matter if we use a proxy or not, we have to figure out the remote
|
||||||
|
port number of various reasons.
|
||||||
|
|
||||||
|
To be able to detect port number flawlessly, we must not confuse them
|
||||||
|
IPv6-specified addresses in the [0::1] style.
|
||||||
|
*/
|
||||||
|
if((1 == sscanf(conn->name, "[%*39[0-9a-fA-F:]%c", &endbracket)) &&
|
||||||
|
(']' == endbracket)) {
|
||||||
|
/* this is a IPv6-style specified IP-address */
|
||||||
|
#ifndef ENABLE_IPV6
|
||||||
|
failf(data, "You haven't enabled IPv6 support");
|
||||||
|
return CURLE_URL_MALFORMAT;
|
||||||
|
#else
|
||||||
|
tmp = strchr(conn->name, ']');
|
||||||
|
|
||||||
|
tmp++; /* pass the ending bracket */
|
||||||
|
if(':' != *tmp)
|
||||||
|
tmp = NULL; /* no port number available */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* traditional IPv4-style port-extracting */
|
||||||
|
tmp = strchr(conn->name, ':');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp) {
|
||||||
|
*tmp++ = '\0'; /* cut off the name there */
|
||||||
|
data->remote_port = atoi(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
if(!data->bits.httpproxy) {
|
if(!data->bits.httpproxy) {
|
||||||
/* If not connecting via a proxy, extract the port from the URL, if it is
|
/* If not connecting via a proxy, extract the port from the URL, if it is
|
||||||
* there, thus overriding any defaults that might have been set above. */
|
* there, thus overriding any defaults that might have been set above. */
|
||||||
tmp = strchr(conn->name, ':');
|
data->port = data->remote_port; /* it is the same port */
|
||||||
if (tmp) {
|
|
||||||
*tmp++ = '\0';
|
|
||||||
data->port = atoi(tmp);
|
|
||||||
}
|
|
||||||
data->remote_port = data->port; /* it is the same port */
|
|
||||||
|
|
||||||
/* Connect to target host right on */
|
/* Connect to target host right on */
|
||||||
conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf);
|
conn->hp = Curl_gethost(data, conn->name, &conn->hostent_buf);
|
||||||
@ -1179,14 +1205,6 @@ static CURLcode _connect(CURL *curl, CURLconnect **in_connect)
|
|||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we use proxy all right, but we wanna know the remote port for SSL
|
|
||||||
reasons */
|
|
||||||
tmp = strchr(conn->name, ':');
|
|
||||||
if (tmp) {
|
|
||||||
*tmp++ = '\0'; /* cut off the name there */
|
|
||||||
data->remote_port = atoi(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Daniel Dec 10, 1998:
|
/* Daniel Dec 10, 1998:
|
||||||
We do the proxy host string parsing here. We want the host name and the
|
We do the proxy host string parsing here. We want the host name and the
|
||||||
port name. Accept a protocol:// prefix, even though it should just be
|
port name. Accept a protocol:// prefix, even though it should just be
|
||||||
|
Loading…
Reference in New Issue
Block a user