[tor-commits] [tor/master] Also cache the protover summary in the routerinfo_t, if we're using that

nickm at torproject.org nickm at torproject.org
Wed Jan 31 19:34:28 UTC 2018


commit 92496a739aac44a537ee9062a4f0d71fba023156
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Jan 24 13:49:15 2018 -0500

    Also cache the protover summary in the routerinfo_t, if we're using that
---
 src/or/or.h          |  3 +++
 src/or/routerparse.c | 21 ++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/or/or.h b/src/or/or.h
index 0be19fdbd..2ef27a99a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2299,6 +2299,9 @@ typedef struct {
    * this routerinfo. Used only during voting. */
   unsigned int omit_from_vote:1;
 
+  /** Flags to summarize the protocol versions for this routerinfo_t. */
+  protover_summary_flags_t pv;
+
 /** Tor can use this router for general positions in circuits; we got it
  * from a directory server as usual, or we're an authority and a server
  * uploaded it. */
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 1cbbb1728..54759c9a7 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -379,6 +379,10 @@ static int check_signature_token(const char *digest,
                                  int flags,
                                  const char *doctype);
 
+static void summarize_protover_flags(protover_summary_flags_t *out,
+                                     const char *protocols,
+                                     const char *version);
+
 #undef DEBUG_AREA_ALLOC
 
 #ifdef DEBUG_AREA_ALLOC
@@ -1895,12 +1899,19 @@ router_parse_entry_from_string(const char *s, const char *end,
     }
   }
 
-  if ((tok = find_opt_by_keyword(tokens, K_PLATFORM))) {
-    router->platform = tor_strdup(tok->args[0]);
-  }
+  {
+    const char *version = NULL, *protocols = NULL;
+    if ((tok = find_opt_by_keyword(tokens, K_PLATFORM))) {
+      router->platform = tor_strdup(tok->args[0]);
+      version = tok->args[0];
+    }
+
+    if ((tok = find_opt_by_keyword(tokens, K_PROTO))) {
+      router->protocol_list = tor_strdup(tok->args[0]);
+      protocols = tok->args[0];
+    }
 
-  if ((tok = find_opt_by_keyword(tokens, K_PROTO))) {
-    router->protocol_list = tor_strdup(tok->args[0]);
+    summarize_protover_flags(&router->pv, protocols, version);
   }
 
   if ((tok = find_opt_by_keyword(tokens, K_CONTACT))) {





More information about the tor-commits mailing list