]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make getinfo ns/purpose/bridge actually work
authorRoger Dingledine <arma@torproject.org>
Wed, 19 Dec 2007 04:58:58 +0000 (04:58 +0000)
committerRoger Dingledine <arma@torproject.org>
Wed, 19 Dec 2007 04:58:58 +0000 (04:58 +0000)
Also, dump our bridge router status entries to disk every 30 minutes.

svn:r12871

ChangeLog
doc/tor.1.in
src/or/config.c
src/or/control.c
src/or/main.c
src/or/networkstatus.c
src/or/or.h
src/or/rephist.c

index 4c50b4bca0618ef4f97c05629b4243ab328cb089..bbc2ae1368af73cea5f07e2d41cd5ce7a996c388 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,13 +36,17 @@ Changes in version 0.2.0.13-alpha - 2007-12-??
       AlternateBridgeAuthority, and AlternateHSAuthority) that let the
       user selectively replace the default directory authorities, rather
       than the all-or-nothing replacement that DirServer offers.
-    - Tor can now be configured to read a GeoIP file from disk in one of two
-      formats.  This can be used by controllers to map IPs to countries.
-      Eventually, it may support exit-by-country.
-    - When possible, bridges remember which countries users are coming
-      from, and report aggregate information in their extra-info
-      documents, so that the bridge authorities can learn where Tor is
-      blocked.
+    - Tor can now be configured to read a GeoIP file from disk in one
+      of two formats. This can be used by controllers to map IP addresses
+      to countries. Eventually, it may support exit-by-country.
+    - When possible, bridge relays remember which countries users
+      are coming from, and report aggregate information in their
+      extra-info documents, so that the bridge authorities can learn
+      where Tor is blocked.
+    - Bridge directory authorities now do reachability testing on the
+      bridges they know. They provide router status summaries to the
+      controller on "getinfo ns/purpose/bridge", and also dump summaries
+      to a file periodically.
 
   o Minor bugfixes:
     - The fix in 0.2.0.12-alpha cleared the "hsdir" flag in v3 network
index bf270900c5e7f1fecc0e8a6170fb7edf65942523..4d827c34fdbc53598d4da9435ce4be38470b06e3 100644 (file)
@@ -721,7 +721,7 @@ anything itself; to save bandwidth, leave this option turned off.
 .LP
 .TP
 \fBFallbackNetworkstatusFile\fP \fIFILENAME\fP
-If Tor doesn't have a cached networkstatus file, it starts out uses
+If Tor doesn't have a cached networkstatus file, it starts out using
 this one instead.  Even if this file is out of date, Tor can still use
 it to learn about directory mirrors, so it doesn't need to put load on
 the authorities.  (Default: None).
index f83ca0f2460cf1427c93b00a0fed84c91b4515b8..a7650637f19cf7d1bc810c0bff86c77f0bddea14 100644 (file)
@@ -83,6 +83,7 @@ static config_abbrev_t _option_abbrevs[] = {
   { "ResolvConf", "ServerDNSResolvConfFile", 0, 1},
   { "SearchDomains", "ServerDNSSearchDomains", 0, 1},
   { "PreferTunnelledDirConns", "PreferTunneledDirConns", 0, 0},
+  { "BridgeAuthoritativeDirectory", "BridgeAuthoritativeDir", 0, 0},
   { NULL, NULL, 0, 0},
 };
 /* A list of state-file abbreviations, for compatibility. */
index af1bb42f600dcdd8c42e8c4a628ec4dcdf835038..23c331b93722a4794b0da00bf3ed9b1d11825424 100644 (file)
@@ -1745,6 +1745,8 @@ static const getinfo_item_t getinfo_items[] = {
          "Brief summary of router status by ID (v2 directory format)."),
   PREFIX("ns/name/", networkstatus,
          "Brief summary of router status by nickname (v2 directory format)."),
+  PREFIX("ns/purpose/", networkstatus,
+         "Brief summary of router status by purpose (v2 directory format)."),
 
   PREFIX("unregistered-servers-", dirserv_unregistered, NULL),
   ITEM("network-status", dir,
index 620edad426c531ac82edb6d0b2a4617eeea25566..e00a03ac83fb0e78d1d75aa266ac4f1001d6108f 100644 (file)
@@ -119,8 +119,6 @@ int has_completed_circuit=0;
 /** How long do we let OR connections handshake before we decide that
  * they are obsolete? */
 #define TLS_HANDSHAKE_TIMEOUT           (60)
-/** How often do we write hidden service usage statistics to disk? */
-#define WRITE_HSUSAGE_INTERVAL (900)
 
 /********* END VARIABLES ************/
 
@@ -830,7 +828,10 @@ run_scheduled_events(time_t now)
   static time_t time_to_try_getting_descriptors = 0;
   static time_t time_to_reset_descriptor_failures = 0;
   static time_t time_to_add_entropy = 0;
+#define WRITE_HSUSAGE_INTERVAL (30*60)
   static time_t time_to_write_hs_statistics = 0;
+#define BRIDGE_STATUSFILE_INTERVAL (30*60)
+  static time_t time_to_write_bridge_status_file = 0;
   static time_t time_to_downrate_stability = 0;
 #define SAVE_STABILITY_INTERVAL (30*60)
   static time_t time_to_save_stability = 0;
@@ -1111,6 +1112,12 @@ run_scheduled_events(time_t now)
     hs_usage_write_statistics_to_file(now);
     time_to_write_hs_statistics = now+WRITE_HSUSAGE_INTERVAL;
   }
+  /** 10b. write bridge networkstatus file to disk */
+  if (options->BridgeAuthoritativeDir &&
+      time_to_write_bridge_status_file < now) {
+    hs_usage_write_statistics_to_file(now);
+    time_to_write_bridge_status_file = now+BRIDGE_STATUSFILE_INTERVAL;
+  }
 }
 
 /** Libevent timer: used to invoke second_elapsed_callback() once per
index 884bc0a3a633241586f81f525cf3ede6e54d03eb..e2f3d9281bfaae06c326922d9f7accafba008ebd 100644 (file)
@@ -1685,9 +1685,8 @@ networkstatus_getinfo_helper_single(routerstatus_t *rs)
  * shouldn't use this for general-purpose routers, since those
  * should be listed from the consensus, not from the routers list). */
 char *
-networkstatus_getinfo_by_purpose(const char *purpose_string)
+networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now)
 {
-  time_t now = time(NULL);
   time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
   char *answer;
   routerlist_t *rl = router_get_routerlist();
@@ -1720,6 +1719,21 @@ networkstatus_getinfo_by_purpose(const char *purpose_string)
   return answer;
 }
 
+/** Write out router status entries for all our bridge descriptors. */
+void
+networkstatus_dump_bridge_status_to_file(time_t now)
+{
+  char *status = networkstatus_getinfo_by_purpose("bridge", now);
+  or_options_t *options = get_options();
+  size_t len = strlen(options->DataDirectory) + 32;
+  char *fname = tor_malloc(len);
+  tor_snprintf(fname, len, "%s"PATH_SEPARATOR"networkstatus-bridges",
+               options->DataDirectory);
+  write_str_to_file(fname,status,0);
+  tor_free(fname);
+  tor_free(status);
+}
+
 /** If <b>question</b> is a string beginning with "ns/" in a format the
  * control interface expects for a GETINFO question, set *<b>answer</b> to a
  * newly-allocated string containing networkstatus lines for the appropriate
@@ -1756,7 +1770,7 @@ getinfo_helper_networkstatus(control_connection_t *conn,
   } else if (!strcmpstart(question, "ns/name/")) {
     status = router_get_consensus_status_by_nickname(question+8, 0);
   } else if (!strcmpstart(question, "ns/purpose/")) {
-    *answer = networkstatus_getinfo_by_purpose(question+11);
+    *answer = networkstatus_getinfo_by_purpose(question+11, time(NULL));
     return *answer ? 0 : -1;
   } else {
     return -1;
index 4625f7852cd443d855209f9d2d99928cd130bce1..7aba08ca7515ddbac21addda7ec75d9f6bcda510 100644 (file)
@@ -3361,7 +3361,7 @@ void signed_descs_update_status_from_consensus_networkstatus(
                                                          smartlist_t *descs);
 
 char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
-char *networkstatus_getinfo_by_purpose(const char *purpose_string);
+char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
 int getinfo_helper_networkstatus(control_connection_t *conn,
                                  const char *question, char **answer);
 void networkstatus_free_all(void);
index 1561540d02fcc8020da303c827b39bf50cabb748..2c84e40c2fa761124ef63bad5b95503cf8388e53 100644 (file)
@@ -2153,21 +2153,21 @@ hs_usage_format_statistics(void)
   return buf;
 }
 
-/** Writes current statistics to file. */
+/** Write current statistics about hidden service usage to file. */
 void
 hs_usage_write_statistics_to_file(time_t now)
 {
   char *buf;
   size_t len;
   char *fname;
-  or_options_t *options;
+  or_options_t *options = get_options();
   /* check if we are up-to-date */
   hs_usage_check_if_current_period_is_up_to_date(now);
   buf = hs_usage_format_statistics();
-  options = get_options();
   len = strlen(options->DataDirectory) + 16;
   fname = tor_malloc(len);
-  tor_snprintf(fname,len, "%s"PATH_SEPARATOR"hsusage", options->DataDirectory);
+  tor_snprintf(fname, len, "%s"PATH_SEPARATOR"hsusage",
+               options->DataDirectory);
   write_str_to_file(fname,buf,0);
   tor_free(buf);
   tor_free(fname);