Our warning now is much more specific, mentioning proxy type/addr/port.

Not included in the previous commit, because the implementation is
ugly; I see no other way of doing this though.
This commit is contained in:
George Kadianakis 2011-06-14 03:27:07 +02:00
parent a79bea40d8
commit abe03f4943
4 changed files with 59 additions and 6 deletions

View File

@ -66,6 +66,8 @@ static void set_constrained_socket_buffers(tor_socket_t sock, int size);
static const char *connection_proxy_state_to_string(int state); static const char *connection_proxy_state_to_string(int state);
static int connection_read_https_proxy_response(connection_t *conn); static int connection_read_https_proxy_response(connection_t *conn);
static void connection_send_socks5_connect(connection_t *conn); static void connection_send_socks5_connect(connection_t *conn);
static const char *proxy_type_to_string(int proxy_type);
/** The last IPv4 address that our network interface seemed to have been /** The last IPv4 address that our network interface seemed to have been
* binding to, in host order. We use this to detect when our IP changes. */ * binding to, in host order. We use this to detect when our IP changes. */
@ -4099,3 +4101,54 @@ assert_connection_ok(connection_t *conn, time_t now)
} }
} }
void
log_failed_proxy_connection(connection_t *conn)
{
or_options_t *options = get_options();
int proxy_type;
tor_addr_t proxy_addr;
int proxy_port;
if (options->HTTPSProxy) {
tor_addr_copy(&proxy_addr, &options->HTTPSProxyAddr);
proxy_port = options->HTTPSProxyPort;
proxy_type = PROXY_CONNECT;
} else if (options->Socks4Proxy) {
tor_addr_copy(&proxy_addr, &options->Socks4ProxyAddr);
proxy_port = options->Socks4ProxyPort;
proxy_type = PROXY_SOCKS4;
} else if (options->Socks5Proxy) {
tor_addr_copy(&proxy_addr, &options->Socks5ProxyAddr);
proxy_port = options->Socks5ProxyPort;
proxy_type = PROXY_SOCKS5;
} else if (options->ClientTransportPlugin) {
transport_info_t *transport;
transport = find_transport_by_bridge_addrport(&conn->addr, conn->port);
if (transport) {
tor_addr_copy(&proxy_addr, &transport->addr);
proxy_port = transport->port;
proxy_type = PROXY_PLUGGABLE;
} else
return;
} else
tor_assert(0);
log_warn(LD_NET,
"The connection to the %s proxy server at %s:%u just failed. "
"Make sure that the proxy server is up and running.",
proxy_type_to_string(proxy_type), fmt_addr(&proxy_addr),
proxy_port);
}
static const char *
proxy_type_to_string(int proxy_type)
{
switch (proxy_type) {
case PROXY_CONNECT: return "HTTP";
case PROXY_SOCKS4: return "SOCKS4";
case PROXY_SOCKS5: return "SOCKS5";
case PROXY_PLUGGABLE: return "pluggable transports SOCKS";
case PROXY_NONE: return "NULL"; /* probably a bug */
default: tor_assert(0);
}
}

View File

@ -57,6 +57,7 @@ int connection_connect(connection_t *conn, const char *address,
int connection_proxy_connect(connection_t *conn, int type); int connection_proxy_connect(connection_t *conn, int type);
int connection_read_proxy_handshake(connection_t *conn); int connection_read_proxy_handshake(connection_t *conn);
void log_failed_proxy_connection(connection_t *conn);
int retry_all_listeners(smartlist_t *replaced_conns, int retry_all_listeners(smartlist_t *replaced_conns,
smartlist_t *new_conns); smartlist_t *new_conns);

View File

@ -761,11 +761,8 @@ conn_close_if_marked(int i)
/* If the connection we are about to close was trying to connect to /* 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 a proxy server and failed, the client won't be able to use that
proxy. We should warn him about this. */ proxy. We should warn him about this. */
if (conn->proxy_state == PROXY_INFANT) { if (conn->proxy_state == PROXY_INFANT)
log_warn(LD_NET, log_failed_proxy_connection(conn);
"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_HAS_BUFFEREVENT(conn, goto unlink);
if ((SOCKET_OK(conn->s) || conn->linked_conn) && if ((SOCKET_OK(conn->s) || conn->linked_conn) &&

View File

@ -230,6 +230,8 @@ typedef enum {
#define PROXY_CONNECT 1 #define PROXY_CONNECT 1
#define PROXY_SOCKS4 2 #define PROXY_SOCKS4 2
#define PROXY_SOCKS5 3 #define PROXY_SOCKS5 3
/* pluggable transports proxy type */
#define PROXY_PLUGGABLE 4
/* Proxy client handshake states */ /* Proxy client handshake states */
/* We use a proxy but we haven't even connected to it yet. */ /* We use a proxy but we haven't even connected to it yet. */