commit 8b9f4d75f27728ca5f07c1eb00d4144cb3b33eac Author: George Kadianakis desnacked@riseup.net Date: Thu Jul 12 15:28:43 2012 +0200
Address Nick's comments.
- Add a changes/ file. - Make it compile under --enable-gcc-warnings. - Update the file-level documentation of src/or/transports.c. - Only update descriptor if at least a managed proxy was configured. - Add our external IP address to the extra-info descriptor instead of 0.0.0.0. --- changes/bug3589 | 3 +++ src/or/circuitbuild.h | 6 ++++-- src/or/connection.c | 1 + src/or/router.c | 1 + src/or/transports.c | 39 ++++++++++++++++++++++++++++++--------- src/or/transports.h | 5 +++-- 6 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/changes/bug3589 b/changes/bug3589 new file mode 100644 index 0000000..eff2650 --- /dev/null +++ b/changes/bug3589 @@ -0,0 +1,3 @@ + o Major features: + - Bridges now report the pluggable transports they support to the + bridge authority. Implements ticket 3589. diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h index e6783d8..a7becce 100644 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@ -12,8 +12,6 @@ #ifndef _TOR_CIRCUITBUILD_H #define _TOR_CIRCUITBUILD_H
-#include "transports.h" - char *circuit_list_path(origin_circuit_t *circ, int verbose); char *circuit_list_path_for_controller(origin_circuit_t *circ); void circuit_log_path(int severity, unsigned int domain, @@ -136,6 +134,10 @@ void circuit_build_times_network_circ_success(circuit_build_times_t *cbt); /* DOCDOC circuit_build_times_get_bw_scale */ int circuit_build_times_get_bw_scale(networkstatus_t *ns);
+/* DOCDOC find_transport_name_by_bridge_addrport */ +const char *find_transport_name_by_bridge_addrport(const tor_addr_t *addr, + uint16_t port); +typedef struct transport_t transport_t; int find_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port, const transport_t **transport);
diff --git a/src/or/connection.c b/src/or/connection.c index af5c011..c9b16d7 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -34,6 +34,7 @@ #include "rendcommon.h" #include "rephist.h" #include "router.h" +#include "transports.h" #include "routerparse.h"
#ifdef USE_BUFFEREVENTS diff --git a/src/or/router.c b/src/or/router.c index 795afe2..df44a76 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -27,6 +27,7 @@ #include "router.h" #include "routerlist.h" #include "routerparse.h" +#include "transports.h"
/** * \file router.c diff --git a/src/or/transports.c b/src/or/transports.c index 2518846..dd07a91 100644 --- a/src/or/transports.c +++ b/src/or/transports.c @@ -39,13 +39,17 @@ * transport_t structs. * * When the managed proxy stops spitting METHOD lines (signified by a - * '{S,C}METHODS DONE' message) we register all the transports - * collected to the circuitbuild.c subsystem. At this point, the - * pointers to transport_t can be transformed into dangling pointers - * at any point by the circuitbuild.c subsystem, and so we replace all - * transport_t pointers with strings describing the transport names. - * We can still go from a transport name to a transport_t using the - * fact that each transport name uniquely identifies a transport_t. + * '{S,C}METHODS DONE' message) we pass copies of its transports to + * the bridge subsystem. We keep copies of the 'transport_t's on the + * managed proxy to be able to associate the proxy with its + * transports, and we pass copies to the bridge subsystem so that + * transports can be associated with bridges. + * [ XXX We should try see whether the two copies are really needed + * and maybe cut it into a single copy of the 'transport_t' shared + * between the managed proxy and the bridge subsystem. Preliminary + * analysis shows that both copies are needed with the current code + * logic, because of race conditions that can cause dangling + * pointers. ] * * <b>In even more detail, this is what happens when a SIGHUP * occurs:</b> @@ -530,6 +534,7 @@ launch_managed_proxy(managed_proxy_t *mp) void pt_configure_remaining_proxies(void) { + int at_least_a_proxy_config_finished = 0; smartlist_t *tmp = smartlist_new();
log_debug(LD_CONFIG, "Configuring remaining managed proxies (%d)!", @@ -567,13 +572,16 @@ pt_configure_remaining_proxies(void) if (!proxy_configuration_finished(mp)) configure_proxy(mp);
+ if (proxy_configuration_finished(mp)) + at_least_a_proxy_config_finished = 1; + } SMARTLIST_FOREACH_END(mp);
smartlist_free(tmp); check_if_restarts_needed = 0; assert_unconfigured_count_ok();
- if (!pt_proxies_configuration_pending()) + if (at_least_a_proxy_config_finished) mark_my_descriptor_dirty("configured managed proxies"); }
@@ -1400,9 +1408,22 @@ pt_get_extra_info_descriptor_string(void) tor_assert(mp->transports);
SMARTLIST_FOREACH_BEGIN(mp->transports, const transport_t *, t) { + /* If the transport proxy returned "0.0.0.0" as its address, and + * we know our external IP address, use it. Otherwise, use the + * returned address. */ + const char *addr_str = fmt_addr(&t->addr); + uint32_t external_ip_address = 0; + if (tor_addr_is_null(&t->addr) && + router_pick_published_address(get_options(), + &external_ip_address) >= 0) { + /* returned addr was 0.0.0.0 and we found our external IP + address: use it. */ + addr_str = fmt_addr32(external_ip_address); + } + smartlist_add_asprintf(string_chunks, "transport %s %s:%u", - t->name, fmt_addr(&t->addr), t->port); + t->name, addr_str, t->port); } SMARTLIST_FOREACH_END(t);
} SMARTLIST_FOREACH_END(mp); diff --git a/src/or/transports.h b/src/or/transports.h index 17d99dd..3fd97f8 100644 --- a/src/or/transports.h +++ b/src/or/transports.h @@ -12,12 +12,13 @@ #define TOR_TRANSPORTS_H
/** Represents a pluggable transport used by a bridge. */ -typedef struct { +typedef struct transport_t { /** SOCKS version: One of PROXY_SOCKS4, PROXY_SOCKS5. */ int socks_version; /** Name of pluggable transport protocol */ char *name; - /** Address of proxy */ + /** The IP address where the transport bound and is waiting for + * connections. */ tor_addr_t addr; /** Port of proxy */ uint16_t port;
tor-commits@lists.torproject.org