mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
r14799@Kushana: nickm | 2007-10-08 15:55:18 -0400
Add code to download router descriptors listed in a v3 networkstatus consensus. svn:r11790
This commit is contained in:
parent
84d7677a8a
commit
13f7f98ad2
@ -3,6 +3,11 @@ Changes in version 0.2.0.8-alpha - 2007-??-??
|
||||
- When an authority is missing votes or signatures, it now tries to fetch
|
||||
them.
|
||||
|
||||
o Major features (v3 directory system):
|
||||
- Caches now download v3 network status documents as needed.
|
||||
- Caches now download descriptors listed in their v3 network status
|
||||
documents.
|
||||
|
||||
o Minor features (router descriptor cache):
|
||||
- Store routers in a file called cached-descriptors instead of in
|
||||
cached-routers. Initialize cached-descriptors from cached-routers
|
||||
|
13
doc/TODO
13
doc/TODO
@ -91,6 +91,19 @@ Things we'd like to do in 0.2.0.x:
|
||||
fetching them
|
||||
- Implement
|
||||
- Enable
|
||||
. Start caching consensus documents once authorities make them;
|
||||
start downloading consensus documents once caches serve
|
||||
them
|
||||
o Download code
|
||||
o Code to schedule downloads
|
||||
- Code to retry failed downloads
|
||||
- Code to delay next download while fetching certificates
|
||||
o Code to download routers listed in v3 networkstatus consensuses.
|
||||
- Enable for non-caches
|
||||
- Code to use v3 networkstatus documents once clients are
|
||||
fetching them
|
||||
- Implement
|
||||
- Enable
|
||||
- Controller support
|
||||
- GETINFO to get consensus
|
||||
- Event when new consensus arrives
|
||||
|
@ -36,6 +36,9 @@ static void update_networkstatus_cache_downloads(time_t now);
|
||||
static void update_networkstatus_client_downloads(time_t now);
|
||||
static void update_consensus_networkstatus_fetch_time(time_t now);
|
||||
static void update_consensus_networkstatus_downloads(time_t now);
|
||||
static void launch_router_descriptor_downloads(smartlist_t *downloadable,
|
||||
time_t now);
|
||||
static void update_consensus_router_descriptor_downloads(time_t now);
|
||||
static int signed_desc_digest_is_recognized(signed_descriptor_t *desc);
|
||||
static int have_tried_downloading_all_statuses(int n_failures);
|
||||
static routerstatus_t *networkstatus_find_entry(networkstatus_t *ns,
|
||||
@ -4016,7 +4019,7 @@ update_networkstatus_downloads(time_t now)
|
||||
update_consensus_networkstatus_downloads(now);
|
||||
}
|
||||
|
||||
/** Clear all our timeouts for fetching v2 directory stuff, and then
|
||||
/** Clear all our timeouts for fetching v2 and v3 directory stuff, and then
|
||||
* give it all a try again. */
|
||||
void
|
||||
routerlist_retry_directory_downloads(time_t now)
|
||||
@ -5142,7 +5145,6 @@ update_router_descriptor_client_downloads(time_t now)
|
||||
* them until they have more, or until this amount of time has passed. */
|
||||
#define MAX_CLIENT_INTERVAL_WITHOUT_REQUEST (10*60)
|
||||
smartlist_t *downloadable = NULL;
|
||||
int should_delay, n_downloadable;
|
||||
or_options_t *options = get_options();
|
||||
|
||||
if (options->DirPort) {
|
||||
@ -5164,14 +5166,23 @@ update_router_descriptor_client_downloads(time_t now)
|
||||
}
|
||||
|
||||
downloadable = router_list_client_downloadable();
|
||||
launch_router_descriptor_downloads(downloadable, now);
|
||||
smartlist_free(downloadable);
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
static void
|
||||
launch_router_descriptor_downloads(smartlist_t *downloadable, time_t now)
|
||||
{
|
||||
int should_delay = 0, n_downloadable;
|
||||
or_options_t *options = get_options();
|
||||
|
||||
n_downloadable = smartlist_len(downloadable);
|
||||
if (!options->DirPort) {
|
||||
if (n_downloadable >= MAX_DL_TO_DELAY) {
|
||||
log_debug(LD_DIR,
|
||||
"There are enough downloadable routerdescs to launch requests.");
|
||||
should_delay = 0;
|
||||
} else if (n_downloadable == 0) {
|
||||
// log_debug(LD_DIR, "No routerdescs need to be downloaded.");
|
||||
should_delay = 1;
|
||||
} else {
|
||||
should_delay = (last_routerdesc_download_attempted +
|
||||
MAX_CLIENT_INTERVAL_WITHOUT_REQUEST) > now;
|
||||
@ -5188,6 +5199,7 @@ update_router_descriptor_client_downloads(time_t now)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! should_delay) {
|
||||
int i, n_per_request;
|
||||
@ -5214,7 +5226,6 @@ update_router_descriptor_client_downloads(time_t now)
|
||||
}
|
||||
last_routerdesc_download_attempted = now;
|
||||
}
|
||||
smartlist_free(downloadable);
|
||||
}
|
||||
|
||||
/** Launch downloads for router status as needed, using the strategy used by
|
||||
@ -5359,6 +5370,44 @@ update_router_descriptor_cache_downloads(time_t now)
|
||||
digestmap_free(map,NULL);
|
||||
}
|
||||
|
||||
/** DOCDOC */
|
||||
static void
|
||||
update_consensus_router_descriptor_downloads(time_t now)
|
||||
{
|
||||
or_options_t *options = get_options();
|
||||
digestmap_t *map = NULL;
|
||||
smartlist_t *downloadable = smartlist_create();
|
||||
int authdir = authdir_mode(options);
|
||||
if (!options->DirPort) {
|
||||
if (rep_hist_circbuilding_dormant(now))
|
||||
return;
|
||||
}
|
||||
if (!current_consensus)
|
||||
return;
|
||||
|
||||
map = digestmap_new();
|
||||
list_pending_descriptor_downloads(map, 0);
|
||||
SMARTLIST_FOREACH(current_consensus->routerstatus_list, routerstatus_t *, rs,
|
||||
{
|
||||
/* ????020 need-to-mirror? */
|
||||
/* XXXX rate-limit retries. */
|
||||
if (router_get_by_descriptor_digest(rs->descriptor_digest))
|
||||
continue; /* We have it already. */
|
||||
if (authdir && dirserv_would_reject_router(rs))
|
||||
continue; /* We would throw it out immediately. */
|
||||
if (!options->DirPort && !client_would_use_router(rs, now, options))
|
||||
continue; /* We would never use it ourself. */
|
||||
if (digestmap_get(map, rs->descriptor_digest))
|
||||
continue; /* We have an in-progress download. */
|
||||
smartlist_add(downloadable, rs->descriptor_digest);
|
||||
});
|
||||
|
||||
launch_router_descriptor_downloads(downloadable, now);
|
||||
|
||||
smartlist_free(downloadable);
|
||||
digestmap_free(map, NULL);
|
||||
}
|
||||
|
||||
/** Launch downloads for router status as needed. */
|
||||
void
|
||||
update_router_descriptor_downloads(time_t now)
|
||||
@ -5368,6 +5417,7 @@ update_router_descriptor_downloads(time_t now)
|
||||
return;
|
||||
if (options->DirPort) {
|
||||
update_router_descriptor_cache_downloads(now);
|
||||
update_consensus_router_descriptor_downloads(now); /*XXXX020 clients too*/
|
||||
} else {
|
||||
update_router_descriptor_client_downloads(now);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user