aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-09-08 06:52:33 +0000
committerNick Mathewson <nickm@torproject.org>2004-09-08 06:52:33 +0000
commitc66e4c48704b8be1425c2b6253542beed49ce0eb (patch)
treebab663d3eaff8366181c3dc75ba6a17ec5cfaca1 /src/or/dirserv.c
parentb6798866d058cd7ce69fc3c7944aff85a1693170 (diff)
downloadtor-c66e4c48704b8be1425c2b6253542beed49ce0eb.tar
tor-c66e4c48704b8be1425c2b6253542beed49ce0eb.tar.gz
Flush more changes from sandbox
- make clients cache directories and use them to seed their router lists at startup. This means clients have a datadir again. - Introduce a global_write_bucket. We need to respond better to exhausting it. - Remove the last vestiges of LinkPadding and TrafficShaping. - Configuration infrastructure support for warning on obsolete options. - Refactor directory header parsing to use smartlist_split_string. - Respond to content-encoding headers by trying to uncompress as appropriate. - Reply with a deflated directory when a client asks for "dir.z". (We could use allow-encodings instead, but allow-encodings isn't specified in HTTP 1.0.) svn:r2335
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 984c70288..ba21c0f00 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -630,10 +630,16 @@ void dirserv_set_cached_directory(const char *directory, time_t when)
{
time_t now;
size_t z_len;
+ char filename[512];
tor_assert(!options.AuthoritativeDir);
now = time(NULL);
- if (when>cached_directory_published &&
- when<now+ROUTER_ALLOW_SKEW) {
+ if (when<=cached_directory_published) {
+ log_fn(LOG_INFO, "Ignoring old directory; not caching.");
+ } else if (when>=now+ROUTER_ALLOW_SKEW) {
+ log_fn(LOG_INFO, "Ignoring future directory; not caching.");
+ } if (when>cached_directory_published &&
+ when<now+ROUTER_ALLOW_SKEW) {
+ log_fn(LOG_DEBUG, "Caching directory.");
tor_free(cached_directory);
cached_directory = tor_strdup(directory);
cached_directory_len = strlen(cached_directory);
@@ -644,6 +650,12 @@ void dirserv_set_cached_directory(const char *directory, time_t when)
log_fn(LOG_WARN,"Error compressing cached directory");
}
cached_directory_published = when;
+ if(get_data_directory(&options)) {
+ sprintf(filename,"%s/cached-directory", get_data_directory(&options));
+ if(write_str_to_file(filename,cached_directory) < 0) {
+ log_fn(LOG_WARN, "Couldn't write cached directory to disk. Ignoring.");
+ }
+ }
}
}