mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
more "anything through http proxy tunnel" fixes
This commit is contained in:
parent
23f22bd53e
commit
0da7057591
37
lib/ftp.c
37
lib/ftp.c
@ -390,7 +390,8 @@ CURLcode ftp_connect(struct connectdata *conn)
|
||||
|
||||
if (data->bits.tunnel_thru_httpproxy) {
|
||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
||||
result = GetHTTPProxyTunnel(data, data->firstsocket);
|
||||
result = GetHTTPProxyTunnel(data, data->firstsocket,
|
||||
data->hostname, data->remote_port);
|
||||
if(CURLE_OK != result)
|
||||
return result;
|
||||
}
|
||||
@ -769,13 +770,24 @@ CURLcode _ftp(struct connectdata *conn)
|
||||
failf(data, "Couldn't interpret this 227-reply: %s", buf);
|
||||
return CURLE_FTP_WEIRD_227_FORMAT;
|
||||
}
|
||||
sprintf(newhost, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
he = GetHost(data, newhost, hostent_buf, sizeof(hostent_buf));
|
||||
if(!he) {
|
||||
failf(data, "Can't resolve new host %s", newhost);
|
||||
return CURLE_FTP_CANT_GET_HOST;
|
||||
}
|
||||
|
||||
if(data->bits.httpproxy) {
|
||||
/*
|
||||
* This is a tunnel through a http proxy and we need to connect to the
|
||||
* proxy again here. We already have the name info for it since the
|
||||
* previous lookup.
|
||||
*/
|
||||
he = conn->hp;
|
||||
}
|
||||
else {
|
||||
/* normal, direct, ftp connection */
|
||||
sprintf(newhost, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
he = GetHost(data, newhost, hostent_buf, sizeof(hostent_buf));
|
||||
if(!he) {
|
||||
failf(data, "Can't resolve new host %s", newhost);
|
||||
return CURLE_FTP_CANT_GET_HOST;
|
||||
}
|
||||
}
|
||||
|
||||
newport = (port[0]<<8) + port[1];
|
||||
data->secondarysocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@ -783,7 +795,13 @@ CURLcode _ftp(struct connectdata *conn)
|
||||
memset((char *) &serv_addr, '\0', sizeof(serv_addr));
|
||||
memcpy((char *)&(serv_addr.sin_addr), he->h_addr, he->h_length);
|
||||
serv_addr.sin_family = he->h_addrtype;
|
||||
serv_addr.sin_port = htons(newport);
|
||||
|
||||
if(data->bits.httpproxy)
|
||||
/* connect to the http proxy's port number */
|
||||
serv_addr.sin_port = htons(data->port);
|
||||
else
|
||||
/* direct connection to remote host's PASV port */
|
||||
serv_addr.sin_port = htons(newport);
|
||||
|
||||
if(data->bits.verbose) {
|
||||
struct in_addr in;
|
||||
@ -871,7 +889,8 @@ CURLcode _ftp(struct connectdata *conn)
|
||||
|
||||
if (data->bits.tunnel_thru_httpproxy) {
|
||||
/* We want "seamless" FTP operations through HTTP proxy tunnel */
|
||||
result = GetHTTPProxyTunnel(data, data->secondarysocket);
|
||||
result = GetHTTPProxyTunnel(data, data->secondarysocket,
|
||||
newhost, newport);
|
||||
if(CURLE_OK != result)
|
||||
return result;
|
||||
}
|
||||
|
@ -140,7 +140,8 @@ bool static checkheaders(struct UrlData *data, char *thisheader)
|
||||
* this proxy. After that, the socket can be used just as a normal socket.
|
||||
*/
|
||||
|
||||
CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket)
|
||||
CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
|
||||
char *hostname, int remote_port)
|
||||
{
|
||||
int httperror=0;
|
||||
int subversion=0;
|
||||
@ -153,7 +154,7 @@ CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket)
|
||||
"%s"
|
||||
"%s"
|
||||
"\r\n",
|
||||
data->hostname, data->remote_port,
|
||||
hostname, remote_port,
|
||||
(data->bits.proxy_user_passwd)?data->ptr_proxyuserpwd:"",
|
||||
(data->useragent?data->ptr_uagent:"")
|
||||
);
|
||||
@ -197,7 +198,8 @@ CURLcode http_connect(struct connectdata *conn)
|
||||
if (conn->protocol & PROT_HTTPS) {
|
||||
if (data->bits.httpproxy) {
|
||||
/* HTTPS through a proxy can only be done with a tunnel */
|
||||
result = GetHTTPProxyTunnel(data, data->firstsocket);
|
||||
result = GetHTTPProxyTunnel(data, data->firstsocket,
|
||||
data->hostname, data->remote_port);
|
||||
if(CURLE_OK != result)
|
||||
return result;
|
||||
}
|
||||
|
@ -42,7 +42,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
/* ftp can use this as well */
|
||||
CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket);
|
||||
CURLcode GetHTTPProxyTunnel(struct UrlData *data, int tunnelsocket,
|
||||
char *hostname, int remote_port);
|
||||
|
||||
/* protocol-specific functions set up to be called by the main engine */
|
||||
CURLcode http(struct connectdata *conn);
|
||||
|
Loading…
Reference in New Issue
Block a user