Browse Source

r11862@Kushana: nickm | 2007-01-06 01:05:15 -0500
Re-enable warning when we resolve an already resolved address. We only warn here now if the address is not a testing address. Also, refactor out a function to check whether an address is used for testing.


svn:r9280

Nick Mathewson 19 years ago
parent
commit
336624ce8f
2 changed files with 21 additions and 11 deletions
  1. 4 0
      ChangeLog
  2. 17 11
      src/or/dns.c

+ 4 - 0
ChangeLog

@@ -20,6 +20,10 @@ Changes in version 0.1.2.6-alpha - 2007-??-??
       server status events so controllers can learn about Tor's progress in
       server status events so controllers can learn about Tor's progress in
       deciding whether it's reachable from the outside.
       deciding whether it's reachable from the outside.
 
 
+  o Minor bugfixes:
+    - Restore a warning message if we accidentally resolve an address that
+      we weren't planning to resolve.
+
 
 
 Changes in version 0.1.2.5-alpha - 2007-01-06
 Changes in version 0.1.2.5-alpha - 2007-01-06
   o Major features:
   o Major features:

+ 17 - 11
src/or/dns.c

@@ -886,6 +886,14 @@ add_answer_to_cache(const char *address, int is_reverse, uint32_t addr,
   set_expiry(resolve, time(NULL) + dns_get_expiry_ttl(ttl));
   set_expiry(resolve, time(NULL) + dns_get_expiry_ttl(ttl));
 }
 }
 
 
+static INLINE int
+is_test_address(const char *address)
+{
+  or_options_t *options = get_options();
+  return options->ServerDNSTestAddresses &&
+    smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
+}
+
 /** Called on the OR side when a DNS worker or the eventdns library tells us
 /** Called on the OR side when a DNS worker or the eventdns library tells us
  * the outcome of a DNS resolve: tell all pending connections about the result
  * the outcome of a DNS resolve: tell all pending connections about the result
  * of the lookup, and cache the value.  (<b>address</b> is a NUL-terminated
  * of the lookup, and cache the value.  (<b>address</b> is a NUL-terminated
@@ -909,10 +917,8 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
 
 
   resolve = HT_FIND(cache_map, &cache_root, &search);
   resolve = HT_FIND(cache_map, &cache_root, &search);
   if (!resolve) {
   if (!resolve) {
-    or_options_t *options = get_options();
-    int is_test_address = options->ServerDNSTestAddresses &&
-      smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
-    if (!is_test_address)
+    int is_test_addr = is_test_address(address);
+    if (!is_test_addr)
       log_info(LD_EXIT,"Resolved unasked address %s; caching anyway.",
       log_info(LD_EXIT,"Resolved unasked address %s; caching anyway.",
                escaped_safe_str(address));
                escaped_safe_str(address));
     add_answer_to_cache(address, is_reverse, addr, hostname, outcome, ttl);
     add_answer_to_cache(address, is_reverse, addr, hostname, outcome, ttl);
@@ -923,9 +929,11 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
   if (resolve->state != CACHE_STATE_PENDING) {
   if (resolve->state != CACHE_STATE_PENDING) {
     /* XXXX Maybe update addr? or check addr for consistency? Or let
     /* XXXX Maybe update addr? or check addr for consistency? Or let
      * VALID replace FAILED? */
      * VALID replace FAILED? */
-    log_info(LD_EXIT, "Resolved %s which was already resolved; ignoring",
-             escaped_safe_str(address));
-    /* XXXX012 this triggers in ordinary life. nick says it's a bug. */
+    int is_test_addr = is_test_address(address);
+    if (!is_test_addr)
+      log_notice(LD_EXIT,
+                 "Resolved %s which was already resolved; ignoring",
+                 escaped_safe_str(address));
     tor_assert(resolve->pending_connections == NULL);
     tor_assert(resolve->pending_connections == NULL);
     return;
     return;
   }
   }
@@ -1602,11 +1610,9 @@ evdns_callback(int result, char type, int count, int ttl, void *addresses,
       status = DNS_RESOLVE_FAILED_TRANSIENT;
       status = DNS_RESOLVE_FAILED_TRANSIENT;
   }
   }
   if (was_wildcarded) {
   if (was_wildcarded) {
-    or_options_t *options = get_options();
-    int is_test_address = options->ServerDNSTestAddresses &&
-      smartlist_string_isin_case(options->ServerDNSTestAddresses, hostname);
+    int is_test_addr = is_test_address(hostname);
 
 
-    if (is_test_address) {
+    if (is_test_addr) {
       /* Ick.  We're getting redirected on known-good addresses.  Our DNS
       /* Ick.  We're getting redirected on known-good addresses.  Our DNS
        * server must really hate us.  */
        * server must really hate us.  */
       add_wildcarded_test_address(hostname);
       add_wildcarded_test_address(hostname);