mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
We now warn the user if a proxy server is not up when we try to connect with it.
This commit is contained in:
parent
00ec4b2c00
commit
a79bea40d8
@ -3565,8 +3565,17 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
||||
}
|
||||
}
|
||||
|
||||
if (options->Socks4Proxy && options->Socks5Proxy)
|
||||
REJECT("You cannot specify both Socks4Proxy and SOCKS5Proxy");
|
||||
/* Check if more than one proxy type has been enabled. This looks REALLY ugly! */
|
||||
if ((options->Socks4Proxy && (options->Socks5Proxy || options->HTTPSProxy
|
||||
|| options->ClientTransportPlugin)) ||
|
||||
(options->Socks5Proxy && (options->Socks4Proxy || options->HTTPSProxy
|
||||
|| options->ClientTransportPlugin)) ||
|
||||
(options->HTTPSProxy && (options->Socks4Proxy || options->Socks5Proxy
|
||||
|| options->ClientTransportPlugin)) ||
|
||||
(options->ClientTransportPlugin && (options->Socks4Proxy
|
||||
|| options->Socks5Proxy || options->HTTPSProxy)))
|
||||
REJECT("You have configured more than one proxy types. "
|
||||
"(Socks4Proxy|Socks5Proxy|HTTPSProxy|ClientTransportPlugin)");
|
||||
|
||||
if (options->Socks5ProxyUsername) {
|
||||
size_t len;
|
||||
|
@ -1461,6 +1461,7 @@ connection_proxy_state_to_string(int state)
|
||||
static const char *unknown = "???";
|
||||
static const char *states[] = {
|
||||
"PROXY_NONE",
|
||||
"PROXY_INFANT",
|
||||
"PROXY_HTTPS_WANT_CONNECT_OK",
|
||||
"PROXY_SOCKS4_WANT_CONNECT_OK",
|
||||
"PROXY_SOCKS5_WANT_AUTH_METHOD_NONE",
|
||||
|
@ -837,7 +837,6 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
||||
or_connection_t *conn;
|
||||
or_options_t *options = get_options();
|
||||
int socket_error = 0;
|
||||
int using_proxy = 0;
|
||||
tor_addr_t addr;
|
||||
|
||||
tor_assert(_addr);
|
||||
@ -858,15 +857,15 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
||||
|
||||
/* use a proxy server if available */
|
||||
if (options->HTTPSProxy) {
|
||||
using_proxy = 1;
|
||||
conn->_base.proxy_state = PROXY_INFANT;
|
||||
tor_addr_copy(&addr, &options->HTTPSProxyAddr);
|
||||
port = options->HTTPSProxyPort;
|
||||
} else if (options->Socks4Proxy) {
|
||||
using_proxy = 1;
|
||||
conn->_base.proxy_state = PROXY_INFANT;
|
||||
tor_addr_copy(&addr, &options->Socks4ProxyAddr);
|
||||
port = options->Socks4ProxyPort;
|
||||
} else if (options->Socks5Proxy) {
|
||||
using_proxy = 1;
|
||||
conn->_base.proxy_state = PROXY_INFANT;
|
||||
tor_addr_copy(&addr, &options->Socks5ProxyAddr);
|
||||
port = options->Socks5ProxyPort;
|
||||
} else if (options->ClientTransportPlugin) {
|
||||
@ -874,7 +873,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
||||
transport = find_transport_by_bridge_addrport(&addr, port);
|
||||
if (transport) {
|
||||
log_debug(LD_GENERAL, "Found transport. Setting up proxying!");
|
||||
using_proxy = 1;
|
||||
conn->_base.proxy_state = PROXY_INFANT;
|
||||
tor_addr_copy(&addr, &transport->addr);
|
||||
port = transport->port;
|
||||
}
|
||||
@ -885,7 +884,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
|
||||
case -1:
|
||||
/* If the connection failed immediately, and we're using
|
||||
* a proxy, our proxy is down. Don't blame the Tor server. */
|
||||
if (!using_proxy)
|
||||
if (conn->_base.proxy_state == PROXY_INFANT)
|
||||
entry_guard_register_connect_status(conn->identity_digest,
|
||||
0, 1, time(NULL));
|
||||
connection_or_connect_failed(conn,
|
||||
|
@ -757,6 +757,16 @@ conn_close_if_marked(int i)
|
||||
#endif
|
||||
|
||||
log_debug(LD_NET,"Cleaning up connection (fd %d).",conn->s);
|
||||
|
||||
/* If the connection we are about to close was trying to connect to
|
||||
a proxy server and failed, the client won't be able to use that
|
||||
proxy. We should warn him about this. */
|
||||
if (conn->proxy_state == PROXY_INFANT) {
|
||||
log_warn(LD_NET,
|
||||
"The connection to a configured proxy server just failed. "
|
||||
"Make sure that the proxy server is up and running.");
|
||||
}
|
||||
|
||||
IF_HAS_BUFFEREVENT(conn, goto unlink);
|
||||
if ((SOCKET_OK(conn->s) || conn->linked_conn) &&
|
||||
connection_wants_to_flush(conn)) {
|
||||
|
25
src/or/or.h
25
src/or/or.h
@ -232,13 +232,24 @@ typedef enum {
|
||||
#define PROXY_SOCKS5 3
|
||||
|
||||
/* Proxy client handshake states */
|
||||
#define PROXY_HTTPS_WANT_CONNECT_OK 1
|
||||
#define PROXY_SOCKS4_WANT_CONNECT_OK 2
|
||||
#define PROXY_SOCKS5_WANT_AUTH_METHOD_NONE 3
|
||||
#define PROXY_SOCKS5_WANT_AUTH_METHOD_RFC1929 4
|
||||
#define PROXY_SOCKS5_WANT_AUTH_RFC1929_OK 5
|
||||
#define PROXY_SOCKS5_WANT_CONNECT_OK 6
|
||||
#define PROXY_CONNECTED 7
|
||||
/* We use a proxy but we haven't even connected to it yet. */
|
||||
#define PROXY_INFANT 1
|
||||
/* We use an HTTP proxy and we've sent the CONNECT command. */
|
||||
#define PROXY_HTTPS_WANT_CONNECT_OK 2
|
||||
/* We use a SOCKS4 proxy and we've sent the CONNECT command. */
|
||||
#define PROXY_SOCKS4_WANT_CONNECT_OK 3
|
||||
/* We use a SOCKS5 proxy and we try to negotiate without
|
||||
any authentication . */
|
||||
#define PROXY_SOCKS5_WANT_AUTH_METHOD_NONE 4
|
||||
/* We use a SOCKS5 proxy and we try to negotiate with
|
||||
Username/Password authentication . */
|
||||
#define PROXY_SOCKS5_WANT_AUTH_METHOD_RFC1929 5
|
||||
/* We use a SOCKS5 proxy and we just sent our credentials. */
|
||||
#define PROXY_SOCKS5_WANT_AUTH_RFC1929_OK 6
|
||||
/* We use a SOCKS5 proxy and we just sent our CONNECT command. */
|
||||
#define PROXY_SOCKS5_WANT_CONNECT_OK 7
|
||||
/* We use a proxy and we CONNECTed successfully!. */
|
||||
#define PROXY_CONNECTED 8
|
||||
|
||||
/** True iff <b>x</b> is an edge connection. */
|
||||
#define CONN_IS_EDGE(x) \
|
||||
|
Loading…
Reference in New Issue
Block a user