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

[or-cvs] r10162: Patch from shibz: implement a getinfo status/version/... so (in tor/trunk: . doc src/or)



Author: nickm
Date: 2007-05-10 15:30:02 -0400 (Thu, 10 May 2007)
New Revision: 10162

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/control.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
Log:
 r12708@catbus:  nickm | 2007-05-10 15:18:08 -0400
 Patch from shibz: implement a getinfo status/version/... so a controller can tell whether the current version is recommended, whether any versions are good, and how many authorities agree.



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-05-10 19:29:46 UTC (rev 10161)
+++ tor/trunk/ChangeLog	2007-05-10 19:30:02 UTC (rev 10162)
@@ -89,6 +89,9 @@
     - Let the controller specify HOP=%d as an argument to ATTACHSTREAM,
       so we can exit from the middle of the circuit.
     - Implement "getinfo status/circuit-established".
+    - Implement "getinfo status/version/..." so a controller can tell whether
+      the current version is recommended, and whether any versions are good,
+      and how many authorities agree.  (Patch from shibz.)
 
   o Minor features (other):
     - Correctly report Windows 95 OSR2 and Windows 98 SE.

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-05-10 19:29:46 UTC (rev 10161)
+++ tor/trunk/doc/TODO	2007-05-10 19:30:02 UTC (rev 10162)
@@ -15,6 +15,9 @@
 
 Documentation and testing on 0.1.2.x-final series
 
+  - Pending backports for 0.1.2.x:
+    - r10148: Open cached-routers with FILE_SHARE_READ on win32.
+
 N - Test guard unreachable logic; make sure that we actually attempt to
     connect to guards that we think are unreachable from time to time.
     Make sure that we don't freak out when the network is down.

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2007-05-10 19:29:46 UTC (rev 10161)
+++ tor/trunk/src/or/control.c	2007-05-10 19:30:02 UTC (rev 10162)
@@ -1463,8 +1463,40 @@
     SMARTLIST_FOREACH(mappings, char *, cp, tor_free(cp));
     smartlist_free(mappings);
   } else if (!strcmpstart(question, "status/")) {
+    /* Note that status/ is not a catch-all for events; there's only supposed
+     * to be a status GETINFO if there's a corresponding STATUS event. */
     if (!strcmp(question, "status/circuit-established")) {
       *answer = tor_strdup(has_completed_circuit ? "1" : "0");
+    } else if (!strcmpstart(question, "status/version/")) {
+      combined_version_status_t st;
+      int is_server = server_mode(get_options());
+      char *recommended;
+      recommended = compute_recommended_versions(time(NULL),
+                                                 !is_server, VERSION, &st);
+      if (!strcmp(question, "status/version/recommended")) {
+        *answer = recommended;
+        return 0;
+      }
+      tor_free(recommended);
+      if (!strcmp(question, "status/version/current")) {
+        switch (st.consensus)
+          {
+          case VS_RECOMMENDED: *answer = tor_strdup("recommended"); break;
+          case VS_OLD: *answer = tor_strdup("obsolete"); break;
+          case VS_NEW: *answer = tor_strdup("new"); break;
+          case VS_NEW_IN_SERIES: *answer = tor_strdup("new in series"); break;
+          case VS_UNRECOMMENDED: *answer = tor_strdup("unrecommended"); break;
+          default: tor_fragile_assert();
+          }
+      } else if (!strcmp(question, "status/version/num-versioning")) {
+        char s[33];
+        tor_snprintf(s, sizeof(s), "%d", st.n_versioning);
+        *answer = tor_strdup(s);
+      } else if (!strcmp(question, "status/version/num-concurring")) {
+        char s[33];
+        tor_snprintf(s, sizeof(s), "%d", st.n_concurring);
+        *answer = tor_strdup(s);
+      }
     } else {
       return 0;
     }
@@ -1547,7 +1579,13 @@
   PREFIX("status/", events, NULL),
   DOC("status/circuit-established",
       "Whether we think client functionality is working."),
-
+  /* DOCDOC specify status/version/ */
+  DOC("status/version/recommended", "List of currently recommended versions."),
+  DOC("status/version/current", "Status of the current version."),
+  DOC("status/version/num-versioning", "Number of versioning authorities."),
+  DOC("status/version/num-concurring",
+      "Number of versioning authorities agreeing on the status of the "
+      "current version"),
   ITEM("address", misc, "IP address of this Tor host, if we can guess it."),
   ITEM("dir-usage", misc, "Breakdown of bytes transferred over DirPort."),
   PREFIX("dir/server/", dir,"Router descriptors as retrieved from a DirPort."),

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-05-10 19:29:46 UTC (rev 10161)
+++ tor/trunk/src/or/or.h	2007-05-10 19:30:02 UTC (rev 10162)
@@ -3193,6 +3193,18 @@
   VS_UNRECOMMENDED=4 /**< This version is not recommended (general case) */
 } version_status_t;
 
+typedef struct combined_version_status_t {
+  /** How many networkstatuses claim to know about versions? */
+  int n_versioning;
+  /** What do the majority of networkstatuses believe about this version? */
+  version_status_t consensus;
+  /** How many networkstatuses constitute the majority? */
+  int n_concurring;
+} combined_version_status_t;
+char *compute_recommended_versions(time_t now, int client,
+                             const char *my_version,
+                             combined_version_status_t *status_out);
+
 int router_get_router_hash(const char *s, char *digest);
 int router_get_dir_hash(const char *s, char *digest);
 int router_get_runningrouters_hash(const char *s, char *digest);

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-05-10 19:29:46 UTC (rev 10161)
+++ tor/trunk/src/or/routerlist.c	2007-05-10 19:30:02 UTC (rev 10162)
@@ -3384,19 +3384,9 @@
  * our server is broken, invalid, obsolete, etc. */
 #define SELF_OPINION_INTERVAL (90*60)
 
-/** Result of checking whether a version is recommended. */
-typedef struct combined_version_status_t {
-  /** How many networkstatuses claim to know about versions? */
-  int n_versioning;
-  /** What do the majority of networkstatuses believe about this version? */
-  version_status_t consensus;
-  /** How many networkstatuses constitute the majority? */
-  int n_concurring;
-} combined_version_status_t;
-
-/** Return a string naming the versions of Tor recommended by
+/** Return a newly allocated string naming the versions of Tor recommended by
  * more than half the versioning networkstatuses. */
-static char *
+char *
 compute_recommended_versions(time_t now, int client,
                              const char *my_version,
                              combined_version_status_t *status_out)