aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-10-29 01:29:59 -0400
committerNick Mathewson <nickm@torproject.org>2013-10-29 01:29:59 -0400
commit4b6f074df9c540cb4847793b7e8243c8f642de0a (patch)
tree3e203c80bc1e1de0a226e9d30b076ecdb8c91d0b
parent49278cd68a0d84727ae1131e677bc3481b3e2fc7 (diff)
parent2235d65240ed1624d49a79891bc5ae564a6a4f34 (diff)
downloadtor-4b6f074df9c540cb4847793b7e8243c8f642de0a.tar
tor-4b6f074df9c540cb4847793b7e8243c8f642de0a.tar.gz
Merge remote-tracking branch 'public/bug5018'
Conflicts: src/or/entrynodes.c
-rw-r--r--changes/bug50183
-rw-r--r--src/or/config.c23
-rw-r--r--src/or/entrynodes.c17
-rw-r--r--src/or/entrynodes.h1
4 files changed, 39 insertions, 5 deletions
diff --git a/changes/bug5018 b/changes/bug5018
new file mode 100644
index 000000000..c5c12efab
--- /dev/null
+++ b/changes/bug5018
@@ -0,0 +1,3 @@
+ o Minor features:
+ - Don't launch pluggable transport proxies that contribute
+ transports we don't need. Resolves ticket 5018.
diff --git a/src/or/config.c b/src/or/config.c
index 95cede015..25db89f8a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -4568,7 +4568,8 @@ parse_bridge_line(const char *line)
* <b>line</b>. Return 0 if the line is well-formed, and -1 if it
* isn't.
*
- * If <b>validate_only</b> is 0, and the line is well-formed:
+ * If <b>validate_only</b> is 0, the line is well-formed, and the
+ * transport is needed by some bridge:
* - If it's an external proxy line, add the transport described in the line to
* our internal transport list.
* - If it's a managed proxy line, launch the managed proxy. */
@@ -4590,7 +4591,8 @@ parse_client_transport_line(const char *line, int validate_only)
int is_managed=0;
char **proxy_argv=NULL;
char **tmp=NULL;
- int proxy_argc,i;
+ int proxy_argc, i;
+ int is_useless_proxy=1;
int line_length;
@@ -4612,11 +4614,16 @@ parse_client_transport_line(const char *line, int validate_only)
smartlist_split_string(transport_list, transports, ",",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH_BEGIN(transport_list, const char *, transport_name) {
+ /* validate transport names */
if (!string_is_C_identifier(transport_name)) {
log_warn(LD_CONFIG, "Transport name is not a C identifier (%s).",
transport_name);
goto err;
}
+
+ /* see if we actually need the transports provided by this proxy */
+ if (!validate_only && transport_is_needed(transport_name))
+ is_useless_proxy = 0;
} SMARTLIST_FOREACH_END(transport_name);
/* field2 is either a SOCKS version or "exec" */
@@ -4635,9 +4642,15 @@ parse_client_transport_line(const char *line, int validate_only)
}
if (is_managed) { /* managed */
- if (!validate_only) { /* if we are not just validating, use the
- rest of the line as the argv of the proxy
- to be launched */
+ if (!validate_only && is_useless_proxy) {
+ log_warn(LD_GENERAL, "Pluggable transport proxy (%s) does not provide "
+ "any needed transports and will not be launched.", line);
+ }
+
+ /* If we are not just validating, use the rest of the line as the
+ argv of the proxy to be launched. Also, make sure that we are
+ only launching proxies that contribute useful transports. */
+ if (!validate_only && !is_useless_proxy) {
proxy_argc = line_length-2;
tor_assert(proxy_argc > 0);
proxy_argv = tor_malloc_zero(sizeof(char*)*(proxy_argc+1));
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 59cc9a3fc..ecc67f007 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1801,6 +1801,23 @@ bridge_resolve_conflicts(const tor_addr_t *addr, uint16_t port,
} SMARTLIST_FOREACH_END(bridge);
}
+/** Return True if we have a bridge that uses a transport with name
+ * <b>transport_name</b>. */
+int
+transport_is_needed(const char *transport_name)
+{
+ if (!bridge_list)
+ return 0;
+
+ SMARTLIST_FOREACH_BEGIN(bridge_list, const bridge_info_t *, bridge) {
+ if (bridge->transport_name &&
+ !strcmp(bridge->transport_name, transport_name))
+ return 1;
+ } SMARTLIST_FOREACH_END(bridge);
+
+ return 0;
+}
+
/** Register the bridge information in <b>bridge_line</b> to the
* bridge subsystem. Steals reference of <b>bridge_line</b>. */
void
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 1f8cff75a..772c6662d 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -123,6 +123,7 @@ struct transport_t;
int get_transport_by_bridge_addrport(const tor_addr_t *addr, uint16_t port,
const struct transport_t **transport);
+int transport_is_needed(const char *transport_name);
int validate_pluggable_transports_config(void);
double pathbias_get_close_success_count(entry_guard_t *guard);