[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] We can now connect using transports as well!



commit 29203b7f3f6d07dec1cede65f118aa450ac7712d
Author: George Kadianakis <desnacked@xxxxxxxxx>
Date:   Sun Jun 12 00:14:11 2011 +0200

    We can now connect using transports as well!
---
 src/or/circuitbuild.c  |   21 +++++++++++++++++++++
 src/or/circuitbuild.h  |    3 +++
 src/or/connection_or.c |   18 ++++++++++++++++++
 3 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index c07e890..21018dc 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -100,6 +100,7 @@ static int count_acceptable_nodes(smartlist_t *routers);
 static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
 
 static void entry_guards_changed(void);
+static void transport_free(transport_info_t *transport);
 
 /**
  * This function decides if CBT learning should be disabled. It returns
@@ -4803,6 +4804,26 @@ find_bridge_by_digest(const char *digest)
   return NULL;
 }
 
+/** If <b>addr</b> and <b>port</b> match one of our known bridges,
+ *  returns it's transport protocol if it has one, else returns NULL.
+ */
+transport_info_t *
+find_bridge_transport_by_addrport(const tor_addr_t *addr, uint16_t port)
+{
+  SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, bridge)
+    {
+      if (tor_addr_eq(&bridge->addr, addr) &&
+          (bridge->port == port)) {
+        if (bridge->transport) {
+          log_debug(LD_GENERAL, "Found matching bridge!\n");
+          return bridge->transport;
+        } else /* bridge found, but it had no transport */
+          return NULL;
+      }
+    } SMARTLIST_FOREACH_END(bridge);
+  return NULL;
+}
+
 /** We need to ask <b>bridge</b> for its server descriptor. */
 static void
 launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index eb6fdba..047de11 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -148,5 +148,8 @@ void clear_transport_list(void);
 int match_bridges_with_transports(void);
 void transport_add_from_config(const tor_addr_t *addr, uint16_t port,
                                const char *name, int socks_ver);
+transport_info_t *
+find_bridge_transport_by_addrport(const tor_addr_t *addr, uint16_t port);
+
 #endif
 
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 73aad7e..7cfe2e7 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -335,6 +335,14 @@ connection_or_finished_connecting(or_connection_t *or_conn)
     proxy_type = PROXY_SOCKS4;
   else if (get_options()->Socks5Proxy)
     proxy_type = PROXY_SOCKS5;
+  else if (get_options()->UseBridges) {
+    transport_info_t *transport;
+    transport = find_bridge_transport_by_addrport(&conn->addr,conn->port);
+    if (transport) { /* this bridge supports transports. use proxy. */
+      log_warn(LD_GENERAL, "Setting up pluggable transport plugin proxy type!\n");
+      proxy_type = transport->socks_version;
+    }
+  }
 
   if (proxy_type != PROXY_NONE) {
     /* start proxy handshake */
@@ -861,6 +869,16 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
     using_proxy = 1;
     tor_addr_copy(&addr, &options->Socks5ProxyAddr);
     port = options->Socks5ProxyPort;
+  } else if (options->ClientTransportPlugin) {
+    transport_info_t *transport;
+    transport = find_bridge_transport_by_addrport(&addr, port);
+    if (transport) {
+      log_warn(LD_GENERAL, "Our bridge uses a pluggable transport plugin. "
+               "Setting up proxying!");
+      using_proxy = 1;
+      tor_addr_copy(&addr, &transport->addr);
+      port = transport->port;
+    }
   }
 
   switch (connection_connect(TO_CONN(conn), conn->_base.address,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits