mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-22 14:23:04 +01:00
Easy code fixes.
- Correctly maintain the previous guard selection in choose_guard_selection(). - Print bridge identifier instead of nothing in entry_guard_describe()._
This commit is contained in:
parent
7ab2678074
commit
50783d0123
2 changed files with 16 additions and 9 deletions
|
@ -341,7 +341,8 @@ entry_guard_describe(const entry_guard_t *guard)
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
tor_snprintf(buf, sizeof(buf),
|
tor_snprintf(buf, sizeof(buf),
|
||||||
"%s ($%s)",
|
"%s ($%s)",
|
||||||
guard->nickname, hex_str(guard->identity, DIGEST_LEN));
|
guard->nickname ? guard->nickname : "[bridge]",
|
||||||
|
hex_str(guard->identity, DIGEST_LEN));
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +528,7 @@ get_extreme_restriction_threshold(void)
|
||||||
STATIC const char *
|
STATIC const char *
|
||||||
choose_guard_selection(const or_options_t *options,
|
choose_guard_selection(const or_options_t *options,
|
||||||
const networkstatus_t *live_ns,
|
const networkstatus_t *live_ns,
|
||||||
const char *old_selection,
|
const guard_selection_t *old_selection,
|
||||||
guard_selection_type_t *type_out)
|
guard_selection_type_t *type_out)
|
||||||
{
|
{
|
||||||
tor_assert(options);
|
tor_assert(options);
|
||||||
|
@ -607,7 +608,11 @@ choose_guard_selection(const or_options_t *options,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Trickier case: we do have a previous selection */
|
/* Trickier case: we do have a previous guard selection context. */
|
||||||
|
tor_assert(old_selection);
|
||||||
|
|
||||||
|
/* Use high and low thresholds to decide guard selection, and if we fall in
|
||||||
|
the middle then keep the current guard selection context. */
|
||||||
if (n_passing_filter >= meaningful_threshold_high) {
|
if (n_passing_filter >= meaningful_threshold_high) {
|
||||||
*type_out = GS_TYPE_NORMAL;
|
*type_out = GS_TYPE_NORMAL;
|
||||||
return "default";
|
return "default";
|
||||||
|
@ -615,7 +620,9 @@ choose_guard_selection(const or_options_t *options,
|
||||||
*type_out = GS_TYPE_RESTRICTED;
|
*type_out = GS_TYPE_RESTRICTED;
|
||||||
return "restricted";
|
return "restricted";
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
/* we are in the middle: maintain previous guard selection */
|
||||||
|
*type_out = old_selection->type;
|
||||||
|
return old_selection->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,16 +641,16 @@ update_guard_selection_choice(const or_options_t *options)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *cur_name = curr_guard_context->name;
|
|
||||||
guard_selection_type_t type = GS_TYPE_INFER;
|
guard_selection_type_t type = GS_TYPE_INFER;
|
||||||
const char *new_name = choose_guard_selection(
|
const char *new_name = choose_guard_selection(
|
||||||
options,
|
options,
|
||||||
networkstatus_get_live_consensus(approx_time()),
|
networkstatus_get_live_consensus(approx_time()),
|
||||||
cur_name,
|
curr_guard_context,
|
||||||
&type);
|
&type);
|
||||||
tor_assert(new_name);
|
tor_assert(new_name);
|
||||||
tor_assert(type != GS_TYPE_INFER);
|
tor_assert(type != GS_TYPE_INFER);
|
||||||
|
|
||||||
|
const char *cur_name = curr_guard_context->name;
|
||||||
if (! strcmp(cur_name, new_name)) {
|
if (! strcmp(cur_name, new_name)) {
|
||||||
log_debug(LD_GUARD,
|
log_debug(LD_GUARD,
|
||||||
"Staying with guard context \"%s\" (no change)", new_name);
|
"Staying with guard context \"%s\" (no change)", new_name);
|
||||||
|
|
|
@ -519,9 +519,9 @@ STATIC void guard_selection_free(guard_selection_t *gs);
|
||||||
MOCK_DECL(STATIC int, entry_guard_is_listed,
|
MOCK_DECL(STATIC int, entry_guard_is_listed,
|
||||||
(guard_selection_t *gs, const entry_guard_t *guard));
|
(guard_selection_t *gs, const entry_guard_t *guard));
|
||||||
STATIC const char *choose_guard_selection(const or_options_t *options,
|
STATIC const char *choose_guard_selection(const or_options_t *options,
|
||||||
const networkstatus_t *ns,
|
const networkstatus_t *ns,
|
||||||
const char *old_selection,
|
const guard_selection_t *old_selection,
|
||||||
guard_selection_type_t *type_out);
|
guard_selection_type_t *type_out);
|
||||||
STATIC entry_guard_t *get_sampled_guard_with_id(guard_selection_t *gs,
|
STATIC entry_guard_t *get_sampled_guard_with_id(guard_selection_t *gs,
|
||||||
const uint8_t *rsa_id);
|
const uint8_t *rsa_id);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue