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

[or-cvs] r8449: Fix a couple of server-side reverse dns bugs (tor/trunk/src/or)



Author: nickm
Date: 2006-09-21 20:10:26 -0400 (Thu, 21 Sep 2006)
New Revision: 8449

Modified:
   tor/trunk/src/or/dns.c
Log:
Fix a couple of server-side reverse dns bugs

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-09-21 22:57:07 UTC (rev 8448)
+++ tor/trunk/src/or/dns.c	2006-09-22 00:10:26 UTC (rev 8449)
@@ -420,6 +420,7 @@
       tor_assert(0);
       return;
     }
+  // log_notice(LD_EXIT, "Sending a regular RESOLVED reply: ");
   connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
                                RELAY_COMMAND_RESOLVED, buf, buflen,
                                conn->cpath_layer);
@@ -446,9 +447,11 @@
   set_uint32(buf+2+namelen, htonl(ttl));
   buflen = 2+namelen+4;
 
+  // log_notice(LD_EXIT, "Sending a reply RESOLVED reply: %s", hostname);
   connection_edge_send_command(conn, circuit_get_by_edge_conn(conn),
                                RELAY_COMMAND_RESOLVED, buf, buflen,
                                conn->cpath_layer);
+  // log_notice(LD_EXIT, "Sent");
 }
 
 /** Given a lower-case <b>address</b>, check to see whether it's a
@@ -473,7 +476,7 @@
   if (len >= INET_NTOA_BUF_LEN)
     return -1; /* Too long. */
 
-  memcpy(buf, cp, len);
+  memcpy(buf, address, len);
   buf[len] = '\0';
   if (tor_inet_aton(buf, &inaddr) == 0)
     return -1; /* malformed. */
@@ -571,6 +574,8 @@
         connection_free(TO_CONN(exitconn));
       return -1;
     }
+    //log_notice(LD_EXIT, "Looks like an address %s",
+//	exitconn->_base.address);
   }
 
   /* now check the hash table to see if 'address' is already there. */
@@ -809,11 +814,16 @@
   if (outcome == DNS_RESOLVE_FAILED_TRANSIENT)
     return;
 
+  //log_notice(LD_EXIT, "Adding to cache: %s -> %s (%lx, %s), %d",
+  //           address, is_reverse?"(reverse)":"", (unsigned long)addr,
+  //           hostname?hostname:"NULL",(int)outcome);
+
   resolve = tor_malloc_zero(sizeof(cached_resolve_t));
   resolve->magic = CACHED_RESOLVE_MAGIC;
   resolve->state = (outcome == DNS_RESOLVE_SUCCEEDED) ?
     CACHE_STATE_CACHED_VALID : CACHE_STATE_CACHED_FAILED;
   strlcpy(resolve->address, address, sizeof(resolve->address));
+  resolve->is_reverse = is_reverse;
   if (is_reverse) {
     tor_assert(hostname);
     resolve->result.hostname = tor_strdup(hostname);
@@ -1494,6 +1504,7 @@
       char *escaped_address;
       is_reverse = 1;
       hostname = ((char**)addresses)[0];
+      status = DNS_RESOLVE_SUCCEEDED;
       escaped_address = esc_for_log(string_address);
       log_debug(LD_EXIT, "eventdns said that %s resolves to %s",
                 safe_str(escaped_address),