mirror of https://github.com/moparisthebest/curl
Based on further discussion on curl-library, I reverted yesterday's SOCKS5
code to instead introduce support for a new proxy type called CURLPROXY_SOCKS5_HOSTNAME that is used to send the host name to the proxy instead of IP address and there's thus no longer any need for a new curl_easy_setopt() option. The default SOCKS5 proxy is again back to sending the IP address to the proxy. The new curl command line option for enabling sending host name to a SOCKS5 proxy is now --socks5-hostname.
This commit is contained in:
parent
65008a4e55
commit
b430576436
11
CHANGES
11
CHANGES
|
@ -6,6 +6,17 @@
|
||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel S (5 Jan 2008)
|
||||||
|
- Based on further discussion on curl-library, I reverted yesterday's SOCKS5
|
||||||
|
code to instead introduce support for a new proxy type called
|
||||||
|
CURLPROXY_SOCKS5_HOSTNAME that is used to send the host name to the proxy
|
||||||
|
instead of IP address and there's thus no longer any need for a new
|
||||||
|
curl_easy_setopt() option.
|
||||||
|
|
||||||
|
The default SOCKS5 proxy is again back to sending the IP address to the
|
||||||
|
proxy. The new curl command line option for enabling sending host name to a
|
||||||
|
SOCKS5 proxy is now --socks5-hostname.
|
||||||
|
|
||||||
Daniel S (4 Jan 2008)
|
Daniel S (4 Jan 2008)
|
||||||
- Based on Maxim Perenesenko's patch, we now do SOCKS5 operations and let the
|
- Based on Maxim Perenesenko's patch, we now do SOCKS5 operations and let the
|
||||||
proxy do the host name resolving and only if --socks5ip (or
|
proxy do the host name resolving and only if --socks5ip (or
|
||||||
|
|
|
@ -2,7 +2,7 @@ Curl and libcurl 7.17.2
|
||||||
|
|
||||||
Public curl releases: 103
|
Public curl releases: 103
|
||||||
Command line options: 125
|
Command line options: 125
|
||||||
curl_easy_setopt() options: 149
|
curl_easy_setopt() options: 148
|
||||||
Public functions in libcurl: 55
|
Public functions in libcurl: 55
|
||||||
Public web site mirrors: 42
|
Public web site mirrors: 42
|
||||||
Known libcurl bindings: 36
|
Known libcurl bindings: 36
|
||||||
|
@ -15,7 +15,7 @@ This release includes the following changes:
|
||||||
o --no-keep-alive was added, since starting now curl is doing connections with
|
o --no-keep-alive was added, since starting now curl is doing connections with
|
||||||
keep-alive enabled by default
|
keep-alive enabled by default
|
||||||
o --socks4a added (proxy type CURLPROXY_SOCKS4A for libcurl)
|
o --socks4a added (proxy type CURLPROXY_SOCKS4A for libcurl)
|
||||||
o --socks5ip added (CURLOPT_SOCKS5_RESOLVE_LOCAL for libcurl)
|
o --socks5-hostname added (CURLPROXY_SOCKS5_HOSTNAME for libcurl)
|
||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ This release includes the following bugfixes:
|
||||||
o bad connection re-use check with environment variable-activated proxy use
|
o bad connection re-use check with environment variable-activated proxy use
|
||||||
o --libcurl now generates a return statement as well
|
o --libcurl now generates a return statement as well
|
||||||
o socklen_t is no longer used in the public includes
|
o socklen_t is no longer used in the public includes
|
||||||
o SOCKS5 uses now let the proxy resolve the host names by default
|
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
|
|
10
docs/curl.1
10
docs/curl.1
|
@ -21,7 +21,7 @@
|
||||||
.\" * $Id$
|
.\" * $Id$
|
||||||
.\" **************************************************************************
|
.\" **************************************************************************
|
||||||
.\"
|
.\"
|
||||||
.TH curl 1 "20 Nov 2007" "Curl 7.17.2" "Curl Manual"
|
.TH curl 1 "5 Jan 2008" "Curl 7.17.2" "Curl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl \- transfer a URL
|
curl \- transfer a URL
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -1083,10 +1083,10 @@ This option overrides any previous use of \fI-x/--proxy\fP, as they are
|
||||||
mutually exclusive.
|
mutually exclusive.
|
||||||
|
|
||||||
If this option is used several times, the last one will be used.
|
If this option is used several times, the last one will be used.
|
||||||
.IP "--socks5 <host[:port]>"
|
.IP "--socks5-hostname <host[:port]>"
|
||||||
Use the specified SOCKS5 proxy (and let the proxy resolve the host name). If
|
Use the specified SOCKS5 proxy (and let the proxy resolve the host name). If
|
||||||
the port number is not specified, it is assumed at port 1080. (Added in
|
the port number is not specified, it is assumed at port 1080. (Added in
|
||||||
7.11.1)
|
7.17.2)
|
||||||
|
|
||||||
This option overrides any previous use of \fI-x/--proxy\fP, as they are
|
This option overrides any previous use of \fI-x/--proxy\fP, as they are
|
||||||
mutually exclusive.
|
mutually exclusive.
|
||||||
|
@ -1094,9 +1094,9 @@ mutually exclusive.
|
||||||
If this option is used several times, the last one will be used. (This option
|
If this option is used several times, the last one will be used. (This option
|
||||||
was previously wrongly documented and used as --socks without the number
|
was previously wrongly documented and used as --socks without the number
|
||||||
appended.)
|
appended.)
|
||||||
.IP "--socks5ip <host[:port]>"
|
.IP "--socks5 <host[:port]>"
|
||||||
Use the specified SOCKS5 proxy - but resolve the host name locally. If the
|
Use the specified SOCKS5 proxy - but resolve the host name locally. If the
|
||||||
port number is not specified, it is assumed at port 1080. (Added in 7.17.2)
|
port number is not specified, it is assumed at port 1080.
|
||||||
|
|
||||||
This option overrides any previous use of \fI-x/--proxy\fP, as they are
|
This option overrides any previous use of \fI-x/--proxy\fP, as they are
|
||||||
mutually exclusive.
|
mutually exclusive.
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
.\" * $Id$
|
.\" * $Id$
|
||||||
.\" **************************************************************************
|
.\" **************************************************************************
|
||||||
.\"
|
.\"
|
||||||
.TH curl_easy_setopt 3 "4 Jan 2008" "libcurl 7.17.2" "libcurl Manual"
|
.TH curl_easy_setopt 3 "5 Jan 2008" "libcurl 7.17.2" "libcurl Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
curl_easy_setopt \- set options for a curl easy handle
|
curl_easy_setopt \- set options for a curl easy handle
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -431,10 +431,9 @@ specified in the proxy string \fICURLOPT_PROXY\fP.
|
||||||
.IP CURLOPT_PROXYTYPE
|
.IP CURLOPT_PROXYTYPE
|
||||||
Pass a long with this option to set type of the proxy. Available options for
|
Pass a long with this option to set type of the proxy. Available options for
|
||||||
this are \fICURLPROXY_HTTP\fP, \fICURLPROXY_SOCKS4\fP (added in 7.15.2),
|
this are \fICURLPROXY_HTTP\fP, \fICURLPROXY_SOCKS4\fP (added in 7.15.2),
|
||||||
\fICURLPROXY_SOCKS5\fP and \fICURLPROXY_SOCKS4A\fP (added in 7.17.2). The HTTP
|
\fICURLPROXY_SOCKS5\fP, \fICURLPROXY_SOCKS4A\fP (added in 7.17.2) and
|
||||||
type is default. (Added in 7.10)
|
\fICURLPROXY_SOCKS5_HOSTNAME\fP (added in 7.17.2). The HTTP type is
|
||||||
|
default. (Added in 7.10)
|
||||||
See also \fIURLOPT_SOCKS5_RESOLVE_LOCAL\fP.
|
|
||||||
.IP CURLOPT_HTTPPROXYTUNNEL
|
.IP CURLOPT_HTTPPROXYTUNNEL
|
||||||
Set the parameter to non-zero to get the library to tunnel all operations
|
Set the parameter to non-zero to get the library to tunnel all operations
|
||||||
through a given HTTP proxy. There is a big difference between using a proxy
|
through a given HTTP proxy. There is a big difference between using a proxy
|
||||||
|
|
|
@ -499,7 +499,10 @@ typedef enum {
|
||||||
CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already
|
CURLPROXY_SOCKS4 = 4, /* support added in 7.15.2, enum existed already
|
||||||
in 7.10 */
|
in 7.10 */
|
||||||
CURLPROXY_SOCKS5 = 5, /* added in 7.10 */
|
CURLPROXY_SOCKS5 = 5, /* added in 7.10 */
|
||||||
CURLPROXY_SOCKS4A = 6 /* added in 7.17.2 */
|
CURLPROXY_SOCKS4A = 6, /* added in 7.17.2 */
|
||||||
|
CURLPROXY_SOCKS5_HOSTNAME = 7 /* Use the SOCKS5 protocol but pass along the
|
||||||
|
host name rather than the IP address. added
|
||||||
|
in 7.17.2 */
|
||||||
} curl_proxytype; /* this enum was added in 7.10 */
|
} curl_proxytype; /* this enum was added in 7.10 */
|
||||||
|
|
||||||
#define CURLAUTH_NONE 0 /* nothing */
|
#define CURLAUTH_NONE 0 /* nothing */
|
||||||
|
@ -1172,11 +1175,6 @@ typedef enum {
|
||||||
/* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
|
/* set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */
|
||||||
CINIT(PROXY_TRANSFER_MODE, LONG, 166),
|
CINIT(PROXY_TRANSFER_MODE, LONG, 166),
|
||||||
|
|
||||||
/* Set using of SOCKS5 to resolve host names locally instead of sending them
|
|
||||||
to the proxy to let it resolve them. Valid only if CURLOPT_PROXYTYPE ==
|
|
||||||
CURLPROXY_SOCKS5, otherwise ignored. */
|
|
||||||
CINIT(SOCKS5_RESOLVE_LOCAL, LONG, 167),
|
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unused */
|
CURLOPT_LASTENTRY /* the last unused */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
|
|
|
@ -390,7 +390,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
curl_socket_t sock = conn->sock[sockindex];
|
curl_socket_t sock = conn->sock[sockindex];
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
long timeout;
|
long timeout;
|
||||||
bool socks5_resolve_local = data->set.socks5_resolve_local;
|
bool socks5_resolve_local = data->set.proxytype == CURLPROXY_SOCKS5;
|
||||||
const size_t hostname_len = strlen(hostname);
|
const size_t hostname_len = strlen(hostname);
|
||||||
int packetsize = 0;
|
int packetsize = 0;
|
||||||
|
|
||||||
|
|
|
@ -2054,14 +2054,6 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLOPT_SOCKS5_RESOLVE_LOCAL:
|
|
||||||
/*
|
|
||||||
* Enable or disable using of SOCKS5 proxy server to resolve domain names
|
|
||||||
* instead of using platform API like gethostbyname_r etc
|
|
||||||
*/
|
|
||||||
data->set.socks5_resolve_local = (bool)(0 != va_arg(param, long));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* unknown tag and its companion, just ignore: */
|
/* unknown tag and its companion, just ignore: */
|
||||||
result = CURLE_FAILED_INIT; /* correct this */
|
result = CURLE_FAILED_INIT; /* correct this */
|
||||||
|
|
|
@ -1441,9 +1441,6 @@ struct UserDefined {
|
||||||
long new_directory_perms; /* Permissions to use when creating remote dirs */
|
long new_directory_perms; /* Permissions to use when creating remote dirs */
|
||||||
bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
|
bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
|
||||||
via an HTTP proxy */
|
via an HTTP proxy */
|
||||||
bool socks5_resolve_local; /* resolve host names locally even if a SOCKS5
|
|
||||||
proxy in use. Valid only if CURLOPT_PROXYTYPE
|
|
||||||
== CURLPROXY_SOCKS5, otherwise ignored. */
|
|
||||||
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
|
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
24
src/main.c
24
src/main.c
|
@ -480,8 +480,6 @@ struct Configurable {
|
||||||
bool raw;
|
bool raw;
|
||||||
bool post301;
|
bool post301;
|
||||||
bool nokeepalive;
|
bool nokeepalive;
|
||||||
bool socks5_resolve_local; /* don't use SOCKS5 proxy server to resolve
|
|
||||||
domain names */
|
|
||||||
struct OutStruct *outs;
|
struct OutStruct *outs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -713,10 +711,10 @@ static void help(void)
|
||||||
" --retry-max-time <seconds> Retry only within this period",
|
" --retry-max-time <seconds> Retry only within this period",
|
||||||
" -s/--silent Silent mode. Don't output anything",
|
" -s/--silent Silent mode. Don't output anything",
|
||||||
" -S/--show-error Show error. With -s, make curl show errors when they occur",
|
" -S/--show-error Show error. With -s, make curl show errors when they occur",
|
||||||
" --socks4 <host[:port]> Use SOCKS4 proxy on given host + port",
|
" --socks4 <host[:port]> SOCKS4 proxy on given host + port",
|
||||||
" --socks4a <host[:port]> Use SOCKS4a proxy on given host + port",
|
" --socks4a <host[:port]> SOCKS4a proxy on given host + port",
|
||||||
" --socks5 <host[:port]> Use SOCKS5 proxy and let the proxy resolve names",
|
" --socks5-hostname <host[:port]> SOCKS5 proxy, pass name instead of IP",
|
||||||
" --socks5ip <host[:port]> Use SOCKS5 proxy on given host + port",
|
" --socks5 <host[:port]> SOCKS5 proxy on given host + port",
|
||||||
" --stderr <file> Where to redirect stderr. - means stdout",
|
" --stderr <file> Where to redirect stderr. - means stdout",
|
||||||
" -t/--telnet-option <OPT=val> Set telnet option",
|
" -t/--telnet-option <OPT=val> Set telnet option",
|
||||||
" --trace <file> Write a debug trace to the given file",
|
" --trace <file> Write a debug trace to the given file",
|
||||||
|
@ -1906,11 +1904,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||||
free(config->ftpport);
|
free(config->ftpport);
|
||||||
config->ftpport = NULL;
|
config->ftpport = NULL;
|
||||||
break;
|
break;
|
||||||
case 'c': /* --socks5ip specifies a socks5 proxy to use, but resolves
|
case 'c': /* --socks5 specifies a socks5 proxy to use, and resolves
|
||||||
the name locally and passes on the resolved address */
|
the name locally and passes on the resolved address */
|
||||||
GetStr(&config->socksproxy, nextarg);
|
GetStr(&config->socksproxy, nextarg);
|
||||||
config->socksver = CURLPROXY_SOCKS5;
|
config->socksver = CURLPROXY_SOCKS5;
|
||||||
config->socks5_resolve_local = TRUE;
|
|
||||||
break;
|
break;
|
||||||
case 't': /* --socks4 specifies a socks4 proxy to use */
|
case 't': /* --socks4 specifies a socks4 proxy to use */
|
||||||
GetStr(&config->socksproxy, nextarg);
|
GetStr(&config->socksproxy, nextarg);
|
||||||
|
@ -1920,11 +1917,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
|
||||||
GetStr(&config->socksproxy, nextarg);
|
GetStr(&config->socksproxy, nextarg);
|
||||||
config->socksver = CURLPROXY_SOCKS4A;
|
config->socksver = CURLPROXY_SOCKS4A;
|
||||||
break;
|
break;
|
||||||
case '2': /* --socks5 specifies a socks5 proxy and enables name resolving
|
case '2': /* --socks5-hostname specifies a socks5 proxy and enables name
|
||||||
with the proxy */
|
resolving with the proxy */
|
||||||
GetStr(&config->socksproxy, nextarg);
|
GetStr(&config->socksproxy, nextarg);
|
||||||
config->socksver = CURLPROXY_SOCKS5;
|
config->socksver = CURLPROXY_SOCKS5_HOSTNAME;
|
||||||
config->socks5_resolve_local = FALSE;
|
|
||||||
break;
|
break;
|
||||||
case 'd': /* --tcp-nodelay option */
|
case 'd': /* --tcp-nodelay option */
|
||||||
config->tcp_nodelay ^= TRUE;
|
config->tcp_nodelay ^= TRUE;
|
||||||
|
@ -4511,10 +4507,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
||||||
if(config->socksproxy) {
|
if(config->socksproxy) {
|
||||||
my_setopt(curl, CURLOPT_PROXY, config->socksproxy);
|
my_setopt(curl, CURLOPT_PROXY, config->socksproxy);
|
||||||
my_setopt(curl, CURLOPT_PROXYTYPE, config->socksver);
|
my_setopt(curl, CURLOPT_PROXYTYPE, config->socksver);
|
||||||
if(config->socksver==CURLPROXY_SOCKS5)
|
|
||||||
/* added in 7.17.2 */
|
|
||||||
my_setopt(curl, CURLOPT_SOCKS5_RESOLVE_LOCAL,
|
|
||||||
config->socks5_resolve_local);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* curl 7.13.0 */
|
/* curl 7.13.0 */
|
||||||
|
|
Loading…
Reference in New Issue