From a15d107dde68f6173cfb1a590320cb108d4dd0f5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 21 Feb 2006 07:46:41 +0000 Subject: Peter Su added support for SOCKS4 proxies. Enable this by setting the proxy type to the already provided type CURLPROXY_SOCKS4. I added a --socks4 option that works like the current --socks5 option but instead use the socks4 protocol. --- src/main.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index c6049242c..89289db8b 100644 --- a/src/main.c +++ b/src/main.c @@ -343,7 +343,10 @@ struct Configurable { struct timeval lastrecvtime; size_t lastrecvsize; bool ftp_ssl; - char *socks5proxy; + + char *socksproxy; /* set to server string */ + int socksver; /* set to CURLPROXY_SOCKS* define */ + bool tcp_nodelay; long req_retry; /* number of retries */ long retry_delay; /* delay between retries (in seconds) */ @@ -557,7 +560,8 @@ static void help(void) " --retry-max-time Retry only within this period", " -s/--silent Silent mode. Don't output anything", " -S/--show-error Show error. With -s, make curl show errors when they occur", - " --socks Use SOCKS5 proxy on given host + port", + " --socks4 Use SOCKS4 proxy on given host + port", + " --socks5 Use SOCKS5 proxy on given host + port", " --stderr Where to redirect stderr. - means stdout", " -t/--telnet-option Set telnet option", " --trace Write a debug trace to the given file", @@ -1314,6 +1318,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ {"$a", "ftp-ssl", FALSE}, {"$b", "ftp-pasv", FALSE}, {"$c", "socks5", TRUE}, + {"$c", "socks", TRUE}, /* this is how the option was documented but + we prefer the --socks5 version for explicit + version */ {"$d", "tcp-nodelay",FALSE}, {"$e", "proxy-digest", FALSE}, {"$f", "proxy-basic", FALSE}, @@ -1330,6 +1337,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ {"$q", "ftp-skip-pasv-ip", FALSE}, {"$r", "ftp-method", TRUE}, {"$s", "local-port", TRUE}, + {"$t", "socks4", TRUE}, {"0", "http1.0", FALSE}, {"1", "tlsv1", FALSE}, @@ -1673,8 +1681,13 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ free(config->ftpport); config->ftpport = NULL; break; - case 'c': /* --socks specifies a socks5 proxy to use */ - GetStr(&config->socks5proxy, nextarg); + case 'c': /* --socks5 specifies a socks5 proxy to use */ + GetStr(&config->socksproxy, nextarg); + config->socksver = CURLPROXY_SOCKS5; + break; + case 't': /* --socks4 specifies a socks5 proxy to use */ + GetStr(&config->socksproxy, nextarg); + config->socksver = CURLPROXY_SOCKS4; break; case 'd': /* --tcp-nodelay option */ config->tcp_nodelay ^= TRUE; @@ -3972,10 +3985,10 @@ operate(struct Configurable *config, int argc, char *argv[]) if(config->ftp_ssl) curl_easy_setopt(curl, CURLOPT_FTP_SSL, CURLFTPSSL_TRY); - /* new in curl 7.11.1 */ - if(config->socks5proxy) { - curl_easy_setopt(curl, CURLOPT_PROXY, config->socks5proxy); - curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); + /* new in curl 7.11.1, modified in 7.15.2 */ + if(config->socksproxy) { + curl_easy_setopt(curl, CURLOPT_PROXY, config->socksproxy); + curl_easy_setopt(curl, CURLOPT_PROXYTYPE, config->socksver); } /* curl 7.13.0 */ -- cgit v1.2.3