[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/master] Add support for a new option: FetchDirInfoExtraEarly



Author: Jacob Appelbaum <jacob@xxxxxxxxxxxxx>
Date: Sat, 11 Jul 2009 18:43:33 -0700
Subject: Add support for a new option: FetchDirInfoExtraEarly
Commit: e7576f92dec47ffb48f481b7a92b3fc0c76105eb

This new option will allow clients to download the newest fresh consensus
much sooner than they normally would do so, even if they previously set
FetchDirInfoEarly. This includes a proper ChangeLog entry and an updated man
page.
---
 ChangeLog              |    6 ++++++
 doc/tor.1.in           |    7 +++++++
 src/or/config.c        |    5 +++++
 src/or/networkstatus.c |    9 +++++++--
 src/or/or.h            |    3 +++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c0a1a9e..94d8e8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,12 @@ Changes in version 0.2.2.1-alpha - 2009-??-??
       connecting clients to disk every 24 hours. To enable this, run
       configure with the --enable-entry-stats option, and set
       "EntryStatistics 1" in your torrc.
+     - Certain Tor clients (such as those behind check.torproject.org) may
+       want to fetch the consensus in an extra early manner. To enable this
+       a user may now set FetchDirInfoExtraEarly to 1. This also depends on
+       setting FetchDirInfoEarly to 1. Previous behavior will stay the same
+       as only certain clients who must have this information sooner should
+       set this option.
 
   o Minor bugfixes
     - Hidden service clients didn't use a cached service descriptor that
diff --git a/doc/tor.1.in b/doc/tor.1.in
index 3ac0f92..b6e2231 100644
--- a/doc/tor.1.in
+++ b/doc/tor.1.in
@@ -241,6 +241,13 @@ fetching early. Normal users should leave it off.
 (Default: 0)
 .LP
 .TP
+\fBFetchDirInfoExtraEarly \fR\fB0\fR|\fB1\fR\fP
+If set to 1, Tor will fetch directory information before other
+directory caches. It will attempt to download directory information closer to
+the start of the consensus period. Normal users should leave it off.
+(Default: 0)
+.LP
+.TP
 \fBFetchHidServDescriptors \fR\fB0\fR|\fB1\fR\fP
 If set to 0, Tor will never fetch any hidden service descriptors from
 the rendezvous directories. This option is only useful if you're using
diff --git a/src/or/config.c b/src/or/config.c
index 5137f74..5495b25 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -214,6 +214,7 @@ static config_var_t _option_vars[] = {
   V(FirewallPorts,               CSV,      ""),
   V(FastFirstHopPK,              BOOL,     "1"),
   V(FetchDirInfoEarly,           BOOL,     "0"),
+  V(FetchDirInfoExtraEarly,      BOOL,     "0"),
   V(FetchServerDescriptors,      BOOL,     "1"),
   V(FetchHidServDescriptors,     BOOL,     "1"),
   V(FetchUselessDescriptors,     BOOL,     "0"),
@@ -3181,6 +3182,10 @@ options_validate(or_options_t *old_options, or_options_t *options,
     REJECT("HSAuthorityRecordStats is set but we're not running as "
            "a hidden service authority.");
 
+  if (options->FetchDirInfoExtraEarly && !options->FetchDirInfoEarly)
+    REJECT("FetchDirInfoExtraEarly requires that you also set "
+           "FetchDirInfoEarly");
+
   if (options->ConnLimit <= 0) {
     r = tor_snprintf(buf, sizeof(buf),
         "ConnLimit must be greater than 0, but was set to %d",
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 573197a..df17f49 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1133,8 +1133,13 @@ update_consensus_networkstatus_fetch_time(time_t now)
       /* We want to cache the next one at some point after this one
        * is no longer fresh... */
       start = c->fresh_until + CONSENSUS_MIN_SECONDS_BEFORE_CACHING;
-      /* But only in the first half-interval after that. */
-      dl_interval = interval/2;
+      /* Some clients may need the consensus sooner than others. */
+      if (options->FetchDirInfoExtraEarly) {
+        dl_interval = 60;
+      } else {
+        /* But only in the first half-interval after that. */
+        dl_interval = interval/2;
+      }
     } else {
       /* We're an ordinary client or a bridge. Give all the caches enough
        * time to download the consensus. */
diff --git a/src/or/or.h b/src/or/or.h
index f298d53..e38cf81 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2444,6 +2444,9 @@ typedef struct {
    * means directly from the authorities) no matter our other config? */
   int FetchDirInfoEarly;
 
+  /** Should we fetch our dir info at the start of the consensus period? */
+  int FetchDirInfoExtraEarly;
+
   char *VirtualAddrNetwork; /**< Address and mask to hand out for virtual
                              * MAPADDRESS requests. */
   int ServerDNSSearchDomains; /**< Boolean: If set, we don't force exit
-- 
1.5.6.5