[or-cvs] r8535: Make eventdns give strings for DNS errors, not just error nu (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Sep 29 18:13:34 UTC 2006


Author: nickm
Date: 2006-09-29 14:13:33 -0400 (Fri, 29 Sep 2006)
New Revision: 8535

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/eventdns.c
   tor/trunk/src/or/eventdns.h
Log:
 r9007 at Kushana:  nickm | 2006-09-29 13:17:32 -0400
 Make eventdns give strings for DNS errors, not just error numbers.



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-09-29 18:13:29 UTC (rev 8534)
+++ tor/trunk/ChangeLog	2006-09-29 18:13:33 UTC (rev 8535)
@@ -85,6 +85,7 @@
       by us right now' with 'listed as down by the directory authorities'.
       With the old code, if a guard was unreachable by us but listed as
       running, it would clog our guard list forever.
+    - Make eventdns give strings for DNS errors, not just error numbers.
 
   o Documentation
     - Documented (and renamed) ServerDNSSearchDomains and

Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c	2006-09-29 18:13:29 UTC (rev 8534)
+++ tor/trunk/src/or/eventdns.c	2006-09-29 18:13:33 UTC (rev 8535)
@@ -785,8 +785,9 @@
 			// we regard these errors as marking a bad nameserver
 			if (req->reissue_count < global_max_reissues) {
 				char msg[64];
-				snprintf(msg, sizeof(msg), "Bad response %d",
-					 error);
+
+				snprintf(msg, sizeof(msg), "Bad response %d (%s)",
+						 error, evdns_err_to_string(error));
 				nameserver_failed(req->ns, msg);
 				if (!request_reissue(req)) return;
 			}
@@ -2292,6 +2293,7 @@
 	event_dispatch();
 	return 0;
 }
+#endif
 
 int
 evdns_init(void)
@@ -2306,8 +2308,25 @@
         return (res);
 }
 
-#endif
+const char *
+evdns_err_to_string(int err)
+{
+    switch (err) {
+	case DNS_ERR_NONE: return "no error";
+	case DNS_ERR_FORMAT: return "misformatted query";
+	case DNS_ERR_SERVERFAILED: return "server failed";
+	case DNS_ERR_NOTEXIST: return "name does not exist";
+	case DNS_ERR_NOTIMPL: return "query not implemented";
+	case DNS_ERR_REFUSED: return "refused";
 
+	case DNS_ERR_TRUNCATED: return "reply truncated or ill-formed";
+	case DNS_ERR_UNKNOWN: return "unknown";
+	case DNS_ERR_TIMEOUT: return "request timed out";
+	case DNS_ERR_SHUTDOWN: return "dns subsystem shut down";
+	default: return "[Unknown error code]";
+	}
+}
+
 void
 evdns_shutdown(int fail_requests)
 {

Modified: tor/trunk/src/or/eventdns.h
===================================================================
--- tor/trunk/src/or/eventdns.h	2006-09-29 18:13:29 UTC (rev 8534)
+++ tor/trunk/src/or/eventdns.h	2006-09-29 18:13:33 UTC (rev 8535)
@@ -53,6 +53,7 @@
 
 int evdns_init(void);
 void evdns_shutdown(int fail_requests);
+const char * evdns_err_to_string(int err);
 int evdns_nameserver_add(unsigned long int address);
 int evdns_count_nameservers(void);
 int evdns_clear_nameservers_and_suspend(void);



More information about the tor-commits mailing list