diff options
author | juga0 <juga@riseup.net> | 2018-05-28 14:41:55 +0000 |
---|---|---|
committer | juga0 <juga@riseup.net> | 2018-07-16 14:43:48 +0000 |
commit | e5dd46beabb7f456fcf4456271676bc507886fe5 (patch) | |
tree | 7344784e22c181373caf368b588b6ac10f88db31 /src/feature/dirauth | |
parent | 8505522e508c8d2379afbd86154a910948cf8c70 (diff) | |
download | tor-e5dd46beabb7f456fcf4456271676bc507886fe5.tar.gz tor-e5dd46beabb7f456fcf4456271676bc507886fe5.zip |
Add the Bandwidth List file headers to votes
* add bwlist_headers argument to dirserv_read_measured_bandwidth
in order to store all the headers found when parsing the file
* add bwlist_headers to networkstatus_t in order to store the
the headers found by the previous function
* include the bandwidth headers as string in vote documents
* add test to check that dirserv_read_measured_bandwidth generates
the bwlist_headers
Diffstat (limited to 'src/feature/dirauth')
-rw-r--r-- | src/feature/dirauth/dirvote.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c index ce67c1bb9a..27d3a4841b 100644 --- a/src/feature/dirauth/dirvote.c +++ b/src/feature/dirauth/dirvote.c @@ -254,6 +254,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, /* XXXX Abstraction violation: should be pulling a field out of v3_ns.*/ char *flag_thresholds = dirserv_get_flag_thresholds_line(); char *params; + char *bwlist_headers = smartlist_join_strings(v3_ns->bwlist_headers, + " ", 0, NULL); authority_cert_t *cert = v3_ns->cert; char *methods = make_consensus_method_list(MIN_SUPPORTED_CONSENSUS_METHOD, @@ -267,7 +269,6 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, params = smartlist_join_strings(v3_ns->net_params, " ", 0, NULL); else params = tor_strdup(""); - tor_assert(cert); smartlist_add_asprintf(chunks, "network-status-version 3\n" @@ -286,7 +287,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, "params %s\n" "dir-source %s %s %s %s %d %d\n" "contact %s\n" - "%s", /* shared randomness information */ + "%s" /* shared randomness information */ + "bandwidth-file %s\n", /* bandwidth file headers */ v3_ns->type == NS_TYPE_VOTE ? "vote" : "opinion", methods, published, va, fu, vu, @@ -302,13 +304,15 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, fmt_addr32(addr), voter->dir_port, voter->or_port, voter->contact, shared_random_vote_str ? - shared_random_vote_str : ""); + shared_random_vote_str : "", + bwlist_headers); tor_free(params); tor_free(flags); tor_free(flag_thresholds); tor_free(methods); tor_free(shared_random_vote_str); + tor_free(bwlist_headers); if (!tor_digest_is_zero(voter->legacy_id_digest)) { char fpbuf[HEX_DIGEST_LEN+1]; @@ -4291,7 +4295,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, uint32_t addr; char *hostname = NULL, *client_versions = NULL, *server_versions = NULL; const char *contact; - smartlist_t *routers, *routerstatuses; + smartlist_t *routers, *routerstatuses, *bwlist_headers; char identity_digest[DIGEST_LEN]; char signing_key_digest[DIGEST_LEN]; int listbadexits = options->AuthDirListBadExits; @@ -4338,7 +4342,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, * set_routerstatus_from_routerinfo() see up-to-date bandwidth info. */ if (options->V3BandwidthsFile) { - dirserv_read_measured_bandwidths(options->V3BandwidthsFile, NULL); + dirserv_read_measured_bandwidths(options->V3BandwidthsFile, NULL, NULL); } else { /* * No bandwidths file; clear the measured bandwidth cache in case we had @@ -4375,6 +4379,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, routerstatuses = smartlist_new(); microdescriptors = smartlist_new(); + bwlist_headers = smartlist_new(); SMARTLIST_FOREACH_BEGIN(routers, routerinfo_t *, ri) { /* If it has a protover list and contains a protocol name greater than @@ -4441,7 +4446,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, /* This pass through applies the measured bw lines to the routerstatuses */ if (options->V3BandwidthsFile) { dirserv_read_measured_bandwidths(options->V3BandwidthsFile, - routerstatuses); + routerstatuses, bwlist_headers); } else { /* * No bandwidths file; clear the measured bandwidth cache in case we had @@ -4537,6 +4542,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, options->ConsensusParams, NULL, 0, 0); smartlist_sort_strings(v3_out->net_params); } + v3_out->bwlist_headers = bwlist_headers; voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t)); voter->nickname = tor_strdup(options->Nickname); |