mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Prop210: Add want_authority to directory_get_from_dirserver
This commit is contained in:
parent
df0c135d62
commit
d3546aa92b
@ -425,14 +425,17 @@ directory_pick_generic_dirserver(dirinfo_type_t type, int pds_flags,
|
||||
* Use <b>pds_flags</b> as arguments to router_pick_directory_server()
|
||||
* or router_pick_trusteddirserver().
|
||||
*/
|
||||
MOCK_IMPL(void, directory_get_from_dirserver, (uint8_t dir_purpose,
|
||||
uint8_t router_purpose,
|
||||
const char *resource,
|
||||
int pds_flags))
|
||||
MOCK_IMPL(void, directory_get_from_dirserver, (
|
||||
uint8_t dir_purpose,
|
||||
uint8_t router_purpose,
|
||||
const char *resource,
|
||||
int pds_flags,
|
||||
download_want_authority_t want_authority))
|
||||
{
|
||||
const routerstatus_t *rs = NULL;
|
||||
const or_options_t *options = get_options();
|
||||
int prefer_authority = directory_fetches_from_authorities(options);
|
||||
int prefer_authority = (directory_fetches_from_authorities(options)
|
||||
|| want_authority == DL_WANT_AUTHORITY);
|
||||
int require_authority = 0;
|
||||
int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
|
||||
dirinfo_type_t type = dir_fetch_type(dir_purpose, router_purpose, resource);
|
||||
|
@ -16,10 +16,12 @@ int directories_have_accepted_server_descriptor(void);
|
||||
void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
|
||||
dirinfo_type_t type, const char *payload,
|
||||
size_t payload_len, size_t extrainfo_len);
|
||||
MOCK_DECL(void, directory_get_from_dirserver, (uint8_t dir_purpose,
|
||||
uint8_t router_purpose,
|
||||
const char *resource,
|
||||
int pds_flags));
|
||||
MOCK_DECL(void, directory_get_from_dirserver, (
|
||||
uint8_t dir_purpose,
|
||||
uint8_t router_purpose,
|
||||
const char *resource,
|
||||
int pds_flags,
|
||||
download_want_authority_t want_authority));
|
||||
void directory_get_from_all_authorities(uint8_t dir_purpose,
|
||||
uint8_t router_purpose,
|
||||
const char *resource);
|
||||
|
@ -2205,7 +2205,7 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
|
||||
log_info(LD_DIR, "Fetching bridge info '%s' from bridge authority.",
|
||||
resource);
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,
|
||||
ROUTER_PURPOSE_BRIDGE, resource, 0);
|
||||
ROUTER_PURPOSE_BRIDGE, resource, 0, DL_WANT_AUTHORITY);
|
||||
}
|
||||
}
|
||||
SMARTLIST_FOREACH_END(bridge);
|
||||
|
@ -1955,6 +1955,15 @@ typedef enum {
|
||||
} download_schedule_t;
|
||||
#define download_schedule_bitfield_t ENUM_BF(download_schedule_t)
|
||||
|
||||
/** Enumeration: do we want to try an authority or a fallback directory
|
||||
* mirror for our download? */
|
||||
typedef enum {
|
||||
DL_WANT_FALLBACK = 0,
|
||||
DL_WANT_AUTHORITY = 1,
|
||||
} download_want_authority_t;
|
||||
#define download_want_authority_bitfield_t \
|
||||
ENUM_BF(download_want_authority_t)
|
||||
|
||||
/** Information about our plans for retrying downloads for a downloadable
|
||||
* object. */
|
||||
typedef struct download_status_t {
|
||||
|
@ -897,8 +897,10 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now)
|
||||
|
||||
if (smartlist_len(fps) > 1) {
|
||||
resource = smartlist_join_strings(fps, "", 0, NULL);
|
||||
/* XXX - do we want certs from authorities or mirrors? - teor */
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_CERTIFICATE, 0,
|
||||
resource, PDS_RETRY_IF_NO_SERVERS);
|
||||
resource, PDS_RETRY_IF_NO_SERVERS,
|
||||
DL_WANT_FALLBACK);
|
||||
tor_free(resource);
|
||||
}
|
||||
/* else we didn't add any: they were all pending */
|
||||
@ -941,8 +943,10 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now)
|
||||
|
||||
if (smartlist_len(fp_pairs) > 1) {
|
||||
resource = smartlist_join_strings(fp_pairs, "", 0, NULL);
|
||||
/* XXX - do we want certs from authorities or mirrors? - teor */
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_CERTIFICATE, 0,
|
||||
resource, PDS_RETRY_IF_NO_SERVERS);
|
||||
resource, PDS_RETRY_IF_NO_SERVERS,
|
||||
DL_WANT_FALLBACK);
|
||||
tor_free(resource);
|
||||
}
|
||||
/* else they were all pending */
|
||||
@ -4383,7 +4387,7 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads,
|
||||
resource, NULL, 0, 0);
|
||||
} else {
|
||||
directory_get_from_dirserver(purpose, ROUTER_PURPOSE_GENERAL, resource,
|
||||
pds_flags);
|
||||
pds_flags, DL_WANT_FALLBACK);
|
||||
}
|
||||
tor_free(resource);
|
||||
}
|
||||
@ -4667,7 +4671,7 @@ launch_dummy_descriptor_download_as_needed(time_t now,
|
||||
last_dummy_download = now;
|
||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,
|
||||
ROUTER_PURPOSE_GENERAL, "authority.z",
|
||||
PDS_RETRY_IF_NO_SERVERS);
|
||||
PDS_RETRY_IF_NO_SERVERS, DL_WANT_FALLBACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,13 @@ static char output[4*BASE64_DIGEST256_LEN+3+2+2+1];
|
||||
|
||||
static void
|
||||
mock_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
|
||||
const char *resource, int pds_flags)
|
||||
const char *resource, int pds_flags,
|
||||
download_want_authority_t want_authority)
|
||||
{
|
||||
(void)dir_purpose;
|
||||
(void)router_purpose;
|
||||
(void)pds_flags;
|
||||
(void)want_authority;
|
||||
tt_assert(resource);
|
||||
strlcpy(output, resource, sizeof(output));
|
||||
done:
|
||||
|
Loading…
Reference in New Issue
Block a user