Преглед изворни кода

Trivial code tweaks and documentation updates.

George Kadianakis пре 14 година
родитељ
комит
36468ec44b
4 измењених фајлова са 28 додато и 21 уклоњено
  1. 8 7
      src/or/circuitbuild.c
  2. 3 3
      src/or/config.c
  3. 16 10
      src/or/connection.c
  4. 1 1
      src/or/main.c

+ 8 - 7
src/or/circuitbuild.c

@@ -4565,7 +4565,7 @@ clear_bridge_list(void)
   smartlist_clear(bridge_list);
   smartlist_clear(bridge_list);
 }
 }
 
 
-/** Free the transport_t <b>transport</b>. */
+/** Free the bridge <b>bridge</b>. */
 static void
 static void
 bridge_free(bridge_info_t *bridge)
 bridge_free(bridge_info_t *bridge)
 {
 {
@@ -4590,7 +4590,7 @@ clear_transport_list(void)
   smartlist_clear(transport_list);
   smartlist_clear(transport_list);
 }
 }
 
 
-/** Free the transport_t <b>transport</b>. */
+/** Free the pluggable transport struct <b>transport</b>. */
 static void
 static void
 transport_free(transport_t *transport)
 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);
   tor_addr_copy(&t->addr, addr);
   t->port = port;
   t->port = port;
   t->name = tor_strdup(name);
   t->name = tor_strdup(name);
-
   t->socks_version = socks_ver;
   t->socks_version = socks_ver;
+
   if (!transport_list)
   if (!transport_list)
     transport_list = smartlist_create();
     transport_list = smartlist_create();
 
 
@@ -4662,13 +4662,14 @@ validate_pluggable_transports_config(void)
         /* Skip bridges without transports. */
         /* Skip bridges without transports. */
         if (!b->transport_name)
         if (!b->transport_name)
           continue;
           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,
            pluggable transports. We should warn the user in such case,
            since it's probably misconfiguration. */
            since it's probably misconfiguration. */
         if (!transport_get_by_name(b->transport_name))
         if (!transport_get_by_name(b->transport_name))
           log_warn(LD_CONFIG, "You have a Bridge line using the %s "
           log_warn(LD_CONFIG, "You have a Bridge line using the %s "
                    "pluggable transport, but there doesn't seem to be a "
                    "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);
       }  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
 /** 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
  * bridge of ours that uses pluggable transports, place it's transport
  * in <b>transport</b>.
  * in <b>transport</b>.
- *  
+ *
  * Return:
  * Return:
  * 0: if transport was found successfully.
  * 0: if transport was found successfully.
  * 1: if <b>addr</b>:<b>port</b> did not match a bridge,
  * 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.
  * -1: if we should be using a transport, but the transport could not be found.
  */
  */
 int
 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)
                                   transport_t **transport)
 {
 {
   if (!bridge_list)
   if (!bridge_list)

+ 3 - 3
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);
                          SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
 
 
   if (smartlist_len(items) < 3) {
   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;
     goto err;
   }
   }
 
 
@@ -4696,7 +4695,8 @@ parse_client_transport_line(const char *line, int validate_only)
   else if (!strcmp(socks_ver_str,"socks5"))
   else if (!strcmp(socks_ver_str,"socks5"))
     socks_ver = PROXY_SOCKS5;
     socks_ver = PROXY_SOCKS5;
   else {
   else {
-    log_warn(LD_CONFIG, "Strange transport proxy type.");
+    log_warn(LD_CONFIG, "Strange ClientTransportPlugin proxy type '%s'.",
+             socks_ver_str);
     goto err;
     goto err;
   }
   }
 
 

+ 16 - 10
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. */
  *  found. */
 int
 int
 get_proxy_addrport(tor_addr_t *addr, uint16_t *port,
 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;
     int r;
     r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
     r = find_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
     if (r == 0) { /* transport found */
     if (r == 0) { /* transport found */
+      tor_assert(transport);
       tor_addr_copy(addr, &transport->addr);
       tor_addr_copy(addr, &transport->addr);
       *port = transport->port;
       *port = transport->port;
+      goto done;
+    } else {
+      return r;
     }
     }
-    return r;
   }
   }
 
 
   return 1;
   return 1;
 
 
- done:
+ done: /* proxy found */
   return 0;
   return 0;
 }
 }
 
 
-/** Returns the proxy type used by tor. */
+/** Returns the global proxy type used by tor. */
 static int
 static int
 get_proxy_type(void)
 get_proxy_type(void)
 {
 {
@@ -4170,7 +4176,7 @@ log_failed_proxy_connection(connection_t *conn)
   uint16_t proxy_port;
   uint16_t proxy_port;
 
 
   if (get_proxy_addrport(&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. "
@@ -4188,7 +4194,7 @@ proxy_type_to_string(int proxy_type)
   case PROXY_SOCKS4:    return "SOCKS4";
   case PROXY_SOCKS4:    return "SOCKS4";
   case PROXY_SOCKS5:    return "SOCKS5";
   case PROXY_SOCKS5:    return "SOCKS5";
   case PROXY_PLUGGABLE: return "pluggable transports SOCKS";
   case PROXY_PLUGGABLE: return "pluggable transports SOCKS";
-  case PROXY_NONE:      return "NULL"; /* probably a bug */
+  case PROXY_NONE:      return "NULL";
   default:              tor_assert(0);
   default:              tor_assert(0);
   }
   }
 }
 }

+ 1 - 1
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
   /* 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 the user about this. */
   if (conn->proxy_state == PROXY_INFANT)
   if (conn->proxy_state == PROXY_INFANT)
     log_failed_proxy_connection(conn);
     log_failed_proxy_connection(conn);