mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 05:03:43 +01:00
r14531@catbus: nickm | 2007-08-13 14:46:25 -0400
Cache v3 networkstatus consensuses on disk. svn:r11086
This commit is contained in:
parent
f3e9dceaa9
commit
ce1f01c3e6
@ -11,6 +11,10 @@ Changes in version 0.2.0.5-alpha - 2007-??-??
|
|||||||
- Fix compile on platforms without getaddrinfo: bug found by Li-Hui
|
- Fix compile on platforms without getaddrinfo: bug found by Li-Hui
|
||||||
Zhou.
|
Zhou.
|
||||||
|
|
||||||
|
o Minor features (directory voting):
|
||||||
|
- Store v3 consensus status consensuses on disk, and reload them
|
||||||
|
on startup.
|
||||||
|
|
||||||
o Minor featuers (security):
|
o Minor featuers (security):
|
||||||
- Warn about unsafe ControlPort configurations.
|
- Warn about unsafe ControlPort configurations.
|
||||||
|
|
||||||
|
2
doc/TODO
2
doc/TODO
@ -92,7 +92,7 @@ Things we'd like to do in 0.2.0.x:
|
|||||||
* Detect whether votes are really all for the same period.
|
* Detect whether votes are really all for the same period.
|
||||||
- Push/pull documents as appropriate.
|
- Push/pull documents as appropriate.
|
||||||
- Pull votes and signatures if we don't get them.
|
- Pull votes and signatures if we don't get them.
|
||||||
- Store consensuses
|
o Store consensuses
|
||||||
- Cache votes and signatures on disk.
|
- Cache votes and signatures on disk.
|
||||||
o Have clients know which authorities are v3 authorities, and what
|
o Have clients know which authorities are v3 authorities, and what
|
||||||
their keys are.
|
their keys are.
|
||||||
|
@ -1400,7 +1400,7 @@ dirvote_publish_consensus(void)
|
|||||||
networkstatus_check_consensus_signature(pending_consensus)<0)
|
networkstatus_check_consensus_signature(pending_consensus)<0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
networkstatus_set_current_consensus(pending_consensus_body);
|
networkstatus_set_current_consensus(pending_consensus_body, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,6 +1353,9 @@ do_main_loop(void)
|
|||||||
if (router_reload_networkstatus()) {
|
if (router_reload_networkstatus()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (router_reload_consensus_networkstatus()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
directory_info_has_arrived(time(NULL),1);
|
directory_info_has_arrived(time(NULL),1);
|
||||||
|
|
||||||
if (authdir_mode_tests_reachability(get_options())) {
|
if (authdir_mode_tests_reachability(get_options())) {
|
||||||
|
@ -3427,9 +3427,10 @@ local_routerstatus_t *router_get_combined_status_by_descriptor_digest(
|
|||||||
const char *digest);
|
const char *digest);
|
||||||
|
|
||||||
/* for consensuses. */
|
/* for consensuses. */
|
||||||
|
int router_reload_consensus_networkstatus(void);
|
||||||
networkstatus_vote_t *networkstatus_get_latest_consensus(void);
|
networkstatus_vote_t *networkstatus_get_latest_consensus(void);
|
||||||
networkstatus_vote_t *networkstatus_get_live_consensus(time_t now);
|
networkstatus_vote_t *networkstatus_get_live_consensus(time_t now);
|
||||||
int networkstatus_set_current_consensus(const char *consensus);
|
int networkstatus_set_current_consensus(const char *consensus, int from_cache);
|
||||||
|
|
||||||
//routerstatus_t *routerstatus_get_by_hexdigest(const char *hexdigest);
|
//routerstatus_t *routerstatus_get_by_hexdigest(const char *hexdigest);
|
||||||
int should_delay_dir_fetches(or_options_t *options);
|
int should_delay_dir_fetches(or_options_t *options);
|
||||||
|
@ -175,6 +175,27 @@ router_reload_networkstatus(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**DOCDOC */
|
||||||
|
int
|
||||||
|
router_reload_consensus_networkstatus(void)
|
||||||
|
{
|
||||||
|
char filename[512];
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
tor_snprintf(filename,sizeof(filename),"%s"PATH_SEPARATOR"cached-consensus",
|
||||||
|
get_options()->DataDirectory);
|
||||||
|
s = read_file_to_str(filename, 0, NULL);
|
||||||
|
if (!s)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (networkstatus_set_current_consensus(s, 1)) {
|
||||||
|
log_warn(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
|
||||||
|
filename);
|
||||||
|
}
|
||||||
|
tor_free(s);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Reload the cached v3 key certificates from the cached-certs file in
|
/** Reload the cached v3 key certificates from the cached-certs file in
|
||||||
* the data directory. Return 0 on success, -1 on failure. */
|
* the data directory. Return 0 on success, -1 on failure. */
|
||||||
int
|
int
|
||||||
@ -3837,8 +3858,9 @@ networkstatus_get_live_consensus(time_t now)
|
|||||||
return current_consensus;
|
return current_consensus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** DOCDOC */
|
||||||
int
|
int
|
||||||
networkstatus_set_current_consensus(const char *consensus)
|
networkstatus_set_current_consensus(const char *consensus, int from_cache)
|
||||||
{
|
{
|
||||||
networkstatus_vote_t *c;
|
networkstatus_vote_t *c;
|
||||||
/* Make sure it's parseable. */
|
/* Make sure it's parseable. */
|
||||||
@ -3857,6 +3879,15 @@ networkstatus_set_current_consensus(const char *consensus)
|
|||||||
|
|
||||||
current_consensus = c;
|
current_consensus = c;
|
||||||
|
|
||||||
|
if (!from_cache) {
|
||||||
|
or_options_t *options = get_options();
|
||||||
|
char filename[512];
|
||||||
|
tor_snprintf(filename, sizeof(filename),
|
||||||
|
"%s"PATH_SEPARATOR"cached-consensus",
|
||||||
|
options->DataDirectory);
|
||||||
|
write_str_to_file(filename, consensus, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (get_options()->DirPort)
|
if (get_options()->DirPort)
|
||||||
dirserv_set_cached_networkstatus_v3(consensus, c->valid_after);
|
dirserv_set_cached_networkstatus_v3(consensus, c->valid_after);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user