mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
When updating routerdesc downloads, look specifically at the ns consensus
This will be needed when "get_live_consensus" potentially returns a microdesc consensus.
This commit is contained in:
+10
-6
@@ -1210,6 +1210,7 @@ update_v2_networkstatus_cache_downloads(time_t now)
|
||||
}
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
static int
|
||||
we_want_to_fetch_flavor(or_options_t *options, int flavor)
|
||||
{
|
||||
@@ -1485,13 +1486,15 @@ networkstatus_get_live_consensus(time_t now)
|
||||
/** As networkstatus_get_live_consensus(), but is way more tolerant of expired
|
||||
* consensuses. */
|
||||
networkstatus_t *
|
||||
networkstatus_get_reasonably_live_consensus(time_t now)
|
||||
networkstatus_get_reasonably_live_consensus(time_t now, int flavor)
|
||||
{
|
||||
#define REASONABLY_LIVE_TIME (24*60*60)
|
||||
if (current_consensus &&
|
||||
current_consensus->valid_after <= now &&
|
||||
now <= current_consensus->valid_until+REASONABLY_LIVE_TIME)
|
||||
return current_consensus;
|
||||
networkstatus_t *consensus =
|
||||
networkstatus_get_latest_consensus_by_flavor(flavor);
|
||||
if (consensus &&
|
||||
consensus->valid_after <= now &&
|
||||
now <= consensus->valid_until+REASONABLY_LIVE_TIME)
|
||||
return consensus;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@@ -1890,7 +1893,8 @@ void
|
||||
routers_update_all_from_networkstatus(time_t now, int dir_version)
|
||||
{
|
||||
routerlist_t *rl = router_get_routerlist();
|
||||
networkstatus_t *consensus = networkstatus_get_live_consensus(now);
|
||||
networkstatus_t *consensus = networkstatus_get_reasonably_live_consensus(now,
|
||||
FLAV_NS);
|
||||
|
||||
if (networkstatus_v2_list_has_changed)
|
||||
download_status_map_update_from_v2_networkstatus();
|
||||
|
||||
@@ -65,7 +65,8 @@ networkstatus_t *networkstatus_get_latest_consensus(void);
|
||||
networkstatus_t *networkstatus_get_latest_consensus_by_flavor(
|
||||
consensus_flavor_t f);
|
||||
networkstatus_t *networkstatus_get_live_consensus(time_t now);
|
||||
networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now);
|
||||
networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now,
|
||||
int flavor);
|
||||
#define NSSET_FROM_CACHE 1
|
||||
#define NSSET_WAS_WAITING_FOR_CERTS 2
|
||||
#define NSSET_DONT_DOWNLOAD_CERTS 4
|
||||
|
||||
+6
-3
@@ -4539,10 +4539,13 @@ update_router_descriptor_downloads(time_t now)
|
||||
if (directory_fetches_dir_info_early(options)) {
|
||||
update_router_descriptor_cache_downloads_v2(now);
|
||||
}
|
||||
|
||||
update_consensus_router_descriptor_downloads(now, 0,
|
||||
networkstatus_get_reasonably_live_consensus(now));
|
||||
networkstatus_get_reasonably_live_consensus(now, FLAV_NS));
|
||||
|
||||
/* XXXX021 we could be smarter here; see notes on bug 652. */
|
||||
/* XXXX NM Microdescs: if we're not fetching microdescriptors, we need
|
||||
* to make something else invoke this. */
|
||||
/* If we're a server that doesn't have a configured address, we rely on
|
||||
* directory fetches to learn when our address changes. So if we haven't
|
||||
* tried to get any routerdescs in a long time, try a dummy fetch now. */
|
||||
@@ -4713,7 +4716,7 @@ count_loading_descriptors_progress(void)
|
||||
int num_present = 0, num_usable=0;
|
||||
time_t now = time(NULL);
|
||||
const networkstatus_t *consensus =
|
||||
networkstatus_get_reasonably_live_consensus(now);
|
||||
networkstatus_get_reasonably_live_consensus(now, FLAV_NS);
|
||||
double fraction;
|
||||
|
||||
if (!consensus)
|
||||
@@ -4743,7 +4746,7 @@ update_router_have_minimum_dir_info(void)
|
||||
int res;
|
||||
or_options_t *options = get_options();
|
||||
const networkstatus_t *consensus =
|
||||
networkstatus_get_reasonably_live_consensus(now);
|
||||
networkstatus_get_reasonably_live_consensus(now, FLAV_NS);
|
||||
|
||||
if (!consensus) {
|
||||
if (!networkstatus_get_latest_consensus())
|
||||
|
||||
Reference in New Issue
Block a user