diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-02-14 17:39:34 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-02-14 17:39:34 +0200 |
commit | 9bfe4ed6dd666bb276e35b6e5c8c3de0c218bce0 (patch) | |
tree | 3e7cb22f7289d2bb6c6af0ef3b75506c5af833af /src/feature | |
parent | 6efc2a0e1f785e1e12fb8c7fd4b6aa4feceb647a (diff) | |
parent | 805f75182a87286a727df323be7c37add595bdff (diff) | |
download | tor-9bfe4ed6dd666bb276e35b6e5c8c3de0c218bce0.tar.gz tor-9bfe4ed6dd666bb276e35b6e5c8c3de0c218bce0.zip |
Merge branch 'tor-github/pr/536' into maint-0.3.5
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/client/entrynodes.c | 27 | ||||
-rw-r--r-- | src/feature/nodelist/microdesc.c | 10 | ||||
-rw-r--r-- | src/feature/nodelist/networkstatus.c | 7 | ||||
-rw-r--r-- | src/feature/nodelist/networkstatus.h | 5 |
4 files changed, 28 insertions, 21 deletions
diff --git a/src/feature/client/entrynodes.c b/src/feature/client/entrynodes.c index df9796a56e..e543289ce0 100644 --- a/src/feature/client/entrynodes.c +++ b/src/feature/client/entrynodes.c @@ -287,7 +287,9 @@ create_initial_guard_context(void) guard_selection_type_t type = GS_TYPE_INFER; const char *name = choose_guard_selection( get_options(), - networkstatus_get_live_consensus(approx_time()), + networkstatus_get_reasonably_live_consensus( + approx_time(), + usable_consensus_flavor()), NULL, &type); tor_assert(name); // "name" can only be NULL if we had an old name. @@ -726,7 +728,9 @@ update_guard_selection_choice(const or_options_t *options) guard_selection_type_t type = GS_TYPE_INFER; const char *new_name = choose_guard_selection( options, - networkstatus_get_live_consensus(approx_time()), + networkstatus_get_reasonably_live_consensus( + approx_time(), + usable_consensus_flavor()), curr_guard_context, &type); tor_assert(new_name); @@ -1125,14 +1129,16 @@ select_and_add_guard_item_for_sample(guard_selection_t *gs, * or if we don't need a consensus because we're using bridges.) */ static int -live_consensus_is_missing(const guard_selection_t *gs) +reasonably_live_consensus_is_missing(const guard_selection_t *gs) { tor_assert(gs); if (gs->type == GS_TYPE_BRIDGE) { /* We don't update bridges from the consensus; they aren't there. */ return 0; } - return networkstatus_get_live_consensus(approx_time()) == NULL; + return networkstatus_get_reasonably_live_consensus( + approx_time(), + usable_consensus_flavor()) == NULL; } /** @@ -1147,9 +1153,9 @@ entry_guards_expand_sample(guard_selection_t *gs) tor_assert(gs); const or_options_t *options = get_options(); - if (live_consensus_is_missing(gs)) { + if (reasonably_live_consensus_is_missing(gs)) { log_info(LD_GUARD, "Not expanding the sample guard set; we have " - "no live consensus."); + "no reasonably live consensus."); return NULL; } @@ -1395,11 +1401,12 @@ sampled_guards_update_from_consensus(guard_selection_t *gs) { tor_assert(gs); - // It's important to use only a live consensus here; we don't want to - // make changes based on anything expired or old. - if (live_consensus_is_missing(gs)) { + // It's important to use a reasonably live consensus here; we want clients + // to bootstrap even if their clock is skewed by more than 2-3 hours. + // But we don't want to make changes based on anything that's really old. + if (reasonably_live_consensus_is_missing(gs)) { log_info(LD_GUARD, "Not updating the sample guard set; we have " - "no live consensus."); + "no reasonably live consensus."); return; } log_info(LD_GUARD, "Updating sampled guard status based on received " diff --git a/src/feature/nodelist/microdesc.c b/src/feature/nodelist/microdesc.c index 3b4a7e1b30..dafaabb5e5 100644 --- a/src/feature/nodelist/microdesc.c +++ b/src/feature/nodelist/microdesc.c @@ -108,10 +108,12 @@ microdesc_note_outdated_dirserver(const char *relay_digest) { char relay_hexdigest[HEX_DIGEST_LEN+1]; - /* Don't register outdated dirservers if we don't have a live consensus, - * since we might be trying to fetch microdescriptors that are not even - * currently active. */ - if (!networkstatus_get_live_consensus(approx_time())) { + /* If we have a reasonably live consensus, then most of our dirservers should + * still be caching all the microdescriptors in it. Reasonably live + * consensuses are up to a day old. But microdescriptors expire 7 days after + * the last consensus that referenced them. */ + if (!networkstatus_get_reasonably_live_consensus(approx_time(), + FLAV_MICRODESC)) { return; } diff --git a/src/feature/nodelist/networkstatus.c b/src/feature/nodelist/networkstatus.c index d1155d85a0..c74acd8b74 100644 --- a/src/feature/nodelist/networkstatus.c +++ b/src/feature/nodelist/networkstatus.c @@ -1448,13 +1448,10 @@ networkstatus_valid_until_is_reasonably_live(time_t valid_until, return (now <= valid_until + REASONABLY_LIVE_TIME); } -/* XXXX remove this in favor of get_live_consensus. But actually, - * leave something like it for bridge users, who need to not totally - * lose if they spend a while fetching a new consensus. */ /** As networkstatus_get_live_consensus(), but is way more tolerant of expired * consensuses. */ -networkstatus_t * -networkstatus_get_reasonably_live_consensus(time_t now, int flavor) +MOCK_IMPL(networkstatus_t *, +networkstatus_get_reasonably_live_consensus,(time_t now, int flavor)) { networkstatus_t *consensus = networkstatus_get_latest_consensus_by_flavor(flavor); diff --git a/src/feature/nodelist/networkstatus.h b/src/feature/nodelist/networkstatus.h index f7d3ef92bb..9e7b0f1bb0 100644 --- a/src/feature/nodelist/networkstatus.h +++ b/src/feature/nodelist/networkstatus.h @@ -89,8 +89,9 @@ int networkstatus_consensus_reasonably_live(const networkstatus_t *consensus, time_t now); int networkstatus_valid_until_is_reasonably_live(time_t valid_until, time_t now); -networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now, - int flavor); +MOCK_DECL(networkstatus_t *,networkstatus_get_reasonably_live_consensus, + (time_t now, + int flavor)); MOCK_DECL(int, networkstatus_consensus_is_bootstrapping,(time_t now)); int networkstatus_consensus_can_use_multiple_directories( const or_options_t *options); |