aboutsummaryrefslogtreecommitdiff
path: root/src/or/entrynodes.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2015-01-29 14:57:00 +0000
committerNick Mathewson <nickm@torproject.org>2015-02-18 09:09:33 -0500
commitf4a63f8eabbdd842ebeb97aabba92ea47c37a607 (patch)
tree4e2cc251b585f2c941e8b3dafc0283d6e840ab2a /src/or/entrynodes.c
parentdb805b91708c02e9b2b4d0c25ec17a45e81929aa (diff)
downloadtor-f4a63f8eabbdd842ebeb97aabba92ea47c37a607.tar.gz
tor-f4a63f8eabbdd842ebeb97aabba92ea47c37a607.zip
Parse GuardFraction info from consensuses and votes.
Also introduce the UseGuardFraction torrc option which decides whether clients should use guardfraction information found in the consensus.
Diffstat (limited to 'src/or/entrynodes.c')
-rw-r--r--src/or/entrynodes.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 5b0e342662..a766f6cba3 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1694,6 +1694,27 @@ getinfo_helper_entry_guards(control_connection_t *conn,
return 0;
}
+/** Return 0 if we should apply guardfraction information found in the
+ * consensus. A specific consensus can be specified with the
+ * <b>ns</b> argument, if NULL the most recent one will be picked.*/
+int
+should_apply_guardfraction(const networkstatus_t *ns)
+{
+ /* We need to check the corresponding torrc option and the consensus
+ * parameter if we need to. */
+ const or_options_t *options = get_options();
+
+ /* If UseGuardFraction is 'auto' then check the same-named consensus
+ * parameter. If the consensus parameter is not present, default to
+ * "off". */
+ if (options->UseGuardFraction == -1) {
+ return networkstatus_get_param(ns, "UseGuardFraction",
+ 0, /* default to "off" */
+ 0, 1);
+ }
+
+ return options->UseGuardFraction;
+}
/** A list of configured bridges. Whenever we actually get a descriptor
* for one, we add it as an entry guard. Note that the order of bridges
* in this list does not necessarily correspond to the order of bridges