[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] If anybody set DirFetchPostPeriod, give them StatuFetchPeri...



Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv18359/src/or

Modified Files:
	config.c 
Log Message:
If anybody set DirFetchPostPeriod, give them StatuFetchPeriod instead.  Impose minima and maxima for all *Period options; impose even tighter maxima for fetching if we are a caching dirserver.  Clip rather than rejecting.  arma: are these good?

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- config.c	29 Nov 2004 22:25:29 -0000	1.271
+++ config.c	30 Nov 2004 02:23:51 -0000	1.272
@@ -63,7 +63,7 @@
   { "l", "Log", 1},
   { "BandwidthRateBytes", "BandwidthRate", 0},
   { "BandwidthBurstBytes", "BandwidthBurst", 0},
-  { "DirFetchPostPeriod", "DirFetchPeriod", 0},
+  { "DirFetchPostPeriod", "StatusFetchPeriod", 0},
   { NULL, NULL , 0},
 };
 #undef PLURAL
@@ -106,9 +106,9 @@
   VAR("DataDirectory",       STRING,   DataDirectory,        NULL),
   VAR("DirPort",             UINT,     DirPort,              "0"),
   VAR("DirBindAddress",      LINELIST, DirBindAddress,       NULL),
-  VAR("DirFetchPeriod",      INTERVAL, DirFetchPeriod,       "1 hour"),
-  VAR("DirPostPeriod",       INTERVAL, DirPostPeriod,        "10 minutes"),
-  VAR("RendPostPeriod",      INTERVAL, RendPostPeriod,       "10 minutes"),
+  VAR("DirFetchPeriod",      INTERVAL, DirFetchPeriod,       "1 hours"),
+  VAR("DirPostPeriod",       INTERVAL, DirPostPeriod,        "20 minutes"),
+  VAR("RendPostPeriod",      INTERVAL, RendPostPeriod,       "20 minutes"),
   VAR("DirPolicy",           LINELIST, DirPolicy,            NULL),
   VAR("DirServer",           LINELIST, DirServers,           NULL),
   VAR("ExitNodes",           STRING,   ExitNodes,            NULL),
@@ -1282,26 +1282,60 @@
     result = -1;
   }
 
-#define MIN_DIRFETCHPOSTPERIOD 60
-  if (options->DirFetchPeriod < MIN_DIRFETCHPOSTPERIOD) {
-    log(LOG_WARN, "DirFetchPeriod option must be at least %d.", MIN_DIRFETCHPOSTPERIOD);
-    result = -1;
+#define MIN_DIR_FETCH_PERIOD 600
+#define MIN_DIR_POST_PERIOD 300
+#define MIN_REND_POST_PERIOD 300
+#define MIN_STATUS_FETCH_PERIOD 60
+
+#define MAX_DIR_PERIOD (MIN_ONION_KEY_LIFETIME/2)
+#define MAX_CACHE_DIR_FETCH_PERIOD 3600
+#define MAX_CACHE_STATUS_FETCH_PERIOD 900
+
+  if (options->DirFetchPeriod < MIN_DIR_FETCH_PERIOD) {
+    log(LOG_WARN, "DirFetchPeriod option must be at least %d seconds. Clipping.", MIN_DIR_FETCH_PERIOD);
+    options->DirFetchPeriod = MIN_DIR_FETCH_PERIOD;
   }
-  if (options->StatusFetchPeriod < MIN_DIRFETCHPOSTPERIOD) {
-    log(LOG_WARN, "StatusFetchPeriod option must be at least %d.", MIN_DIRFETCHPOSTPERIOD);
-    result = -1;
+  if (options->StatusFetchPeriod < MIN_STATUS_FETCH_PERIOD) {
+    log(LOG_WARN, "StatusFetchPeriod option must be at least %d seconds. Clipping.", MIN_STATUS_FETCH_PERIOD);
+    options->StatusFetchPeriod = MIN_STATUS_FETCH_PERIOD;
   }
-  if (options->DirPostPeriod < MIN_DIRFETCHPOSTPERIOD) {
-    log(LOG_WARN, "DirPostPeriod option must be at least %d.", MIN_DIRFETCHPOSTPERIOD);
-    result = -1;
+  if (options->DirPostPeriod < MIN_DIR_POST_PERIOD) {
+    log(LOG_WARN, "DirPostPeriod option must be at least %d seconds. Clipping.",
+        MIN_DIR_POST_PERIOD);
+    options->DirPostPeriod = MIN_DIR_POST_PERIOD;
   }
-  if (options->DirFetchPeriod > MIN_ONION_KEY_LIFETIME / 2) {
+  if (options->RendPostPeriod < MIN_REND_POST_PERIOD) {
+    log(LOG_WARN,"RendPostPeriod option must be at least %d seconds. Clipping.",
+        MIN_REND_POST_PERIOD);
+    options->RendPostPeriod = MIN_REND_POST_PERIOD;
+  }
+
+  if (options->DirPort && ! options->AuthoritativeDir) {
+    if (options->DirFetchPeriod > MAX_CACHE_DIR_FETCH_PERIOD) {
+      log(LOG_WARN, "Caching directory servers must have DirFetchPeriod less than %d seconds. Clipping.", MAX_CACHE_DIR_FETCH_PERIOD);
+      options->DirFetchPeriod = MAX_CACHE_DIR_FETCH_PERIOD;
+    }
+    if (options->StatusFetchPeriod > MAX_CACHE_STATUS_FETCH_PERIOD) {
+      log(LOG_WARN, "Caching directory servers must have StatusFetchPeriod less than %d seconds. Clipping.", MAX_CACHE_STATUS_FETCH_PERIOD);
+      options->StatusFetchPeriod = MAX_CACHE_STATUS_FETCH_PERIOD;
+    }
+  }
+
+  if (options->DirFetchPeriod > MAX_DIR_PERIOD) {
     log(LOG_WARN, "DirFetchPeriod is too large; clipping.");
-    options->DirFetchPeriod = MIN_ONION_KEY_LIFETIME / 2;
+    options->DirFetchPeriod = MAX_DIR_PERIOD;
   }
-  if (options->DirPostPeriod > MIN_ONION_KEY_LIFETIME / 2) {
+  if (options->DirPostPeriod > MAX_DIR_PERIOD) {
     log(LOG_WARN, "DirPostPeriod is too large; clipping.");
-    options->DirPostPeriod = MIN_ONION_KEY_LIFETIME / 2;
+    options->DirPostPeriod = MAX_DIR_PERIOD;
+  }
+  if (options->StatusFetchPeriod > MAX_DIR_PERIOD) {
+    log(LOG_WARN, "StatusFetchPeriod is too large; clipping.");
+    options->StatusFetchPeriod = MAX_DIR_PERIOD;
+  }
+  if (options->RendPostPeriod > MAX_DIR_PERIOD) {
+    log(LOG_WARN, "RendPostPeriod is too large; clipping.");
+    options->RendPostPeriod = MAX_DIR_PERIOD;
   }
 
   if (options->KeepalivePeriod < 1) {