[tor-commits] [tor/master] Use a more helpful log message when we can't find a proxy.

nickm at torproject.org nickm at torproject.org
Fri May 18 16:39:57 UTC 2012


commit 5dc9acb5e5d630372da991cb4c9569c593355273
Author: George Kadianakis <desnacked at riseup.net>
Date:   Fri May 18 03:07:46 2012 +0300

    Use a more helpful log message when we can't find a proxy.
---
 src/or/circuitbuild.c  |   15 +++++++++++++++
 src/or/circuitbuild.h  |    3 +++
 src/or/connection_or.c |   23 +++++++++++++++++++++--
 3 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 403f65f..82ff327 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -4972,6 +4972,21 @@ find_bridge_by_digest(const char *digest)
   return NULL;
 }
 
+const char *
+find_transport_name_by_bridge_addrport(const tor_addr_t *addr, uint16_t port)
+{
+  if (!bridge_list)
+    return NULL;
+
+  SMARTLIST_FOREACH_BEGIN(bridge_list, const bridge_info_t *, bridge) {
+    if (tor_addr_eq(&bridge->addr, addr) &&
+        (bridge->port == port))
+      return bridge->transport_name;
+  } SMARTLIST_FOREACH_END(bridge);
+
+  return NULL;
+}
+
 /** If <b>addr</b> and <b>port</b> match the address and port of a
  * bridge of ours that uses pluggable transports, place its transport
  * in <b>transport</b>.
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index a7fd208..2ef5be8 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -157,6 +157,9 @@ void transport_free(transport_t *transport);
 transport_t *transport_new(const tor_addr_t *addr, uint16_t port,
                                       const char *name, int socks_ver);
 
+const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr,
+                                                   uint16_t port);
+
 int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
                                       const transport_t **transport);
 transport_t *transport_get_by_name(const char *name);
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 0d3f9d8..81df70e 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1051,8 +1051,27 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
       conn->_base.proxy_state = PROXY_INFANT;
     }
   } else {
-    log_warn(LD_GENERAL, "Tried to connect through proxy, but proxy address "
-             "could not be found.");
+    /* get_proxy_addrport() might fail if we have a Bridge line that
+       references a transport, but no ClientTransportPlugin lines
+       defining its transport proxy. If this is the case, let's try to
+       output a useful log message to the user. */
+    const char *transport_name =
+      find_transport_name_by_bridge_addrport(&TO_CONN(conn)->addr,
+                                             TO_CONN(conn)->port);
+
+    if (transport_name) {
+      log_warn(LD_GENERAL, "We were supposed to connect to bridge '%s:%u' "
+               "using pluggable transport '%s', but it seems that we can't "
+               "find a pluggable transport proxy supporting '%s'. Please make "
+               "sure that your configuration file is valid.",
+               fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port,
+               transport_name, transport_name);
+    } else {
+      log_warn(LD_GENERAL, "Tried to connect to '%s:%u' through a proxy, but "
+               "the proxy address could not be found.",
+               fmt_addr(&TO_CONN(conn)->addr), TO_CONN(conn)->port);
+    }
+
     connection_free(TO_CONN(conn));
     return NULL;
   }





More information about the tor-commits mailing list