summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-09-12 13:56:36 -0400
committerNick Mathewson <nickm@torproject.org>2012-12-06 11:28:49 -0500
commita8d491a8fdfafe6e56924a19b5169c2eb9d3a66a (patch)
tree2eced68a20fe262b8a688a5592b07b1073339a3a
parent06cd62266f4ce15cf71692344df82b3260fedb89 (diff)
downloadtor-a8d491a8fdfafe6e56924a19b5169c2eb9d3a66a.tar.gz
tor-a8d491a8fdfafe6e56924a19b5169c2eb9d3a66a.zip
Add an option to weight down authorities when choosing a fallback
-rw-r--r--doc/tor.1.txt6
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/or.h4
-rw-r--r--src/or/routerlist.c9
4 files changed, 18 insertions, 2 deletions
diff --git a/doc/tor.1.txt b/doc/tor.1.txt
index e79d21e594..231ac528d2 100644
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@ -322,6 +322,12 @@ GENERAL OPTIONS
distinguishable from other users, because you won't believe the same
authorities they do.
+**DirAuthorityFallbackRate** __NUM__::
+ When configured to use both directory authorities and fallback
+ directories, the directory authorities also work as fallbacks. They are
+ chosen with their regular weights, multiplied by this number, which
+ should be 1.0 or less. (Default: 1.0)
+
**DynamicDHGroups** **0**|**1**::
If this option is set to 1, when running as a server, generate our
own Diffie-Hellman group instead of using the one from Apache's mod_ssl.
diff --git a/src/or/config.c b/src/or/config.c
index af699d9504..17b5b79ce4 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -208,6 +208,7 @@ static config_var_t option_vars_[] = {
OBSOLETE("DirRecordUsageSaveInterval"),
V(DirReqStatistics, BOOL, "1"),
VAR("DirAuthority", LINELIST, DirAuthorities, NULL),
+ V(DirAuthorityFallbackRate, DOUBLE, "1.0"),
V(DisableAllSwap, BOOL, "0"),
V(DisableDebuggerAttachment, BOOL, "1"),
V(DisableIOCP, BOOL, "1"),
diff --git a/src/or/or.h b/src/or/or.h
index cbb437e86c..9f9316b988 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3431,6 +3431,10 @@ typedef struct {
/** List of fallback directory servers */
config_line_t *FallbackDir;
+ /** Weight to apply to all directory authority rates if considering them
+ * along with fallbackdirs */
+ double DirAuthorityFallbackRate;
+
/** If set, use these main (currently v3) directory authorities and
* not the default ones. */
config_line_t *AlternateDirAuthority;
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index a5dd9c40f3..5536d1c61b 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1252,7 +1252,7 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags)
/** Pick a random element from a list of dir_server_t, weighting by their
* <b>weight</b> field. */
static const dir_server_t *
-dirserver_choose_by_weight(const smartlist_t *servers)
+dirserver_choose_by_weight(const smartlist_t *servers, double authority_weight)
{
int n = smartlist_len(servers);
int i;
@@ -1263,6 +1263,8 @@ dirserver_choose_by_weight(const smartlist_t *servers)
for (i = 0; i < n; ++i) {
ds = smartlist_get(servers, i);
weights[i].dbl = ds->weight;
+ if (ds->is_authority)
+ weights[i].dbl *= authority_weight;
}
scale_array_elements_to_u64(weights, n, NULL);
@@ -1290,6 +1292,8 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist,
const int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_);
const int no_serverdesc_fetching =(flags & PDS_NO_EXISTING_SERVERDESC_FETCH);
const int no_microdesc_fetching =(flags & PDS_NO_EXISTING_MICRODESC_FETCH);
+ const double auth_weight = (sourcelist == fallback_dir_servers) ?
+ options->DirAuthorityFallbackRate : 1.0;
smartlist_t *pick_from;
int n_busy = 0;
int try_excluding = 1, n_excluded = 0;
@@ -1368,7 +1372,8 @@ router_pick_trusteddirserver_impl(const smartlist_t *sourcelist,
}
{
- const dir_server_t *selection = dirserver_choose_by_weight(pick_from);
+ const dir_server_t *selection =
+ dirserver_choose_by_weight(pick_from, auth_weight);
if (selection)
result = &selection->fake_status;