aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@torproject.org>2012-08-31 23:02:19 +0200
committerNick Mathewson <nickm@torproject.org>2012-09-04 11:56:34 -0400
commit68901da5a1dcfb210f7e8210af0b63c6161f9b63 (patch)
tree33bd54d0ffc4a4ba9d057fbe9b46628999ceba0d /src/or/dirserv.c
parent156ffef2494136d2fa0b1456a1c21cc29cbc3ff0 (diff)
downloadtor-68901da5a1dcfb210f7e8210af0b63c6161f9b63.tar
tor-68901da5a1dcfb210f7e8210af0b63c6161f9b63.tar.gz
Generate microdescriptors with "a" lines.
Generate and store all supported microdescriptor formats. Generate votes with one "m" line for each format. Only "m" lines with version info matching chosen consensus method will be voted upon. An optimisation would be to combine "m" lines with identical hashes, i.e. instead of "m 1,2,3 H1" and "m 4,5 H1", say "m 1,2,3,4,5 H1".
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 5814171c5..44e52914e 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -62,6 +62,16 @@ static cached_dir_t *the_directory = NULL;
/** For authoritative directories: the current (v1) network status. */
static cached_dir_t the_runningrouters;
+/** Array of start and end of consensus methods used for supported
+ microdescriptor formats. */
+static const struct consensus_method_range_t {
+ int low;
+ int high;
+} microdesc_consensus_methods[] = {
+ {MIN_METHOD_FOR_MICRODESC, MIN_METHOD_FOR_A_LINES - 1},
+ {MIN_METHOD_FOR_A_LINES, MAX_SUPPORTED_CONSENSUS_METHOD},
+ {-1, -1}};
+
static void directory_remove_invalid(void);
static cached_dir_t *dirserv_regenerate_directory(void);
static char *format_versions_list(config_line_t *ln);
@@ -2685,7 +2695,8 @@ dirserv_read_measured_bandwidths(const char *from_file,
}
/** Return a new networkstatus_t* containing our current opinion. (For v3
- * authorities) */
+ * authorities)
+ */
networkstatus_t *
dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
authority_cert_t *cert)
@@ -2757,6 +2768,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
microdescriptors = smartlist_new();
SMARTLIST_FOREACH_BEGIN(routers, routerinfo_t *, ri) {
+ const struct consensus_method_range_t *cmr = NULL;
if (ri->cache_info.published_on >= cutoff) {
routerstatus_t *rs;
vote_routerstatus_t *vrs;
@@ -2778,15 +2790,20 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
rs->is_flagged_running = 0;
vrs->version = version_from_platform(ri->platform);
- md = dirvote_create_microdescriptor(ri);
- if (md) {
- char buf[128];
- vote_microdesc_hash_t *h;
- dirvote_format_microdesc_vote_line(buf, sizeof(buf), md);
- h = tor_malloc(sizeof(vote_microdesc_hash_t));
- h->microdesc_hash_line = tor_strdup(buf);
- h->next = NULL;
- vrs->microdesc = h;
+ for (cmr = microdesc_consensus_methods;
+ cmr->low != -1 && cmr->high != -1;
+ cmr++) {
+ md = dirvote_create_microdescriptor(ri, cmr->low);
+ if (md) {
+ char buf[128];
+ vote_microdesc_hash_t *h;
+ dirvote_format_microdesc_vote_line(buf, sizeof(buf), md,
+ cmr->low, cmr->high);
+ h = tor_malloc(sizeof(vote_microdesc_hash_t));
+ h->microdesc_hash_line = tor_strdup(buf);
+ h->next = vrs->microdesc;
+ vrs->microdesc = h;
+ }
md->last_listed = now;
smartlist_add(microdescriptors, md);
}