[tor-commits] [tor/master] Remove get_bridge_pt_addrport().

nickm at torproject.org nickm at torproject.org
Thu Sep 11 03:42:52 UTC 2014


commit cd56b1a86ea255ba4bfc77959a88bfcd616ef516
Author: Yawning Angel <yawning at schwanenlied.me>
Date:   Thu May 1 03:30:09 2014 +0000

    Remove get_bridge_pt_addrport().
    
    The code was not disambiguating ClientTransportPlugin configured and
    not used, and ClientTransportPlugin configured, but in a failed state.
    
    The right thing to do is to undo moving the get_transport_by_addrport()
    call back into get_proxy_addrport(), and remove and explicit check for
    using a Bridge since by the time the check is made, if a Bridge is
    being used, it is PT/proxy-less.
---
 src/or/connection.c |   46 ++++++++++++----------------------------------
 1 file changed, 12 insertions(+), 34 deletions(-)

diff --git a/src/or/connection.c b/src/or/connection.c
index b32cddf..ff8cdf1 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -86,8 +86,6 @@ static int connection_read_https_proxy_response(connection_t *conn);
 static void connection_send_socks5_connect(connection_t *conn);
 static const char *proxy_type_to_string(int proxy_type);
 static int get_proxy_type(void);
-static int get_bridge_pt_addrport(tor_addr_t *addr, uint16_t *port,
-                                  int *proxy_type, const connection_t *conn);
 
 /** The last addresses that our network interface seemed to have been
  * binding to.  We use this as one way to detect when our IP changes.
@@ -4773,35 +4771,6 @@ assert_connection_ok(connection_t *conn, time_t now)
 }
 
 /** Fills <b>addr</b> and <b>port</b> with the details of the global
- *  pluggable transport or bridge we are using.
- *  <b>conn</b> contains the connection we are using the PT/bridge for.
- *
- * Return 0 on success, -1 on failure.
- */
-static int
-get_bridge_pt_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
-                       const connection_t *conn)
-{
-  const or_options_t *options = get_options();
-
-  if (options->ClientTransportPlugin || options->Bridges) {
-    const transport_t *transport = NULL;
-    int r;
-    r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
-    if (r<0)
-      return -1;
-    if (transport) { /* transport found */
-      tor_addr_copy(addr, &transport->addr);
-      *port = transport->port;
-      *proxy_type = transport->socks_version;
-      return 0;
-    }
-  }
-
-  return -1;
-}
-
-/** 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.
  *
@@ -4819,8 +4788,19 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
    * the config to have unused ClientTransportPlugin entries.
    */
   if (options->ClientTransportPlugin) {
-    if (get_bridge_pt_addrport(addr, port, proxy_type, conn) == 0)
+    const transport_t *transport = NULL;
+    int r;
+    r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
+    if (r<0)
+      return -1;
+    if (transport) { /* transport found */
+      tor_addr_copy(addr, &transport->addr);
+      *port = transport->port;
+      *proxy_type = transport->socks_version;
       return 0;
+    }
+
+    /* Unused ClientTransportPlugin. */
   }
 
   if (options->HTTPSProxy) {
@@ -4838,8 +4818,6 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
     *port = options->Socks5ProxyPort;
     *proxy_type = PROXY_SOCKS5;
     return 0;
-  } else if (options->Bridges) {
-    return get_bridge_pt_addrport(addr, port, proxy_type, conn);
   }
 
   tor_addr_make_unspec(addr);





More information about the tor-commits mailing list