[or-cvs] r9181: Add a version entry to networkstatus documents; have this en (in tor/trunk: . doc src/or)

nickm at seul.org nickm at seul.org
Sun Dec 24 04:09:51 UTC 2006


Author: nickm
Date: 2006-12-23 23:09:48 -0500 (Sat, 23 Dec 2006)
New Revision: 9181

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/routerlist.c
   tor/trunk/src/or/routerparse.c
Log:
 r11694 at Kushana:  nickm | 2006-12-23 23:09:20 -0500
 Add a version entry to networkstatus documents; have this entry get parsed and used to calculate whether begin_dir is supported.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11694] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/ChangeLog	2006-12-24 04:09:48 UTC (rev 9181)
@@ -7,6 +7,11 @@
     - Enable write limiting as well as read limiting. Now we sacrifice
       capacity if we're pushing out lots of directory traffic, rather
       than overrunning the user's intended bandwidth limits.
+    - Authorities now include server versions in networkstatus. This adds
+      about 2% to the side of compressed networkstatus docs, and allows
+      clients to tell which servers support BEGIN_DIR and which don't.
+      The implementation is forward-compatible with a proposed future
+      protocol version scheme not tied to Tor versions.
 
   o Minor features:
     - Start using the state file to store bandwidth accounting data:

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/doc/TODO	2006-12-24 04:09:48 UTC (rev 9181)
@@ -55,14 +55,14 @@
 R     - handle connect-dir streams that don't have a chosen_exit_name set.
       o include ORPort in DirServers lines so we can know where to connect.
         list the orport as 0 if it can't handle begin_dir.
-N     - list versions in status page
-        a new line in the status entry. "Tor 0.1.2.2-alpha". If it's
-        a version, treat it like one. If it's something else, assume
-        it's at least 0.1.2.x.
-        maybe we could have it be a new 'v' line in the status, with
-        key=value syntax. so we could have a 'tor' version, but we
-        could also have a 'conn' version, a 'dir' version, etc down
-        the road. and one day maybe the 'tor' key would be deprecated.
+      o List versions in status page
+        o A new line in the status entry. "Tor 0.1.2.2-alpha". If it's
+          a version, treat it like one. If it's something else, assume
+          it's at least 0.1.2.x.
+        D maybe we could have it be a new 'v' line in the status, with
+          key=value syntax. so we could have a 'tor' version, but we
+          could also have a 'conn' version, a 'dir' version, etc down
+          the road. and one day maybe the 'tor' key would be deprecated.
 
   o Document .noconnect addresses...
     A new file 'address-spec.txt' that describes .exit, .onion,
@@ -193,7 +193,7 @@
       - separate config options for read vs write limiting
 
   - Forward compatibility fixes
-    - Stop requiring "opt" to ignore options in descriptors, networkstatuses,
+    o Stop requiring "opt" to ignore options in descriptors, networkstatuses,
       and so on.
     - Caches should start trying to cache consensus docs?
     - Start uploading short and long descriptors; authorities should support

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/src/or/dirserv.c	2006-12-24 04:09:48 UTC (rev 9181)
@@ -1561,6 +1561,17 @@
         goto done;
       }
       outp += strlen(outp);
+      if (ri->platform && !strcmpstart(ri->platform, "Tor ")) {
+        const char *eos = find_whitespace(ri->platform+4);
+        char *platform = tor_strndup(ri->platform+4, eos-(ri->platform+4));
+        if (tor_snprintf(outp, endp-outp,
+                         "opt v %s\n", platform)) {
+          log_warn(LD_BUG, "Unable to print router version.");
+          goto done;
+        }
+        tor_free(platform);
+        outp += strlen(outp);
+      }
     }
   });
 

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/src/or/or.h	2006-12-24 04:09:48 UTC (rev 9181)
@@ -1013,6 +1013,13 @@
   unsigned int is_bad_exit:1; /**< True iff this node is a bad choice for
                                * an exit node. */
 
+  /** True iff we know version info for this router. (i.e., a "v" entry was
+   * included.)  We'll replace all these with a big tor_vesion_t or a char[]
+   * if the number of traits we care about ever becomes incredibly big. */
+  unsigned int version_known:1;
+  /** True iff this router is a version that supports BEGIN_DIR cells. */
+  unsigned int version_supports_begindir:1;
+
   /** True if we, as a directory mirror, want to download the corresponding
    * routerinfo from the authority who gave us this routerstatus.  (That is,
    * if we don't have the routerinfo, and if we haven't already tried to get it

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/src/or/routerlist.c	2006-12-24 04:09:48 UTC (rev 9181)
@@ -3345,6 +3345,7 @@
   while (1) {
     int n_running=0, n_named=0, n_valid=0, n_listing=0;
     int n_v2_dir=0, n_fast=0, n_stable=0, n_exit=0, n_guard=0, n_bad_exit=0;
+    int n_version_known=0, n_supports_begindir=0;
     int n_desc_digests=0, highest_count=0;
     const char *the_name = NULL;
     local_routerstatus_t *rs_out, *rs_old;
@@ -3432,6 +3433,10 @@
         ++n_v2_dir;
       if (rs->is_bad_exit)
         ++n_bad_exit;
+      if (rs->version_known)
+        ++n_version_known;
+      if (rs->version_supports_begindir)
+        ++n_supports_begindir;
     }
     /* Go over the descriptor digests and figure out which descriptor we
      * want. */
@@ -3482,6 +3487,9 @@
     rs_out->status.is_stable = n_stable > n_statuses/2;
     rs_out->status.is_v2_dir = n_v2_dir > n_statuses/2;
     rs_out->status.is_bad_exit = n_bad_exit > n_listing_bad_exits/2;
+    rs_out->status.version_known = n_version_known > 0;
+    rs_out->status.version_supports_begindir =
+      n_supports_begindir > n_version_known/2;
     if (!rs_old || memcmp(rs_old, rs_out, sizeof(local_routerstatus_t)))
       smartlist_add(changed_list, rs_out);
   }

Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c	2006-12-24 04:09:42 UTC (rev 9180)
+++ tor/trunk/src/or/routerparse.c	2006-12-24 04:09:48 UTC (rev 9181)
@@ -54,6 +54,7 @@
   K_SERVER_VERSIONS,
   K_R,
   K_S,
+  K_V,
   K_EVENTDNS,
   _UNRECOGNIZED,
   _ERR,
@@ -117,6 +118,7 @@
                                                            DIR|NETSTATUS},
   { "r",                   K_R,                   ARGS,    NO_OBJ, RTRSTATUS },
   { "s",                   K_S,                   ARGS,    NO_OBJ, RTRSTATUS },
+  { "v",                   K_V,               CONCAT_ARGS, NO_OBJ, RTRSTATUS },
   { "reject",              K_REJECT,              ARGS,    NO_OBJ,  RTR },
   { "router",              K_ROUTER,              ARGS,    NO_OBJ,  RTR },
   { "recommended-software",K_RECOMMENDED_SOFTWARE,ARGS,    NO_OBJ,  DIR },
@@ -1075,9 +1077,17 @@
         rs->is_possible_guard = 1;
       else if (!strcmp(tok->args[i], "BadExit"))
         rs->is_bad_exit = 1;
-
     }
   }
+  if ((tok = find_first_by_keyword(tokens, K_V))) {
+    rs->version_known = 1;
+    if (strcmpstart(tok->args[0], "Tor ")) {
+      rs->version_supports_begindir = 1;
+    } else {
+      rs->version_supports_begindir =
+        tor_version_as_new_as(tok->args[0], "0.1.2.2-alpha");
+    }
+  }
 
   if (!strcasecmp(rs->nickname, UNNAMED_ROUTER_NICKNAME))
     rs->is_named = 0;



More information about the tor-commits mailing list