}
}
- 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;
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",
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);
/* 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) {
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;
}
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,
#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)) {
#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) \