aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-09-29 18:13:33 +0000
committerNick Mathewson <nickm@torproject.org>2006-09-29 18:13:33 +0000
commitb21e656eaf8acff1e68a8b13cdbe6e06f463eff5 (patch)
treea8f6c2c8dcceece5fe81ae6944bfd7e75d88bae7
parent05604c60d42afc8dd006c67fad592275b24929a7 (diff)
downloadtor-b21e656eaf8acff1e68a8b13cdbe6e06f463eff5.tar
tor-b21e656eaf8acff1e68a8b13cdbe6e06f463eff5.tar.gz
r9007@Kushana: nickm | 2006-09-29 13:17:32 -0400
Make eventdns give strings for DNS errors, not just error numbers. svn:r8535
-rw-r--r--ChangeLog1
-rw-r--r--src/or/eventdns.c25
-rw-r--r--src/or/eventdns.h1
3 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 964c55643..707a42a52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -85,6 +85,7 @@ Changes in version 0.1.2.2-alpha - 2006-??-??
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
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index c0d974e0b..8ed486214 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -785,8 +785,9 @@ reply_handle(struct request *const req,
// 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 @@ main(int c, char **v) {
event_dispatch();
return 0;
}
+#endif
int
evdns_init(void)
@@ -2306,7 +2308,24 @@ evdns_init(void)
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)
diff --git a/src/or/eventdns.h b/src/or/eventdns.h
index 2aca5ef98..17cf76215 100644
--- a/src/or/eventdns.h
+++ b/src/or/eventdns.h
@@ -53,6 +53,7 @@ typedef void (*evdns_callback_type) (int result, char type, int count, int ttl,
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);