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

[tor-commits] [tor/master] Add pluggable transport info to extra-info descriptors.



commit 9dea3a03b925f8cd83f2a975c4d5899f7691252d
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Thu Feb 23 17:51:48 2012 -0800

    Add pluggable transport info to extra-info descriptors.
---
 src/or/router.c     |    7 +++++++
 src/or/transports.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 src/or/transports.h |    2 ++
 3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/or/router.c b/src/or/router.c
index 352c456..795afe2 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2344,6 +2344,13 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
     }
   }
 
+  /* Add information about the pluggable transports we support. */
+  if (options->ServerTransportPlugin) {
+    char *pluggable_transports = pt_get_extra_info_descriptor_string();
+    if (pluggable_transports)
+      smartlist_add(chunks, pluggable_transports);
+  }
+
   if (should_record_bridge_info(options) && write_stats_to_extrainfo) {
     const char *bridge_stats = geoip_get_bridge_stats_extrainfo(now);
     if (bridge_stats) {
diff --git a/src/or/transports.c b/src/or/transports.c
index e0492b8..e5a5446 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -1373,6 +1373,51 @@ pt_prepare_proxy_list_for_config_read(void)
   tor_assert(unconfigured_proxies_n == 0);
 }
 
+/** Return the pluggable transport string that we should display in
+ *  our extra-info descriptor. If we shouldn't display such a string,
+ *  or we have nothing to display, return NULL. The string is
+ *  allocated on the heap and it's the responsibility of the caller to
+ *  free it. */
+char *
+pt_get_extra_info_descriptor_string(void)
+{
+  char *the_string = NULL;
+  smartlist_t *string_chunks = NULL;
+
+  if (!managed_proxy_list)
+    return NULL;
+
+  string_chunks = smartlist_new();
+
+  /* For each managed proxy, add its transports to the chunks list. */
+  SMARTLIST_FOREACH_BEGIN(managed_proxy_list,  const managed_proxy_t *, mp) {
+    if ((!mp->is_server) || (mp->conf_state != PT_PROTO_COMPLETED))
+      continue;
+
+    tor_assert(mp->transports);
+
+    SMARTLIST_FOREACH_BEGIN(mp->transports, const transport_t *, t) {
+      smartlist_add_asprintf(string_chunks,
+                             "method %s %s:%u",
+                             t->name, fmt_addr(&t->addr), t->port);
+    } SMARTLIST_FOREACH_END(t);
+
+  } SMARTLIST_FOREACH_END(mp);
+
+  if (smartlist_len(string_chunks) == 0) {
+    smartlist_free(string_chunks);
+    return NULL;
+  }
+
+  /* Join all the chunks into the final string. */
+  the_string = smartlist_join_strings(string_chunks, "\n", 1, NULL);
+
+  SMARTLIST_FOREACH(string_chunks, char *, s, tor_free(s));
+  smartlist_free(string_chunks);
+
+  return the_string;
+}
+
 /** The tor config was read.
  *  Destroy all managed proxies that were marked by a previous call to
  *  prepare_proxy_list_for_config_read() and are not used by the new
diff --git a/src/or/transports.h b/src/or/transports.h
index 39f7bf4..17d99dd 100644
--- a/src/or/transports.h
+++ b/src/or/transports.h
@@ -46,6 +46,8 @@ void pt_configure_remaining_proxies(void);
 
 int pt_proxies_configuration_pending(void);
 
+char *pt_get_extra_info_descriptor_string(void);
+
 void pt_free_all(void);
 
 void pt_prepare_proxy_list_for_config_read(void);



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