- Constantine Sapuntzakis fixed bug report #2784055

(http://curl.haxx.se/bug/view.cgi?id=2784055) identifying a problem to
  connect to SOCKS proxies when using the multi interface. It turned out to
  almost not work at all previously. We need to wait for the TCP connect to
  be properly verified before doing the SOCKS magic.

  There's still a flaw in the FTP code for this.
This commit is contained in:
Daniel Stenberg
2009-05-08 10:59:40 +00:00
parent 9ef7b6afe2
commit e84c7db049
5 changed files with 70 additions and 35 deletions

View File

@@ -6,6 +6,15 @@
Changelog Changelog
Daniel Stenberg (8 May 2009)
- Constantine Sapuntzakis fixed bug report #2784055
(http://curl.haxx.se/bug/view.cgi?id=2784055) identifying a problem to
connect to SOCKS proxies when using the multi interface. It turned out to
almost not work at all previously. We need to wait for the TCP connect to
be properly verified before doing the SOCKS magic.
There's still a flaw in the FTP code for this.
Daniel Stenberg (7 May 2009) Daniel Stenberg (7 May 2009)
- Made the SO_SNDBUF setting for the data connection socket for ftp uploads as - Made the SO_SNDBUF setting for the data connection socket for ftp uploads as
well. See change 28 Apr 2009. well. See change 28 Apr 2009.

View File

@@ -42,6 +42,7 @@ This release includes the following bugfixes:
o Rejected SSL session ids are killed properly (for OpenSSL and GnuTLS builds) o Rejected SSL session ids are killed properly (for OpenSSL and GnuTLS builds)
o Deal with the TFTP OACK packet o Deal with the TFTP OACK packet
o fixed roff mistakes in man pages o fixed roff mistakes in man pages
o use SOCKS proxy with the multi interface
This release includes the following known bugs: This release includes the following known bugs:

View File

@@ -1055,9 +1055,16 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
easy->result = Curl_is_connected(easy->easy_conn, easy->result = Curl_is_connected(easy->easy_conn,
FIRSTSOCKET, FIRSTSOCKET,
&connected); &connected);
if(connected) if(connected) {
/* see if we need to do any proxy magic first once we connected */
easy->result = Curl_connected_proxy(easy->easy_conn);
if(!easy->result)
/* if everything is still fine we do the protocol-specific connect
setup */
easy->result = Curl_protocol_connect(easy->easy_conn, easy->result = Curl_protocol_connect(easy->easy_conn,
&protocol_connect); &protocol_connect);
}
if(CURLE_OK != easy->result) { if(CURLE_OK != easy->result) {
/* failure detected */ /* failure detected */

View File

@@ -2814,33 +2814,16 @@ ConnectionStore(struct SessionHandle *data,
return i; return i;
} }
static CURLcode ConnectPlease(struct SessionHandle *data, /* after a TCP connection to the proxy has been verified, this function does
struct connectdata *conn, the next magic step.
struct Curl_dns_entry *hostaddr,
bool *connected) Note: this function (and its sub-functions) calls failf()
*/
CURLcode Curl_connected_proxy(struct connectdata *conn)
{ {
CURLcode result; CURLcode result = CURLE_OK;
Curl_addrinfo *addr; struct SessionHandle *data = conn->data;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char *hostname = conn->bits.proxy?conn->proxy.name:conn->host.name;
infof(data, "About to connect() to %s%s port %d (#%d)\n",
conn->bits.proxy?"proxy ":"",
hostname, conn->port, conn->connectindex);
#endif
/*************************************************************
* Connect to server/proxy
*************************************************************/
result= Curl_connecthost(conn,
hostaddr,
&conn->sock[FIRSTSOCKET],
&addr,
connected);
if(CURLE_OK == result) {
/* All is cool, then we store the current information */
conn->dns_entry = hostaddr;
conn->ip_addr = addr;
switch(data->set.proxytype) { switch(data->set.proxytype) {
#ifndef CURL_DISABLE_PROXY #ifndef CURL_DISABLE_PROXY
@@ -2868,9 +2851,42 @@ static CURLcode ConnectPlease(struct SessionHandle *data,
result = CURLE_COULDNT_CONNECT; result = CURLE_COULDNT_CONNECT;
break; break;
} /* switch proxytype */ } /* switch proxytype */
} /* if result is ok */
if(result) return result;
}
static CURLcode ConnectPlease(struct SessionHandle *data,
struct connectdata *conn,
struct Curl_dns_entry *hostaddr,
bool *connected)
{
CURLcode result;
Curl_addrinfo *addr;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char *hostname = conn->bits.proxy?conn->proxy.name:conn->host.name;
infof(data, "About to connect() to %s%s port %d (#%d)\n",
conn->bits.proxy?"proxy ":"",
hostname, conn->port, conn->connectindex);
#endif
/*************************************************************
* Connect to server/proxy
*************************************************************/
result= Curl_connecthost(conn,
hostaddr,
&conn->sock[FIRSTSOCKET],
&addr,
connected);
if(CURLE_OK == result) {
/* All is cool, we store the current information */
conn->dns_entry = hostaddr;
conn->ip_addr = addr;
if(*connected)
result = Curl_connected_proxy(conn);
}
else
*connected = FALSE; /* mark it as not connected */ *connected = FALSE; /* mark it as not connected */
return result; return result;
@@ -4761,8 +4777,6 @@ CURLcode Curl_done(struct connectdata **connp,
Curl_expire(data, 0); /* stop timer */ Curl_expire(data, 0); /* stop timer */
Curl_getoff_all_pipelines(data, conn);
if(conn->bits.done || if(conn->bits.done ||
(conn->send_pipe->size + conn->recv_pipe->size != 0 && (conn->send_pipe->size + conn->recv_pipe->size != 0 &&
!data->set.reuse_forbid && !data->set.reuse_forbid &&
@@ -4773,6 +4787,8 @@ CURLcode Curl_done(struct connectdata **connp,
conn->bits.done = TRUE; /* called just now! */ conn->bits.done = TRUE; /* called just now! */
Curl_getoff_all_pipelines(data, conn);
/* Cleanup possible redirect junk */ /* Cleanup possible redirect junk */
if(data->req.newurl) { if(data->req.newurl) {
free(data->req.newurl); free(data->req.newurl);

View File

@@ -85,4 +85,6 @@ void Curl_reset_reqproto(struct connectdata *conn);
#define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */ #define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
#define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi service */ #define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi service */
CURLcode Curl_connected_proxy(struct connectdata *conn);
#endif #endif