[or-cvs] r13699: Patch from mwenge: always willingly serve our own extrainfo (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Sun Feb 24 22:11:13 UTC 2008


Author: nickm
Date: 2008-02-24 17:11:12 -0500 (Sun, 24 Feb 2008)
New Revision: 13699

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/control.c
   tor/trunk/src/or/dirserv.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/router.c
Log:
 r14421 at tombo:  nickm | 2008-02-24 17:05:18 -0500
 Patch from mwenge: always willingly serve our own extrainfo from the controlport



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r14421] on 49666b30-7950-49c5-bedf-9dc8f3168102

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-02-24 22:11:08 UTC (rev 13698)
+++ tor/trunk/ChangeLog	2008-02-24 22:11:12 UTC (rev 13699)
@@ -55,6 +55,9 @@
       get saved to disk by SAVECONF. Make Tor automatically convert
       "HashedControlPassword" to this new option but only when it's
       given on the command line. Partial fix for bug 586.
+    - If we have an extra-info document for our server, always make
+      it available on the control port, even if we haven't gotten
+      a copy of it from an authority yet.  Patch from mwenge.
 
   o Minor features (logging):
     - When SafeLogging is disabled, log addresses along with all TLS

Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c	2008-02-24 22:11:08 UTC (rev 13698)
+++ tor/trunk/src/or/control.c	2008-02-24 22:11:12 UTC (rev 13699)
@@ -1523,8 +1523,17 @@
     if (strlen(question) == HEX_DIGEST_LEN) {
       char d[DIGEST_LEN];
       signed_descriptor_t *sd = NULL;
-      if (base16_decode(d, sizeof(d), question, strlen(question))==0)
-        sd = extrainfo_get_by_descriptor_digest(d);
+      if (base16_decode(d, sizeof(d), question, strlen(question))==0) {
+        /* XXXX this test should move into extrainfo_get_by_descriptor_digest,
+         * but I don't want to risk affecting other parts of the code,
+         * especially since the rules for using our own extrainfo (including
+         * when it might be freed) are different from those for using one
+         * we have downloaded. */
+        if (router_extrainfo_digest_is_me(d))
+          sd = &(router_get_my_extrainfo()->cache_info);
+        else
+          sd = extrainfo_get_by_descriptor_digest(d);
+      }
       if (sd) {
         const char *body = signed_descriptor_get_body(sd);
         if (body)

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2008-02-24 22:11:08 UTC (rev 13698)
+++ tor/trunk/src/or/dirserv.c	2008-02-24 22:11:12 UTC (rev 13699)
@@ -2673,7 +2673,8 @@
     SMARTLIST_FOREACH(digests, const char *, d,
        {
          if (router_digest_is_me(d)) {
-           smartlist_add(descs_out, &(router_get_my_routerinfo()->cache_info));
+           if (router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
+             smartlist_add(descs_out, &(router_get_my_routerinfo()->cache_info));
          } else {
            routerinfo_t *ri = router_get_by_digest(d);
            /* Don't actually serve a descriptor that everyone will think is

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-02-24 22:11:08 UTC (rev 13698)
+++ tor/trunk/src/or/or.h	2008-02-24 22:11:12 UTC (rev 13699)
@@ -3794,6 +3794,7 @@
 extrainfo_t *router_get_my_extrainfo(void);
 const char *router_get_my_descriptor(void);
 int router_digest_is_me(const char *digest);
+int router_extrainfo_digest_is_me(const char *digest);
 int router_is_me(routerinfo_t *router);
 int router_fingerprint_is_me(const char *fp);
 int router_pick_published_address(or_options_t *options, uint32_t *addr);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2008-02-24 22:11:08 UTC (rev 13698)
+++ tor/trunk/src/or/router.c	2008-02-24 22:11:12 UTC (rev 13699)
@@ -1094,6 +1094,19 @@
   return identitykey && !memcmp(identitykey_digest, digest, DIGEST_LEN);
 }
 
+/** Return true iff I'm a server and <b>digest</b> is equal to
+ * my identity digest. */
+int
+router_extrainfo_digest_is_me(const char *digest)
+{
+  if (!router_get_my_extrainfo())
+    return 0;
+
+  return !memcmp(digest,
+                 &(router_get_my_extrainfo()->cache_info).signed_descriptor_digest,
+                 DIGEST_LEN);
+}
+
 /** A wrapper around router_digest_is_me(). */
 int
 router_is_me(routerinfo_t *router)



More information about the tor-commits mailing list