mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Restore the entry/dirguard distinction.
We shouldn't be calling choose_random_entry() for directory conncetions; that's what choose_random_dirguard() is for.
This commit is contained in:
parent
bce5019eff
commit
d7089ff228
@ -3373,7 +3373,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
|
||||
(purpose != CIRCUIT_PURPOSE_TESTING || options->BridgeRelay)) {
|
||||
/* This request is for an entry server to use for a regular circuit,
|
||||
* and we use entry guard nodes. Just return one of the guard nodes. */
|
||||
return choose_random_entry(state, NO_DIRINFO);
|
||||
return choose_random_entry(state);
|
||||
}
|
||||
|
||||
excluded = smartlist_new();
|
||||
|
@ -478,7 +478,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
|
||||
*/
|
||||
/* XXX024 Not all bridges handle conditional consensus downloading,
|
||||
* so, for now, never assume the server supports that. -PP */
|
||||
const node_t *node = choose_random_entry(NULL, type);
|
||||
const node_t *node = choose_random_dirguard(type);
|
||||
if (node && node->ri) {
|
||||
/* every bridge has a routerinfo. */
|
||||
tor_addr_t addr;
|
||||
|
@ -848,6 +848,14 @@ node_understands_microdescriptors(const node_t *node)
|
||||
static int
|
||||
node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
|
||||
{
|
||||
/* Checking dirinfo for any type other than microdescriptors isn't required
|
||||
yet, since we only choose directory guards that can support microdescs,
|
||||
routerinfos, and networkstatuses, AND we don't use directory guards if
|
||||
we're configured to do direct downloads of anything else. The only case
|
||||
where we might have a guard that doesn't know about a type of directory
|
||||
information is when we're retrieving directory information from a
|
||||
bridge. */
|
||||
|
||||
if ((dirinfo & MICRODESC_DIRINFO) &&
|
||||
!node_understands_microdescriptors(node))
|
||||
return 0;
|
||||
@ -862,9 +870,9 @@ node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
|
||||
* only select from nodes that know how to answer directory questions
|
||||
* of that type. */
|
||||
const node_t *
|
||||
choose_random_entry(cpath_build_state_t *state, dirinfo_type_t dirinfo)
|
||||
choose_random_entry(cpath_build_state_t *state)
|
||||
{
|
||||
return choose_random_entry_impl(state, 0, dirinfo);
|
||||
return choose_random_entry_impl(state, 0, 0);
|
||||
}
|
||||
|
||||
/** Pick a live (up and listed) directory guard from entry_guards for
|
||||
@ -893,12 +901,6 @@ choose_random_entry_impl(cpath_build_state_t *state, int for_directory,
|
||||
const int num_needed = for_directory ? options->NumDirectoryGuards :
|
||||
options->NumEntryGuards;
|
||||
|
||||
/* Checking dirinfo_type isn't required yet, since we only choose directory
|
||||
guards that can support microdescs, routerinfos, and networkstatuses, AND
|
||||
we don't use directory guards if we're configured to do direct downloads
|
||||
of anything else. */
|
||||
(void) dirinfo_type;
|
||||
|
||||
if (chosen_exit) {
|
||||
nodelist_add_node_and_family(exit_family, chosen_exit);
|
||||
consider_exit_family = 1;
|
||||
@ -2012,7 +2014,7 @@ int
|
||||
any_bridge_descriptors_known(void)
|
||||
{
|
||||
tor_assert(get_options()->UseBridges);
|
||||
return choose_random_entry(NULL, NO_DIRINFO)!=NULL ? 1 : 0;
|
||||
return choose_random_entry(NULL) != NULL;
|
||||
}
|
||||
|
||||
/** Return 1 if there are any directory conns fetching bridge descriptors
|
||||
|
@ -78,8 +78,7 @@ int entry_guard_register_connect_status(const char *digest, int succeeded,
|
||||
int mark_relay_status, time_t now);
|
||||
void entry_nodes_should_be_added(void);
|
||||
int entry_list_is_constrained(const or_options_t *options);
|
||||
const node_t *choose_random_entry(cpath_build_state_t *state,
|
||||
dirinfo_type_t dirinfo);
|
||||
const node_t *choose_random_entry(cpath_build_state_t *state);
|
||||
const node_t *choose_random_dirguard(dirinfo_type_t t);
|
||||
int entry_guards_parse_state(or_state_t *state, int set, char **msg);
|
||||
void entry_guards_update_state(or_state_t *state);
|
||||
|
Loading…
Reference in New Issue
Block a user