diff options
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 70 |
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) { |