summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-01-06 07:34:07 +0000
committerNick Mathewson <nickm@torproject.org>2007-01-06 07:34:07 +0000
commit5239602dbc176729e720cf26fb8ddd0d11658536 (patch)
tree8f516add4bb7794b12b9c8fe2464d3637dece687 /src
parentbc14afe0649febf6e9d7b8cf20b4f0bfe9632553 (diff)
downloadtor-5239602dbc176729e720cf26fb8ddd0d11658536.tar.gz
tor-5239602dbc176729e720cf26fb8ddd0d11658536.zip
r11873@Kushana: nickm | 2007-01-06 02:32:18 -0500
Implement DNS-related status events. svn:r9285
Diffstat (limited to 'src')
-rw-r--r--src/or/dns.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index ed6dcf11de..9e55447e9b 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -171,6 +171,7 @@ init_cache_map(void)
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 @@ evdns_log_cb(int warn, const char *msg)
} 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 @@ wildcard_increment_answer(const char *id)
"\"%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 @@ add_wildcarded_test_address(const char *address)
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;
}
}