[or-cvs] r9285: Implement DNS-related status events. (in tor/trunk: . doc src/or)

nickm at seul.org nickm at seul.org
Sat Jan 6 07:34:08 UTC 2007


Author: nickm
Date: 2007-01-06 02:34:07 -0500 (Sat, 06 Jan 2007)
New Revision: 9285

Modified:
   tor/trunk/
   tor/trunk/doc/control-spec.txt
   tor/trunk/src/or/dns.c
Log:
 r11873 at Kushana:  nickm | 2007-01-06 02:32:18 -0500
 Implement DNS-related status events.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11873] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/doc/control-spec.txt
===================================================================
--- tor/trunk/doc/control-spec.txt	2007-01-06 07:34:02 UTC (rev 9284)
+++ tor/trunk/doc/control-spec.txt	2007-01-06 07:34:07 UTC (rev 9285)
@@ -1152,15 +1152,29 @@
      // from resolve_my_address() in config.c
      [unimplemented]
 
-     // sketchy libevent, sketchy OS, sketchy threading
+     // sketchy OS, sketchy threading
      [unimplemented]
 
      // too many onions queued. threading problem or slow cpu?
      [unimplemented]
 
-     // eventdns statements. like, hijacked dns.
-     [unimplemented]
+     NAMESERVER_STATUS
+     "NS=addr"
+     "STATUS=" "UP" / "DOWN"
+     "ERR=" message
+        One of our nameservers has changed status.
 
+     NAMESERVER_ALL_DOWN
+        All of our nameservers have gone down.
+
+     DNS_HIJACKED
+        Our DNS provider is providing an address when it should be saying
+        "NOTFOUND"; Tor will treat the address as a synonym for "NOTFOUND".
+
+     DNS_USELESS
+        Our DNS provider is giving a hijacked address instead of well-known
+        websites; Tor will not try to be an exit node.
+
      BAD_SERVER_DESCRIPTOR
      "DIRAUTH=addr:port"
      "REASON=string"

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2007-01-06 07:34:02 UTC (rev 9284)
+++ tor/trunk/src/or/dns.c	2007-01-06 07:34:07 UTC (rev 9285)
@@ -171,6 +171,7 @@
 static void
 evdns_log_cb(int warn, const char *msg)
 {
+  const char *cp;
   if (!strcmpstart(msg, "Resolve requested for") &&
       get_options()->SafeLogging) {
     log(LOG_INFO, LD_EXIT, "eventdns: Resolve requested.");
@@ -178,11 +179,25 @@
   } else if (!strcmpstart(msg, "Search: ")) {
     return;
   }
-  if (!strcmpstart(msg, "Nameserver ") && strstr(msg, " has failed: ")) {
+  if (!strcmpstart(msg, "Nameserver ") && (cp=strstr(msg, " has failed: "))) {
+    char *ns = tor_strndup(msg+11, cp-(msg+11));
+    const char *err = strchr(cp, ':'+2);
     /* Don't warn about a single failed nameserver; we'll warn with 'all
      * nameservers have failed' if we're completely out of nameservers;
      * otherwise, the situation is tolerable. */
     warn = 0;
+    control_event_server_status(LOG_WARN,
+                                "NAMESERVER_STATUS NS=%s STATUS=DOWN ERR=%s",
+                                ns, escaped(err));
+    tor_free(ns);
+  } else if (!strcmpstart(msg, "Nameserver ") &&
+             (cp=strstr(msg, " is back up"))) {
+    char *ns = tor_strndup(msg+11, cp-(msg+11));
+    control_event_server_status(LOG_NOTICE,
+                                "NAMESERVER_STATUS NS=%s STATUS=UP", ns);
+    tor_free(ns);
+  } else if (!strcmp(msg, "All nameservers have failed")) {
+    control_event_server_status(LOG_WARN, "NAMESERVER_ALL_DOWN");
   }
   log(warn?LOG_WARN:LOG_INFO, LD_EXIT, "eventdns: %s", msg);
 }
@@ -1720,6 +1735,8 @@
         "\"%s\" as 'not found'.", id, *ip, id);
       smartlist_add(dns_wildcard_list, tor_strdup(id));
     }
+    if (!dns_wildcard_notice_given)
+      control_event_server_status(LOG_NOTICE, "DNS_HIJACKED");
     dns_wildcard_notice_given = 1;
   }
 }
@@ -1746,6 +1763,8 @@
       dns_is_completely_invalid = 1;
       mark_my_descriptor_dirty();
     }
+    if (!dns_wildcarded_test_address_notice_given)
+      control_event_server_status(LOG_WARN, "DNS_USELESS");
     dns_wildcarded_test_address_notice_given = 1;
   }
 }



More information about the tor-commits mailing list