]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Also cache the protover summary in the routerinfo_t, if we're using that
authorNick Mathewson <nickm@torproject.org>
Wed, 24 Jan 2018 18:49:15 +0000 (13:49 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 24 Jan 2018 18:53:56 +0000 (13:53 -0500)
src/or/or.h
src/or/routerparse.c

index 0be19fdbdd9456e220bdc913cdfcca66b0e5b02b..2ef27a99a0ef03d696306279845e30811bf6029d 100644 (file)
@@ -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. */
index 1cbbb172833b181ddb6cbbd746a67bcb9af5abdc..54759c9a7bbf4bfc5db10af2716ead99a4c50b16 100644 (file)
@@ -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))) {