diff --git a/doc/control-spec.txt b/doc/control-spec.txt index 198aaafd36..cd911b5cb0 100644 --- a/doc/control-spec.txt +++ b/doc/control-spec.txt @@ -1152,14 +1152,28 @@ do for each. -RD] // 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" 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; } }