From 7e845e7cfdd658caccc60f687d5d5d68d7e88937 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 Sep 2005 05:16:06 +0000 Subject: Added FTP_SKIP_PASV_IP and --ftp-skip-pasv-ip --- lib/ftp.c | 16 ++++++++++++---- lib/url.c | 10 +++++++++- lib/urldata.h | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/ftp.c b/lib/ftp.c index bc30e2258..4d89723c7 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -1601,8 +1601,18 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, return CURLE_FTP_WEIRD_227_FORMAT; } - snprintf(newhost, sizeof(newhost), - "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + /* we got OK from server */ + if(data->set.ftp_skip_ip) { + /* told to ignore the remotely given IP but instead use the one we used + for the control connection */ + infof(data, "Skips %d.%d.%d.%d for data connection, uses %s instead\n", + ip[0], ip[1], ip[2], ip[3], + conn->ip_addr_str); + snprintf(newhost, sizeof(newhost), "%s", conn->ip_addr_str); + } + else + snprintf(newhost, sizeof(newhost), + "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); newport = (port[0]<<8) + port[1]; } else if(ftp->count1 == 0) { @@ -1622,8 +1632,6 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn, return CURLE_FTP_WEIRD_PASV_REPLY; } - /* we got OK from server */ - if(data->change.proxy && *data->change.proxy) { /* * This is a tunnel through a http proxy and we need to connect to the diff --git a/lib/url.c b/lib/url.c index 06784fe34..c256cf23f 100644 --- a/lib/url.c +++ b/lib/url.c @@ -965,6 +965,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, data->set.ftp_use_epsv = va_arg(param, long)?TRUE:FALSE; break; + case CURLOPT_FTP_SKIP_PASV_IP: + /* + * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the + * bypass of the IP address in PASV responses. + */ + data->set.ftp_skip_ip = (bool)va_arg(param, long); + break; + case CURLOPT_INFILE: /* * FILE pointer to read the file to be uploaded from. Or possibly @@ -1240,7 +1248,7 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, /* * Set a SSL_CTX callback */ - data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); + data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); break; case CURLOPT_SSL_CTX_DATA: /* diff --git a/lib/urldata.h b/lib/urldata.h index 3436b17da..ff0b23a54 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1072,8 +1072,9 @@ struct UserDefined { bool no_signal; /* do not use any signal/alarm handler */ bool global_dns_cache; /* subject for future removal */ bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */ - bool ignorecl; /* ignore content length */ + bool ftp_skip_ip; /* skip the IP address the FTP server passes on to + us */ }; /* -- cgit v1.2.3