aboutsummaryrefslogtreecommitdiff
path: root/src/or/transports.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-03-19 13:25:45 -0400
committerNick Mathewson <nickm@torproject.org>2013-03-19 13:25:45 -0400
commitc101ecc8dcc733fda31c0834f19c48d717ebe4c7 (patch)
tree53cbcd8c6b4290bd7d8c78fd2f58e791241864ab /src/or/transports.c
parent6e94d2fb3a11d7cba5796c1662e0c5089ad3e509 (diff)
parent9bdd33eae68b93db688c4537e5c11841a5d37a3b (diff)
downloadtor-c101ecc8dcc733fda31c0834f19c48d717ebe4c7.tar.gz
tor-c101ecc8dcc733fda31c0834f19c48d717ebe4c7.zip
Merge remote-tracking branch 'asn/bug3594_rebased_and_fixed'
Conflicts: src/common/util.c src/or/entrynodes.h
Diffstat (limited to 'src/or/transports.c')
-rw-r--r--src/or/transports.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/or/transports.c b/src/or/transports.c
index b5a00c90ec..0afba24ea0 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -95,6 +95,7 @@
#include "util.h"
#include "router.h"
#include "statefile.h"
+#include "entrynodes.h"
static process_environment_t *
create_managed_proxy_environment(const managed_proxy_t *mp);
@@ -1420,6 +1421,57 @@ pt_get_extra_info_descriptor_string(void)
return the_string;
}
+/** Stringify the SOCKS arguments in <b>socks_args</b> according to
+ * 180_pluggable_transport.txt. The string is allocated on the heap
+ * and it's the responsibility of the caller to free it after use. */
+char *
+pt_stringify_socks_args(const smartlist_t *socks_args)
+{
+ /* tmp place to store escaped socks arguments, so that we can
+ concatenate them up afterwards */
+ smartlist_t *sl_tmp = NULL;
+ char *escaped_string = NULL;
+ char *new_string = NULL;
+
+ tor_assert(socks_args);
+ tor_assert(smartlist_len(socks_args) > 0);
+
+ sl_tmp = smartlist_new();
+
+ SMARTLIST_FOREACH_BEGIN(socks_args, const char *, s) {
+ /* Escape ';' and '\'. */
+ escaped_string = tor_escape_str_for_socks_arg(s);
+ if (!escaped_string)
+ goto done;
+
+ smartlist_add(sl_tmp, escaped_string);
+ } SMARTLIST_FOREACH_END(s);
+
+ new_string = smartlist_join_strings(sl_tmp, ";", 0, NULL);
+
+ done:
+ SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
+ smartlist_free(sl_tmp);
+
+ return new_string;
+}
+
+/** Return a string of the SOCKS arguments that we should pass to the
+ * pluggable transports proxy in <b>addr</b>:<b>port</b> according to
+ * 180_pluggable_transport.txt. The string is allocated on the heap
+ * and it's the responsibility of the caller to free it after use. */
+char *
+pt_get_socks_args_for_proxy_addrport(const tor_addr_t *addr, uint16_t port)
+{
+ const smartlist_t *socks_args = NULL;
+
+ socks_args = get_socks_args_by_bridge_addrport(addr, port);
+ if (!socks_args)
+ return NULL;
+
+ return pt_stringify_socks_args(socks_args);
+}
+
/** 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