r11862@Kushana: nickm | 2007-01-06 01:05:15 -0500

Re-enable warning when we resolve an already resolved address.  We only warn here now if the address is not a testing address.  Also, refactor out a function to check whether an address is used for testing.


svn:r9280
This commit is contained in:
Nick Mathewson 2007-01-06 06:26:46 +00:00
parent c8466c5919
commit 336624ce8f
2 changed files with 21 additions and 11 deletions

View File

@ -20,6 +20,10 @@ Changes in version 0.1.2.6-alpha - 2007-??-??
server status events so controllers can learn about Tor's progress in
deciding whether it's reachable from the outside.
o Minor bugfixes:
- Restore a warning message if we accidentally resolve an address that
we weren't planning to resolve.
Changes in version 0.1.2.5-alpha - 2007-01-06
o Major features:

View File

@ -886,6 +886,14 @@ add_answer_to_cache(const char *address, int is_reverse, uint32_t addr,
set_expiry(resolve, time(NULL) + dns_get_expiry_ttl(ttl));
}
static INLINE int
is_test_address(const char *address)
{
or_options_t *options = get_options();
return options->ServerDNSTestAddresses &&
smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
}
/** Called on the OR side when a DNS worker or the eventdns library tells us
* the outcome of a DNS resolve: tell all pending connections about the result
* of the lookup, and cache the value. (<b>address</b> is a NUL-terminated
@ -909,10 +917,8 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
resolve = HT_FIND(cache_map, &cache_root, &search);
if (!resolve) {
or_options_t *options = get_options();
int is_test_address = options->ServerDNSTestAddresses &&
smartlist_string_isin_case(options->ServerDNSTestAddresses, address);
if (!is_test_address)
int is_test_addr = is_test_address(address);
if (!is_test_addr)
log_info(LD_EXIT,"Resolved unasked address %s; caching anyway.",
escaped_safe_str(address));
add_answer_to_cache(address, is_reverse, addr, hostname, outcome, ttl);
@ -923,9 +929,11 @@ dns_found_answer(const char *address, int is_reverse, uint32_t addr,
if (resolve->state != CACHE_STATE_PENDING) {
/* XXXX Maybe update addr? or check addr for consistency? Or let
* VALID replace FAILED? */
log_info(LD_EXIT, "Resolved %s which was already resolved; ignoring",
escaped_safe_str(address));
/* XXXX012 this triggers in ordinary life. nick says it's a bug. */
int is_test_addr = is_test_address(address);
if (!is_test_addr)
log_notice(LD_EXIT,
"Resolved %s which was already resolved; ignoring",
escaped_safe_str(address));
tor_assert(resolve->pending_connections == NULL);
return;
}
@ -1602,11 +1610,9 @@ evdns_callback(int result, char type, int count, int ttl, void *addresses,
status = DNS_RESOLVE_FAILED_TRANSIENT;
}
if (was_wildcarded) {
or_options_t *options = get_options();
int is_test_address = options->ServerDNSTestAddresses &&
smartlist_string_isin_case(options->ServerDNSTestAddresses, hostname);
int is_test_addr = is_test_address(hostname);
if (is_test_address) {
if (is_test_addr) {
/* Ick. We're getting redirected on known-good addresses. Our DNS
* server must really hate us. */
add_wildcarded_test_address(hostname);