diff options
author | George Kadianakis <desnacked@riseup.net> | 2012-02-23 17:51:48 -0800 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2012-07-03 21:26:03 +0300 |
commit | 9dea3a03b925f8cd83f2a975c4d5899f7691252d (patch) | |
tree | 9c726de6d4374d403646ff5c1d7647ccea3c82b3 /src/or/transports.c | |
parent | 4bafe24400fa80d2bfc7c862924d8af04554e002 (diff) | |
download | tor-9dea3a03b925f8cd83f2a975c4d5899f7691252d.tar.gz tor-9dea3a03b925f8cd83f2a975c4d5899f7691252d.zip |
Add pluggable transport info to extra-info descriptors.
Diffstat (limited to 'src/or/transports.c')
-rw-r--r-- | src/or/transports.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/or/transports.c b/src/or/transports.c index e0492b8d6b..e5a54463de 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 |