[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [or-cvs] r13688: Servers that don't know their own IP address should go to th (in tor/trunk: . src/or)



On Saturday 23 February 2008 23:39:16 arma@xxxxxxxx wrote:
> Author: arma
> Date: 2008-02-23 18:39:16 -0500 (Sat, 23 Feb 2008)
> New Revision: 13688
>
> Modified:
>    tor/trunk/ChangeLog
>    tor/trunk/src/or/dirserv.c
>    tor/trunk/src/or/router.c
> Log:
> Servers that don't know their own IP address should go to the
> authorities for their first directory fetch, even if their DirPort
> is off or if they don't know they're reachable yet. This will help
> them bootstrap better. Bugfix on 0.2.0.18-alpha; fixes bug 609.
>
>

I encountered this bug while trying to get 'getinfo extra-info/digest/X' to 
work for my own server's extra-info digest.

The attached fixes 2 things:

1. Though it shouldn't happen now that desc_routerinfo is properly created, 
adding a null &(router_get_my_routerinfo()->cache_info) in 
dirserv_get_routerdescs causes a segfault later on in getinfo_helper_dir.

2. If the requested extra-info is for our own server, supply it every time: it 
isn't always retrievable by extrainfo_get_by_descriptor_digest.
Index: src/or/dirserv.c
===================================================================
--- src/or/dirserv.c	(revision 13692)
+++ src/or/dirserv.c	(working copy)
@@ -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
Index: src/or/control.c
===================================================================
--- src/or/control.c	(revision 13692)
+++ src/or/control.c	(working copy)
@@ -1523,8 +1523,12 @@
     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) {
+        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)
Index: src/or/or.h
===================================================================
--- src/or/or.h	(revision 13692)
+++ src/or/or.h	(working copy)
@@ -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);
Index: src/or/router.c
===================================================================
--- src/or/router.c	(revision 13692)
+++ src/or/router.c	(working copy)
@@ -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)

Attachment: signature.asc
Description: This is a digitally signed message part.