|
@@ -67,6 +67,7 @@ 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);
|
|
static const char *proxy_type_to_string(int proxy_type);
|
|
|
|
|
+static int get_proxy_type(void);
|
|
|
|
|
|
|
|
/** 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. */
|
|
@@ -4103,44 +4104,47 @@ assert_connection_ok(connection_t *conn, time_t now)
|
|
|
/** Fills <b>addr</b> and <b>port</b> with the details of the proxy
|
|
/** Fills <b>addr</b> and <b>port</b> with the details of the proxy
|
|
|
* server of type <b>proxy_type</b> we are using.
|
|
* server of type <b>proxy_type</b> we are using.
|
|
|
* <b>conn</b> contains the connection_t we are using the proxy for.
|
|
* <b>conn</b> contains the connection_t we are using the proxy for.
|
|
|
- * Returns 0 if we were successfull or returns 1 if we are not using
|
|
|
|
|
- * a proxy. */
|
|
|
|
|
|
|
+ * Returns 0 if we were successfull, 1 if we are not using
|
|
|
|
|
+ * a proxy, -1 if we are using a proxy but his addrport could not be
|
|
|
|
|
+ * found. */
|
|
|
int
|
|
int
|
|
|
-get_proxy_addrport(int proxy_type, tor_addr_t *addr, uint16_t *port,
|
|
|
|
|
|
|
+get_proxy_addrport(tor_addr_t *addr, uint16_t *port,
|
|
|
connection_t *conn)
|
|
connection_t *conn)
|
|
|
{
|
|
{
|
|
|
- or_options_t *options;
|
|
|
|
|
-
|
|
|
|
|
- if (proxy_type == PROXY_NONE)
|
|
|
|
|
- return 1;
|
|
|
|
|
-
|
|
|
|
|
- options = get_options();
|
|
|
|
|
|
|
+ or_options_t *options = get_options();
|
|
|
|
|
|
|
|
- if (proxy_type == PROXY_CONNECT) {
|
|
|
|
|
|
|
+ if (options->HTTPSProxy) {
|
|
|
tor_addr_copy(addr, &options->HTTPSProxyAddr);
|
|
tor_addr_copy(addr, &options->HTTPSProxyAddr);
|
|
|
*port = options->HTTPSProxyPort;
|
|
*port = options->HTTPSProxyPort;
|
|
|
- } else if (proxy_type == PROXY_SOCKS4) {
|
|
|
|
|
|
|
+ goto done;
|
|
|
|
|
+ } else if (options->Socks4Proxy) {
|
|
|
tor_addr_copy(addr, &options->Socks4ProxyAddr);
|
|
tor_addr_copy(addr, &options->Socks4ProxyAddr);
|
|
|
*port = options->Socks4ProxyPort;
|
|
*port = options->Socks4ProxyPort;
|
|
|
- } else if (proxy_type == PROXY_SOCKS5) {
|
|
|
|
|
|
|
+ goto done;
|
|
|
|
|
+ } else if (options->Socks5Proxy) {
|
|
|
tor_addr_copy(addr, &options->Socks5ProxyAddr);
|
|
tor_addr_copy(addr, &options->Socks5ProxyAddr);
|
|
|
*port = options->Socks5ProxyPort;
|
|
*port = options->Socks5ProxyPort;
|
|
|
- } else if (proxy_type == PROXY_PLUGGABLE) {
|
|
|
|
|
- transport_t *transport;
|
|
|
|
|
- transport = find_transport_by_bridge_addrport(&conn->addr, conn->port);
|
|
|
|
|
- if (transport) {
|
|
|
|
|
|
|
+ goto done;
|
|
|
|
|
+ } else if (options->ClientTransportPlugin ||
|
|
|
|
|
+ options->Bridges) {
|
|
|
|
|
+ transport_t *transport=NULL;
|
|
|
|
|
+ int r;
|
|
|
|
|
+ r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
|
|
|
|
|
+ if (r == 0) { /* transport found */
|
|
|
tor_addr_copy(addr, &transport->addr);
|
|
tor_addr_copy(addr, &transport->addr);
|
|
|
*port = transport->port;
|
|
*port = transport->port;
|
|
|
- } else { /* no transport for this bridge. */
|
|
|
|
|
- return 1;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ return r;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ return 1;
|
|
|
|
|
+
|
|
|
|
|
+ done:
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** Returns the proxy type used by tor. */
|
|
/** Returns the proxy type used by tor. */
|
|
|
-int
|
|
|
|
|
|
|
+static int
|
|
|
get_proxy_type(void)
|
|
get_proxy_type(void)
|
|
|
{
|
|
{
|
|
|
or_options_t *options = get_options();
|
|
or_options_t *options = get_options();
|
|
@@ -4162,18 +4166,16 @@ get_proxy_type(void)
|
|
|
void
|
|
void
|
|
|
log_failed_proxy_connection(connection_t *conn)
|
|
log_failed_proxy_connection(connection_t *conn)
|
|
|
{
|
|
{
|
|
|
- int proxy_type;
|
|
|
|
|
tor_addr_t proxy_addr;
|
|
tor_addr_t proxy_addr;
|
|
|
uint16_t proxy_port;
|
|
uint16_t proxy_port;
|
|
|
|
|
|
|
|
- proxy_type = get_proxy_type();
|
|
|
|
|
- if (get_proxy_addrport(proxy_type, &proxy_addr, &proxy_port, conn) != 0)
|
|
|
|
|
|
|
+ if (get_proxy_addrport(&proxy_addr, &proxy_port, conn) != 0)
|
|
|
return; /* if we have no proxy set up leave this function. */
|
|
return; /* if we have no proxy set up leave this function. */
|
|
|
|
|
|
|
|
log_warn(LD_NET,
|
|
log_warn(LD_NET,
|
|
|
"The connection to the %s proxy server at %s:%u just failed. "
|
|
"The connection to the %s proxy server at %s:%u just failed. "
|
|
|
"Make sure that the proxy server is up and running.",
|
|
"Make sure that the proxy server is up and running.",
|
|
|
- proxy_type_to_string(proxy_type), fmt_addr(&proxy_addr),
|
|
|
|
|
|
|
+ proxy_type_to_string(get_proxy_type()), fmt_addr(&proxy_addr),
|
|
|
proxy_port);
|
|
proxy_port);
|
|
|
}
|
|
}
|
|
|
|
|
|