aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2013-06-12 17:12:39 +0300
committerNick Mathewson <nickm@torproject.org>2013-07-18 08:45:03 -0400
commit1ee3a0cf4440f34c024ff61a320e0b16553a3558 (patch)
tree9f116c2e14ecf8b5a1ee2c0fa20d87ba7d366fef /src/or
parent1a0cf08841904940ed46b2fcfd79cf65c65a1a6c (diff)
downloadtor-1ee3a0cf4440f34c024ff61a320e0b16553a3558.tar
tor-1ee3a0cf4440f34c024ff61a320e0b16553a3558.tar.gz
Place the options in the environment after processing them properly.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c20
-rw-r--r--src/or/config.h2
-rw-r--r--src/or/transports.c50
3 files changed, 71 insertions, 1 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 1f6d1db1c..4ddced8a6 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -4671,6 +4671,26 @@ get_transport_bindaddr_from_config(const char *transport)
return NULL;
}
+/** Given the name of a pluggable transport in <b>transport</b>, check
+ * the configuration file to see if the user has asked us to pass any
+ * parameters to the pluggable transport. Return a smartlist
+ * containing the parameters, otherwise NULL. */
+smartlist_t *
+get_options_for_server_transport(const char *transport)
+{
+ config_line_t *cl;
+ const or_options_t *options = get_options();
+
+ for (cl = options->ServerTransportOptions; cl; cl = cl->next) {
+ smartlist_t *options_sl =
+ get_options_from_transport_options_line(cl->value, transport);
+ if (options_sl)
+ return options_sl;
+ }
+
+ return NULL;
+}
+
/** Read the contents of a ServerTransportPlugin line from
* <b>line</b>. Return 0 if the line is well-formed, and -1 if it
* isn't.
diff --git a/src/or/config.h b/src/or/config.h
index 11e8109d9..9910f1873 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -114,7 +114,7 @@ void bridge_line_free(bridge_line_t *bridge_line);
bridge_line_t *parse_bridge_line(const char *line);
smartlist_t *get_options_from_transport_options_line(const char *line,
const char *transport);
-
+smartlist_t *get_options_for_server_transport(const char *transport);
#endif
diff --git a/src/or/transports.c b/src/or/transports.c
index 6b6882ae7..2b129cb0f 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -1100,6 +1100,48 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
return r;
}
+/** Return a newly allocated string that tor should place in
+ * TOR_PT_SERVER_TRANSPORT_OPTIONS while configuring the server
+ * manged proxy in <b>mp</b>. Return NULL if no such options are found. */
+static char *
+get_transport_options_for_server_proxy(const managed_proxy_t *mp)
+{
+ char *options_string = NULL;
+ smartlist_t *string_sl = smartlist_new();
+
+ tor_assert(mp->is_server);
+
+ /** Loop over the transports of the proxy. If we have options for
+ any of them, format them appropriately and place them in our
+ smartlist. Finally, join our smartlist to get the final
+ string. */
+ SMARTLIST_FOREACH_BEGIN(mp->transports_to_launch, const char *, transport) {
+ smartlist_t *options_tmp_sl = NULL;
+ options_tmp_sl = get_options_for_server_transport(transport);
+ if (!options_tmp_sl)
+ continue;
+
+ /** Loop over the options of this transport, escape them, and
+ place them in the smartlist. */
+ SMARTLIST_FOREACH_BEGIN(options_tmp_sl, const char *, options) {
+ char *escaped_opts = tor_escape_str_for_pt_args(options, ":;\\");
+ smartlist_add_asprintf(string_sl, "%s:%s",
+ transport, escaped_opts);
+ tor_free(escaped_opts);
+ } SMARTLIST_FOREACH_END(options);
+
+ SMARTLIST_FOREACH(options_tmp_sl, char *, c, tor_free(c));
+ smartlist_free(options_tmp_sl);
+ } SMARTLIST_FOREACH_END(transport);
+
+ options_string = smartlist_join_strings(string_sl, ";", 0, NULL);
+
+ SMARTLIST_FOREACH(string_sl, char *, t, tor_free(t));
+ smartlist_free(string_sl);
+
+ return options_string;
+}
+
/** Return the string that tor should place in TOR_PT_SERVER_BINDADDR
* while configuring the server managed proxy in <b>mp</b>. The
* string is stored in the heap, and it's the the responsibility of
@@ -1181,6 +1223,14 @@ create_managed_proxy_environment(const managed_proxy_t *mp)
tor_free(bindaddr_tmp);
}
+ {
+ char *server_transport_options =
+ get_transport_options_for_server_proxy(mp);
+ smartlist_add_asprintf(envs, "TOR_PT_SERVER_TRANSPORT_OPTIONS=%s",
+ server_transport_options);
+ tor_free(server_transport_options);
+ }
+
/* XXX024 Remove the '=' here once versions of obfsproxy which
* assert that this env var exists are sufficiently dead.
*