summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-11-30 02:23:51 +0000
committerNick Mathewson <nickm@torproject.org>2004-11-30 02:23:51 +0000
commite764d00e15bc3059bb7f204bb39b0ff9c4c45118 (patch)
treecb7a627fd57a01b2ccf5ac34ad8814bc3da4a72d /src/or
parentce505f5033794488df20670a4555e02da9ae81cb (diff)
downloadtor-e764d00e15bc3059bb7f204bb39b0ff9c4c45118.tar.gz
tor-e764d00e15bc3059bb7f204bb39b0ff9c4c45118.zip
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?
svn:r3024
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 18ce5d39e1..8397a0dbda 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -63,7 +63,7 @@ static config_abbrev_t config_abbrevs[] = {
{ "l", "Log", 1},
{ "BandwidthRateBytes", "BandwidthRate", 0},
{ "BandwidthBurstBytes", "BandwidthBurst", 0},
- { "DirFetchPostPeriod", "DirFetchPeriod", 0},
+ { "DirFetchPostPeriod", "StatusFetchPeriod", 0},
{ NULL, NULL , 0},
};
#undef PLURAL
@@ -106,9 +106,9 @@ static config_var_t config_vars[] = {
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 @@ options_validate(or_options_t *options)
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->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->DirFetchPeriod > MIN_ONION_KEY_LIFETIME / 2) {
+
+ 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) {