r9007@Kushana: nickm | 2006-09-29 13:17:32 -0400

Make eventdns give strings for DNS errors, not just error numbers.


svn:r8535
This commit is contained in:
Nick Mathewson
2006-09-29 18:13:33 +00:00
parent 05604c60d4
commit b21e656eaf
3 changed files with 24 additions and 3 deletions
+1
View File
@@ -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
+22 -3
View File
@@ -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)
+1
View File
@@ -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);