summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-01-27 18:33:33 +0000
committerRoger Dingledine <arma@torproject.org>2007-01-27 18:33:33 +0000
commitbaeeadb6ebef8788e456ef5db4dafa76bcd2f7c0 (patch)
treecae59d789eca97ecfa3c6dddb865a35e714c054b
parentc6fd3c7158ac56e358adb73bfc794370eb282918 (diff)
downloadtor-baeeadb6ebef8788e456ef5db4dafa76bcd2f7c0.tar.gz
tor-baeeadb6ebef8788e456ef5db4dafa76bcd2f7c0.zip
avoid messy crashes (bugfix by nick)
svn:r9435
-rw-r--r--src/or/routerlist.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 1f7fe4d72d..f177b153a0 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1053,7 +1053,7 @@ routerlist_sl_choose_by_bandwidth(smartlist_t *sl, int for_exit)
routerstatus_t *
routerstatus_sl_choose_by_bandwidth(smartlist_t *sl)
{
- return smartlist_choose_by_bandwidth(sl, 1, 0);
+ return smartlist_choose_by_bandwidth(sl, 1, 1);
}
/** Return a random running router from the routerlist. If any node
@@ -2630,6 +2630,25 @@ router_get_combined_status_by_nickname(const char *nickname,
return best;
}
+/** Find a routerstatus_t that corresponds to <b>hexdigest</b>, if
+ * any. Prefer ones that belong to authorities. */
+routerstatus_t *
+routerstatus_get_by_hexdigest(const char *hexdigest)
+{
+ char digest[DIGEST_LEN];
+ local_routerstatus_t *rs;
+ trusted_dir_server_t *ds;
+
+ if (strlen(hexdigest) < HEX_DIGEST_LEN ||
+ base16_decode(digest,DIGEST_LEN,hexdigest,HEX_DIGEST_LEN) < 0)
+ return NULL;
+ if ((ds = router_get_trusteddirserver_by_digest(digest)))
+ return &(ds->fake_status.status);
+ if ((rs = router_get_combined_status_by_digest(digest)))
+ return &(rs->status);
+ return NULL;
+}
+
/** Return true iff any networkstatus includes a descriptor whose digest
* is that of <b>desc</b>. */
static int