diff options
author | Roger Dingledine <arma@torproject.org> | 2007-12-20 06:47:59 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2007-12-20 06:47:59 +0000 |
commit | f0e7c4f0da87901584b4b03e7b50157ce607b88e (patch) | |
tree | 7f76e6f37f14f82132ef1b89ea946d990503c413 /src/or | |
parent | acd8bc1fd92e71c25570c161f0b3b9b1f4b766a7 (diff) | |
download | tor-f0e7c4f0da87901584b4b03e7b50157ce607b88e.tar.gz tor-f0e7c4f0da87901584b4b03e7b50157ce607b88e.zip |
Only Tors that want to mirror the v2 directory info should
create the "cached-status" directory in their datadir. All Tors
used to create it. Bugfix on 0.1.2.x.
Bridge relays with DirPort set to 0 no longer cache v1 or v2
directory information; there's no point. Bugfix on trunk.
svn:r12887
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 2 | ||||
-rw-r--r-- | src/or/dirserv.c | 8 | ||||
-rw-r--r-- | src/or/networkstatus.c | 6 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/routerparse.c | 2 |
5 files changed, 15 insertions, 5 deletions
diff --git a/src/or/config.c b/src/or/config.c index 83fec4e1bb..437a75690e 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1108,7 +1108,7 @@ options_act(or_options_t *old_options) return -1; } - if (running_tor) { + if (running_tor && directory_caches_v2_dir_info(options)) { len = strlen(options->DataDirectory)+32; fn = tor_malloc(len); tor_snprintf(fn, len, "%s"PATH_SEPARATOR"cached-status", diff --git a/src/or/dirserv.c b/src/or/dirserv.c index e45a6ea8f7..364337514e 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1147,6 +1147,14 @@ directory_fetches_dir_info_like_bridge_user(or_options_t *options) return options->UseBridges != 0; } +/** Return 1 if we want to cache v2 dir info (each status file). + */ +int +directory_caches_v2_dir_info(or_options_t *options) +{ + return options->DirPort != 0; +} + /** Return 1 if we want to keep descriptors, networkstatuses, etc around * and we're willing to serve them to others. Else return 0. */ diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index 28d0010ff7..54b92a8fa3 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -495,7 +495,7 @@ add_networkstatus_to_cache(const char *s, tor_free(fn); } - if (directory_caches_dir_info(get_options())) + if (directory_caches_v2_dir_info(get_options())) dirserv_set_cached_networkstatus_v2(s, ns->identity_digest, ns->published_on); @@ -540,7 +540,7 @@ router_set_networkstatus_v2(const char *s, time_t arrived_at, char fp[HEX_DIGEST_LEN+1]; char published[ISO_TIME_LEN+1]; - if (!directory_caches_dir_info(get_options())) + if (!directory_caches_v2_dir_info(get_options())) return 0; /* Don't bother storing it. */ ns = networkstatus_v2_parse_from_string(s); @@ -721,7 +721,7 @@ networkstatus_v2_list_clean(time_t now) unlink(fname); } tor_free(fname); - if (directory_caches_dir_info(get_options())) { + if (directory_caches_v2_dir_info(get_options())) { dirserv_set_cached_networkstatus_v2(NULL, ns->identity_digest, 0); } networkstatus_v2_free(ns); diff --git a/src/or/or.h b/src/or/or.h index 35e66fe798..f20211d95e 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3068,6 +3068,8 @@ int dirserv_dump_directory_to_string(char **dir_out, int directory_fetches_from_authorities(or_options_t *options); int directory_fetches_dir_info_like_mirror(or_options_t *options); int directory_fetches_dir_info_like_bridge_user(or_options_t *options); +int directory_caches_v2_dir_info(or_options_t *options); +#define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o) int directory_caches_dir_info(or_options_t *options); int directory_permits_begindir_requests(or_options_t *options); int directory_permits_controller_requests(or_options_t *options); diff --git a/src/or/routerparse.c b/src/or/routerparse.c index afdd9dc158..e6d60c9c78 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -687,7 +687,7 @@ router_parse_directory(const char *str) /* Now that we know the signature is okay, and we have a * publication time, cache the directory. */ - if (directory_caches_dir_info(get_options()) && + if (directory_caches_v1_dir_info(get_options()) && !authdir_mode_v1(get_options())) dirserv_set_cached_directory(str, published_on, 0); |