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

[or-cvs] r12259: Implement a FallbackNetworkstatusFile (default to $prefix/sh (in tor/trunk: . doc src/config src/or)



Author: nickm
Date: 2007-10-28 19:44:53 -0400 (Sun, 28 Oct 2007)
New Revision: 12259

Modified:
   tor/trunk/
   tor/trunk/configure.in
   tor/trunk/doc/TODO
   tor/trunk/src/config/Makefile.am
   tor/trunk/src/or/config.c
   tor/trunk/src/or/networkstatus.c
   tor/trunk/src/or/or.h
Log:
 r16246@catbus:  nickm | 2007-10-28 19:34:58 -0400
 Implement a FallbackNetworkstatusFile (default to $prefix/share/tor/fallback-consensus) to that we know about lots of directory servers and routers when we start up the first time.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r16246] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/configure.in
===================================================================
--- tor/trunk/configure.in	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/configure.in	2007-10-28 23:44:53 UTC (rev 12259)
@@ -619,6 +619,12 @@
 AH_TEMPLATE([LOCALSTATEDIR], [Default location to store state files.])
 AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$LOCALSTATEDIR")
 
+dnl Note: this is not the same as Tor's "DataDir" config option.
+DATADIR=`eval echo $datadir`
+AC_SUBST(DATADIR)
+AH_TEMPLATE([DATADIR], [Default location for platform-independent read-only data.])
+AC_DEFINE_UNQUOTED(DATADIR,"$DATADIR")
+
 # Set CFLAGS _after_ all the above checks, since our warnings are stricter
 # than autoconf's macros like.
 if test $ac_cv_c_compiler_gnu = yes; then

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/doc/TODO	2007-10-28 23:44:53 UTC (rev 12259)
@@ -21,8 +21,9 @@
     licenses for other components of the bundles.
 
   - Before the feature freeze: (Nick)
-    - Support for preconfigured mirror lists
-      - Use a pre-shipped fallback consensus.
+    o Support for preconfigured mirror lists
+      o Use a pre-shipped fallback consensus.
+      o Code to install a pre-defined fallback consensus
     . Download consensuses (et al) via if-modified-since
       o Implement backend support for sending if-modified-since
       o Use it for consensuses.

Modified: tor/trunk/src/config/Makefile.am
===================================================================
--- tor/trunk/src/config/Makefile.am	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/src/config/Makefile.am	2007-10-28 23:44:53 UTC (rev 12259)
@@ -3,3 +3,9 @@
 EXTRA_DIST = 
 
 conf_DATA = torrc.sample
+
+data_DATA = fallback-consensus
+
+# If we don't have it, fake it.
+fallback-consensus:
+	touch fallback-consensus
\ No newline at end of file

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/src/or/config.c	2007-10-28 23:44:53 UTC (rev 12259)
@@ -118,6 +118,8 @@
 /** An entry for config_vars: "The option <b>name</b> is obsolete." */
 #define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL }
 
+
+
 /** Array of configuration options.  Until we disallow nonstandard
  * abbreviations, order is significant, since the first matching option will
  * be chosen first.
@@ -175,6 +177,8 @@
   V(ExitNodes,                   STRING,   NULL),
   V(ExitPolicy,                  LINELIST, NULL),
   V(ExitPolicyRejectPrivate,     BOOL,     "1"),
+  V(FallbackNetworkstatusFile,   STRING,
+    DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "fallback-consensus"),
   V(FascistFirewall,             BOOL,     "0"),
   V(FirewallPorts,               CSV,      ""),
   V(FastFirstHopPK,              BOOL,     "1"),

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/src/or/networkstatus.c	2007-10-28 23:44:53 UTC (rev 12259)
@@ -158,6 +158,8 @@
 {
   char *filename;
   char *s;
+  struct stat st;
+  or_options_t *options = get_options();
 
   /* XXXX020 Suppress warnings if cached consensus is bad. */
 
@@ -182,6 +184,24 @@
     tor_free(s);
   }
   tor_free(filename);
+
+  if (!current_consensus ||
+      (stat(options->FallbackNetworkstatusFile, &st)==0 &&
+       st.st_mtime > current_consensus->valid_after)) {
+    s = read_file_to_str(options->FallbackNetworkstatusFile,
+                         RFTS_IGNORE_MISSING, NULL);
+    if (s) {
+      if (networkstatus_set_current_consensus(s, 1, 1)) {
+        log_info(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
+                 options->FallbackNetworkstatusFile);
+      } else {
+        log_notice(LD_FS, "Loaded fallback consensus networkstaus from \"%s\"",
+                   options->FallbackNetworkstatusFile);
+      }
+      tor_free(s);
+    }
+  }
+
   routers_update_all_from_networkstatus(time(NULL));
 
   return 0;

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-10-28 20:30:21 UTC (rev 12258)
+++ tor/trunk/src/or/or.h	2007-10-28 23:44:53 UTC (rev 12259)
@@ -2174,6 +2174,9 @@
   int V3AuthDistDelay;
   /** The number of intervals we think a consensus should be valid. */
   int V3AuthNIntervalsValid;
+
+  /** DOCDOC here and in tor.1 */
+  char *FallbackNetworkstatusFile;
 } or_options_t;
 
 /** Persistent state for an onion router, as saved to disk. */