aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2010-07-30 21:39:08 +0200
committerSebastian Hahn <sebastian@torproject.org>2010-07-31 10:24:24 +0200
commit9ca311f6220cd52a0f8fcb3bc072cd9569bd1c6e (patch)
treedefbf6f9aaca735a3b748ec88f0d9da29ab649a1
parent7409929917a63b04a29e20cce054cf7bb7be4996 (diff)
downloadtor-9ca311f6220cd52a0f8fcb3bc072cd9569bd1c6e.tar
tor-9ca311f6220cd52a0f8fcb3bc072cd9569bd1c6e.tar.gz
Allow using regular relays as bridges
-rw-r--r--changes/relays_as_bridges5
-rw-r--r--src/or/routerlist.c27
2 files changed, 21 insertions, 11 deletions
diff --git a/changes/relays_as_bridges b/changes/relays_as_bridges
new file mode 100644
index 000000000..6e8afb005
--- /dev/null
+++ b/changes/relays_as_bridges
@@ -0,0 +1,5 @@
+ o Minor bugfixes:
+ - Allow the use of regular relays as bridges. To achieve this, replace
+ routers with a purpose other than bridge with bridge descriptors when
+ fetching them. Bugfix on 0.1.1.9-alpha; fixes bug 1776.
+
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5f98abe01..8808f56db 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -3151,15 +3151,23 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
id_digest = router->cache_info.identity_digest;
+ old_router = router_get_by_digest(id_digest);
+
/* Make sure that we haven't already got this exact descriptor. */
if (sdmap_get(routerlist->desc_digest_map,
router->cache_info.signed_descriptor_digest)) {
- log_info(LD_DIR,
- "Dropping descriptor that we already have for router '%s'",
- router->nickname);
- *msg = "Router descriptor was not new.";
- routerinfo_free(router);
- return ROUTER_WAS_NOT_NEW;
+ /* If we have this descriptor already and the new descriptor is a bridge
+ * descriptor, replace it. If we had a bridge descriptor before and the
+ * new one is not a bridge descriptor, don't replace it. */
+ if (old_router && (!routerinfo_is_a_configured_bridge(router) ||
+ routerinfo_is_a_configured_bridge(old_router))) {
+ log_info(LD_DIR,
+ "Dropping descriptor that we already have for router '%s'",
+ router->nickname);
+ *msg = "Router descriptor was not new.";
+ routerinfo_free(router);
+ return ROUTER_WAS_NOT_NEW;
+ }
}
if (authdir) {
@@ -3196,15 +3204,14 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
{
routerstatus_t *rs =
- networkstatus_v2_find_entry(ns, router->cache_info.identity_digest);
+ networkstatus_v2_find_entry(ns, id_digest);
if (rs && !memcmp(rs->descriptor_digest,
router->cache_info.signed_descriptor_digest,
DIGEST_LEN))
rs->need_to_mirror = 0;
});
if (consensus) {
- routerstatus_t *rs = networkstatus_vote_find_entry(consensus,
- router->cache_info.identity_digest);
+ routerstatus_t *rs = networkstatus_vote_find_entry(consensus, id_digest);
if (rs && !memcmp(rs->descriptor_digest,
router->cache_info.signed_descriptor_digest,
DIGEST_LEN)) {
@@ -3226,8 +3233,6 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
}
/* If we have a router with the same identity key, choose the newer one. */
- old_router = rimap_get(routerlist->identity_map,
- router->cache_info.identity_digest);
if (old_router) {
if (!in_consensus && (router->cache_info.published_on <=
old_router->cache_info.published_on)) {