[tor-commits] [tor/master] Trivial code tweaks and documentation updates.

nickm at torproject.org nickm at torproject.org
Mon Jul 11 20:01:37 UTC 2011


commit 36468ec44b6dc3443b0142de83a100e2a853acf8
Author: George Kadianakis <desnacked at gmail.com>
Date:   Tue Jun 28 05:43:40 2011 +0200

    Trivial code tweaks and documentation updates.
---
 src/or/circuitbuild.c |   15 ++++++++-------
 src/or/config.c       |    6 +++---
 src/or/connection.c   |   26 ++++++++++++++++----------
 src/or/main.c         |    2 +-
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index b1f967b..7857eda 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -4565,7 +4565,7 @@ clear_bridge_list(void)
   smartlist_clear(bridge_list);
 }
 
-/** Free the transport_t <b>transport</b>. */
+/** Free the bridge <b>bridge</b>. */
 static void
 bridge_free(bridge_info_t *bridge)
 {
@@ -4590,7 +4590,7 @@ clear_transport_list(void)
   smartlist_clear(transport_list);
 }
 
-/** Free the transport_t <b>transport</b>. */
+/** Free the pluggable transport struct <b>transport</b>. */
 static void
 transport_free(transport_t *transport)
 {
@@ -4639,8 +4639,8 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
   tor_addr_copy(&t->addr, addr);
   t->port = port;
   t->name = tor_strdup(name);
-
   t->socks_version = socks_ver;
+
   if (!transport_list)
     transport_list = smartlist_create();
 
@@ -4662,13 +4662,14 @@ validate_pluggable_transports_config(void)
         /* Skip bridges without transports. */
         if (!b->transport_name)
           continue;
-        /* See if the user has Bridges that specify nonexistent 
+        /* See if the user has Bridges that specify nonexistent
            pluggable transports. We should warn the user in such case,
            since it's probably misconfiguration. */
         if (!transport_get_by_name(b->transport_name))
           log_warn(LD_CONFIG, "You have a Bridge line using the %s "
                    "pluggable transport, but there doesn't seem to be a "
-                   "corresponding ClientTransportPlugin line.", b->transport_name);
+                   "corresponding ClientTransportPlugin line.",
+                   b->transport_name);
       }  SMARTLIST_FOREACH_END(b);
   }
 }
@@ -4812,7 +4813,7 @@ find_bridge_by_digest(const char *digest)
 /** If <b>addr</b> and <b>port</b> match the address and port of a
  * bridge of ours that uses pluggable transports, place it's transport
  * in <b>transport</b>.
- *  
+ *
  * Return:
  * 0: if transport was found successfully.
  * 1: if <b>addr</b>:<b>port</b> did not match a bridge,
@@ -4820,7 +4821,7 @@ find_bridge_by_digest(const char *digest)
  * -1: if we should be using a transport, but the transport could not be found.
  */
 int
-find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, 
+find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
                                   transport_t **transport)
 {
   if (!bridge_list)
diff --git a/src/or/config.c b/src/or/config.c
index 41142b6..12320e0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -4680,8 +4680,7 @@ parse_client_transport_line(const char *line, int validate_only)
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
 
   if (smartlist_len(items) < 3) {
-    log_warn(LD_CONFIG, "parse_client_transport_line(): "
-              "Too few arguments on ClientTransportPlugin line.");
+    log_warn(LD_CONFIG, "Too few arguments on ClientTransportPlugin line.");
     goto err;
   }
 
@@ -4696,7 +4695,8 @@ parse_client_transport_line(const char *line, int validate_only)
   else if (!strcmp(socks_ver_str,"socks5"))
     socks_ver = PROXY_SOCKS5;
   else {
-    log_warn(LD_CONFIG, "Strange transport proxy type.");
+    log_warn(LD_CONFIG, "Strange ClientTransportPlugin proxy type '%s'.",
+             socks_ver_str);
     goto err;
   }
 
diff --git a/src/or/connection.c b/src/or/connection.c
index bfc901f..e086588 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4101,11 +4101,14 @@ assert_connection_ok(connection_t *conn, time_t now)
   }
 }
 
-/** Fills <b>addr</b> and <b>port</b> with the details of the proxy
- *  server of type <b>proxy_type</b> we are using.
- *  <b>conn</b> contains the connection_t we are using the proxy for.
- *  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
+/** Fills <b>addr</b> and <b>port</b> with the details of the global
+ *  proxy server we are using.
+ *  <b>conn</b> contains the connection we are using the proxy for.
+ *
+ *  Returns:
+ *  0: if we were successfull
+ *  1: if we are not using a proxy
+ *  -1: if we are using a proxy but its addrport could not be
  *  found. */
 int
 get_proxy_addrport(tor_addr_t *addr, uint16_t *port,
@@ -4131,19 +4134,22 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port,
     int r;
     r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
     if (r == 0) { /* transport found */
+      tor_assert(transport);
       tor_addr_copy(addr, &transport->addr);
       *port = transport->port;
+      goto done;
+    } else {
+      return r;
     }
-    return r;
   }
 
   return 1;
 
- done:
+ done: /* proxy found */
   return 0;
 }
 
-/** Returns the proxy type used by tor. */
+/** Returns the global proxy type used by tor. */
 static int
 get_proxy_type(void)
 {
@@ -4170,7 +4176,7 @@ log_failed_proxy_connection(connection_t *conn)
   uint16_t proxy_port;
 
   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,
            "The connection to the %s proxy server at %s:%u just failed. "
@@ -4188,7 +4194,7 @@ proxy_type_to_string(int proxy_type)
   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 */
+  case PROXY_NONE:      return "NULL";
   default:              tor_assert(0);
   }
 }
diff --git a/src/or/main.c b/src/or/main.c
index f456b03..4d43267 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -760,7 +760,7 @@ conn_close_if_marked(int i)
 
   /* 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. */
+  proxy. We should warn the user about this. */
   if (conn->proxy_state == PROXY_INFANT)
     log_failed_proxy_connection(conn);
 





More information about the tor-commits mailing list