From 95f3e6161b0b6182e8ed887067138da93dd0b990 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Fri, 31 Dec 2004 21:47:54 +0000 Subject: [PATCH] require BandwidthRate to be at least 10kB/s svn:r3232 --- src/or/config.c | 20 +++++++++++--------- src/or/or.h | 7 +++++++ src/or/routerlist.c | 6 ------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 580771d759..9fbd357b3a 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -217,15 +217,7 @@ get_options(void) { } /** Change the current global options to contain new_val instead - * of their current value; free the old value as necessary. Where - * new_val is different from the old value, update the process to - * use the new value instead. - * - * Note 1: new_val must have previously been validated with - * options_validate(), or Tor may freak out and exit. - * - * Note 2: We haven't moved all the "act on new configuration" logic - * here yet. Some is still in do_hup() and other places. + * of their current value; free the old value as necessary. */ void set_options(or_options_t *new_val) { @@ -237,6 +229,12 @@ set_options(or_options_t *new_val) { /** Fetch the active option list, and take actions based on it. All * of the things we do should survive being done repeatedly. * Return 0 if all goes well, return -1 if it's time to die. + * + * Note 1: new_val must have previously been validated with + * options_validate(), or Tor may freak out and exit. + * + * Note 2: We haven't moved all the "act on new configuration" logic + * here yet. Some is still in do_hup() and other places. */ int options_act(void) { @@ -1369,6 +1367,10 @@ options_validate(or_options_t *options) log(LOG_WARN,"BandwidthBurst must be less than %d",INT_MAX); result = -1; } + if (options->BandwidthRate < ROUTER_REQUIRED_MIN_BANDWIDTH) { + log(LOG_WARN,"BandwidthRate is set to %d bytes/second. It must be at least %d.", (int)options->BandwidthRate, ROUTER_REQUIRED_MIN_BANDWIDTH); + result = -1; + } if (options->_MonthlyAccountingStart) { if (options->AccountingStart) { diff --git a/src/or/or.h b/src/or/or.h index bc4d4f093d..2bc621400a 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1579,6 +1579,13 @@ void add_nickname_list_to_smartlist(struct smartlist_t *sl, const char *list, in int router_nickname_is_in_list(routerinfo_t *router, const char *list); routerinfo_t *routerlist_find_my_routerinfo(void); int router_nickname_matches(routerinfo_t *router, const char *nickname); + +/** How many seconds a router must be up before we'll use it for + * reliability-critical node positions. + */ +#define ROUTER_REQUIRED_MIN_UPTIME 3600 /* an hour */ +#define ROUTER_REQUIRED_MIN_BANDWIDTH 10000 + int router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw); routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl); routerinfo_t *router_choose_random_node(const char *preferred, diff --git a/src/or/routerlist.c b/src/or/routerlist.c index fccd9f9c7c..293797f6cf 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -396,12 +396,6 @@ routerlist_find_my_routerinfo(void) { return NULL; } -/** How many seconds a router must be up before we'll use it for - * reliability-critical node positions. - */ -#define ROUTER_REQUIRED_MIN_UPTIME 3600 /* an hour */ -#define ROUTER_REQUIRED_MIN_BANDWIDTH 10000 - int router_is_unreliable_router(routerinfo_t *router, int need_uptime, int need_bw) {