summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@gmail.com>2011-07-13 19:06:07 +0200
committerGeorge Kadianakis <desnacked@gmail.com>2011-07-13 19:06:07 +0200
commit5492de76dde34cb56c5658b6311772281c08c200 (patch)
treed79fa81821228e50b67353d8381882213b8468a4 /src/or/circuitbuild.c
parent9ba2d0e439e53f8307c808fe26e37b53892a604c (diff)
downloadtor-5492de76dde34cb56c5658b6311772281c08c200.tar.gz
tor-5492de76dde34cb56c5658b6311772281c08c200.zip
Put some last missing pieces together.
* Add some utility transport functions in circuitbuild.[ch] so that we can use them from pt.c. * Make the accounting system consider traffic coming from proxies. * Make sure that we only fetch bridge descriptors when all the transports are configured.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c65
1 files changed, 47 insertions, 18 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index aa0e996d17..f9b5c38256 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -26,6 +26,7 @@
#include "nodelist.h"
#include "onion.h"
#include "policies.h"
+#include "pluggable_transports.h"
#include "relay.h"
#include "rephist.h"
#include "router.h"
@@ -124,7 +125,6 @@ static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
static void entry_guards_changed(void);
static const transport_t *transport_get_by_name(const char *name);
-static void transport_free(transport_t *transport);
static void bridge_free(bridge_info_t *bridge);
/**
@@ -4591,7 +4591,7 @@ clear_transport_list(void)
}
/** Free the pluggable transport struct <b>transport</b>. */
-static void
+void
transport_free(transport_t *transport)
{
if (!transport)
@@ -4619,29 +4619,35 @@ transport_get_by_name(const char *name)
return NULL;
}
-/** Remember a new pluggable transport proxy at <b>addr</b>:<b>port</b>.
- * <b>name</b> is set to the name of the protocol this proxy uses.
- * <b>socks_ver</b> is set to the SOCKS version of the proxy.
- *
- * Returns 0 on success, -1 on fail. */
-int
-transport_add_from_config(const tor_addr_t *addr, uint16_t port,
- const char *name, int socks_ver)
+/** Returns a transport_t struct for a transport proxy supporting the
+ protocol <b>name</b> listening at <b>addr</b>:<b>port</b> using
+ SOCKS version <b>socks_ver</b>. */
+transport_t *
+transport_create(const tor_addr_t *addr, uint16_t port,
+ const char *name, int socks_ver)
{
- transport_t *t;
+ transport_t *t = tor_malloc_zero(sizeof(transport_t));
- if (transport_get_by_name(name)) { /* check for duplicate names */
- log_warn(LD_CONFIG, "More than one transport has '%s' as "
- "its name.", name);
- return -1;
- }
-
- t = tor_malloc_zero(sizeof(transport_t));
tor_addr_copy(&t->addr, addr);
t->port = port;
t->name = tor_strdup(name);
t->socks_version = socks_ver;
+ return t;
+}
+
+/** Adds transport <b>t</b> to the internal list of pluggable transports. */
+int
+transport_add(transport_t *t)
+{
+ assert(t);
+
+ if (transport_get_by_name(t->name)) { /* check for duplicate names */
+ log_notice(LD_CONFIG, "More than one transports have '%s' as "
+ "their name.", t->name);
+ return -1;
+ }
+
if (!transport_list)
transport_list = smartlist_create();
@@ -4649,6 +4655,23 @@ transport_add_from_config(const tor_addr_t *addr, uint16_t port,
return 0;
}
+/** Remember a new pluggable transport proxy at <b>addr</b>:<b>port</b>.
+ * <b>name</b> is set to the name of the protocol this proxy uses.
+ * <b>socks_ver</b> is set to the SOCKS version of the proxy. */
+int
+transport_add_from_config(const tor_addr_t *addr, uint16_t port,
+ const char *name, int socks_ver)
+{
+ transport_t *t = transport_create(addr, port, name, socks_ver);
+
+ if (transport_add(t) < 0) {
+ transport_free(t);
+ return -1;
+ } else {
+ return 0;
+ }
+}
+
/** Warns the user of possible pluggable transport misconfiguration. */
void
validate_pluggable_transports_config(void)
@@ -4897,6 +4920,12 @@ fetch_bridge_descriptors(or_options_t *options, time_t now)
if (!bridge_list)
return;
+ /* ASN Should we move this to launch_direct_bridge_descriptor_fetch() ? */
+ /* If we still have unconfigured managed proxies, don't go and
+ connect to a bridge. */
+ if (pt_proxies_configuration_pending())
+ return;
+
SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, bridge)
{
if (!download_status_is_ready(&bridge->fetch_status, now,