[tor-commits] [tor/master] Change dataflow on generating 'dir-cache' flag.

nickm at torproject.org nickm at torproject.org
Mon Dec 21 12:30:55 UTC 2015


commit 54406f78b84103ed7fd4610a89dda9d37f0f033e
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Nov 3 09:29:31 2015 -0500

    Change dataflow on generating 'dir-cache' flag.
    
    Convention is that router_dump_router_to_string() should look at its
    input "router", which should be generated by
    router_build_fresh_descirptor().
---
 src/or/router.c     |    3 ++-
 src/test/test_dir.c |    8 ++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/or/router.c b/src/or/router.c
index 5e4f855..5c680ce 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1899,6 +1899,7 @@ router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e)
   ri->addr = addr;
   ri->or_port = router_get_advertised_or_port(options);
   ri->dir_port = router_get_advertised_dir_port(options, 0);
+  ri->supports_tunnelled_dir_requests = dir_server_mode(options);
   ri->cache_info.published_on = time(NULL);
   ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); /* must invoke from
                                                         * main thread */
@@ -2675,7 +2676,7 @@ router_dump_router_to_string(routerinfo_t *router,
     tor_free(p6);
   }
 
-  if (dir_server_mode(options)) {
+  if (router->supports_tunnelled_dir_requests) {
     smartlist_add(chunks, tor_strdup("tunnelled-dir-server\n"));
   }
 
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 97a9200..cf95df5 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -111,6 +111,7 @@ test_dir_formats(void *arg)
   r1->cache_info.published_on = 0;
   r1->or_port = 9000;
   r1->dir_port = 9003;
+  r1->supports_tunnelled_dir_requests = 1;
   tor_addr_parse(&r1->ipv6_addr, "1:2:3:4::");
   r1->ipv6_orport = 9999;
   r1->onion_pkey = crypto_pk_dup_key(pk1);
@@ -155,6 +156,7 @@ test_dir_formats(void *arg)
   r2->cache_info.published_on = 5;
   r2->or_port = 9005;
   r2->dir_port = 0;
+  r2->supports_tunnelled_dir_requests = 1;
   r2->onion_pkey = crypto_pk_dup_key(pk2);
   curve25519_keypair_t r2_onion_keypair;
   curve25519_keypair_generate(&r2_onion_keypair, 0);
@@ -176,12 +178,9 @@ test_dir_formats(void *arg)
   options->ContactInfo = tor_strdup("Magri White "
                                     "<magri at elsewhere.example.com>");
 
-  options->ORPort_set = options->DirPort_set = options->AssumeReachable = 1;
   buf = router_dump_router_to_string(r1, pk2, NULL, NULL, NULL);
 
   tor_free(options->ContactInfo);
-  /* Reset for later */
-  options->ORPort_set = options->DirPort_set = options->AssumeReachable = 0;
   tt_assert(buf);
 
   strlcpy(buf2, "router Magri 192.168.0.1 9000 0 9003\n"
@@ -301,8 +300,6 @@ test_dir_formats(void *arg)
   strlcat(buf2, "tunnelled-dir-server\n", sizeof(buf2));
   strlcat(buf2, "router-sig-ed25519 ", sizeof(buf2));
 
-  options->ORPort_set = 1;
-  
   buf = router_dump_router_to_string(r2, pk1, pk2, &r2_onion_keypair, &kp2);
   tt_assert(buf);
   buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
@@ -314,7 +311,6 @@ test_dir_formats(void *arg)
   buf = router_dump_router_to_string(r2, pk1, NULL, NULL, NULL);
 
   /* Reset for later */
-  options->ORPort_set = 0;
   cp = buf;
   rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
   tt_assert(rp2);





More information about the tor-commits mailing list