summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dns.c24
-rw-r--r--src/or/eventdns.c14
-rw-r--r--src/or/eventdns.h3
3 files changed, 25 insertions, 16 deletions
diff --git a/src/or/dns.c b/src/or/dns.c
index a61ff12de1..fd63181f8b 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -7,18 +7,16 @@ const char dns_c_id[] =
/**
* \file dns.c
- * \brief Implements a farm of 'DNS worker' threads or processes to
- * perform DNS lookups for onion routers and cache the results.
- * [This needs to be done in the background because of the lack of a
- * good, ubiquitous asynchronous DNS implementation.]
+ * \brief Implements a local cache for DNS results for Tor servers.
+ * We provide two asynchrounous backend implementations:
+ * 1) A farm of 'DNS worker' threads or processes to perform DNS lookups for
+ * onion routers and cache the results.
+ * 2) A wrapper around Adam Langley's eventdns.c code, to send requests
+ * to the nameservers asynchronously.
+ * (We can't just use gethostbyname() and friends because we really need to
+ * be nonblocking.)
**/
-/* See
- * http://elvin.dstc.com/ListArchive/elvin-dev/archive/2001/09/msg00027.html
- * for some approaches to asynchronous dns. We will want to switch once one of
- * them becomes more commonly available.
- */
-
#include "or.h"
#include "../common/ht.h"
#ifdef USE_EVENTDNS
@@ -166,19 +164,23 @@ dns_init(void)
or_options_t *options = get_options();
eventdns_set_log_fn(eventdns_log_cb);
if (options->Nameservers && smartlist_len(options->Nameservers)) {
+ log_info(LD_EXIT, "Configuring nameservers from Tor configuration");
SMARTLIST_FOREACH(options->Nameservers, const char *, ip,
{
struct in_addr in;
- log_info(LD_EXIT, "Parsing /etc/resolv.conf");
if (tor_inet_aton(ip, &in)) {
log_info(LD_EXIT, "Adding nameserver '%s'", ip);
eventdns_nameserver_add(in.s_addr);
}
});
} else {
+#ifdef MS_WINDOWS
+ eventdns_config_windows_nameservers();
+#else
log_info(LD_EXIT, "Parsing /etc/resolv.conf");
eventdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS|DNS_OPTION_MISC,
"/etc/resolv.conf");
+#endif
}
}
#endif
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index 583f8f7289..1a9f839931 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -1,10 +1,14 @@
/* $Id$ */
-// Modified from agl's original; see CVS for more info.
-// Try to keep this re-mergeable by Adam. Don't make it depend on Tor.
-// TODO:
-// - Learn about nameservers on win32.
-// - Support AAAA (?), A6, and PTR records.
+/* The original version of this module was written by Adam Langley; for
+ * a history of modifications, check out the subversion logs.
+ *
+ * When editiing this module, try to keep it re-mergeable by Adam. Don't
+ * reformat the whitespace, add Tor dependencies, or so on.
+ *
+ * TODO:
+ * - Support IPv6 and PTR records.
+ */
/* Async DNS Library
* Adam Langley <agl@imperialviolet.org>
diff --git a/src/or/eventdns.h b/src/or/eventdns.h
index 27fb195846..0cb39a2156 100644
--- a/src/or/eventdns.h
+++ b/src/or/eventdns.h
@@ -52,6 +52,9 @@ int eventdns_nameserver_add(unsigned long int address);
int eventdns_nameserver_ip_add(const char *ip_as_string);
int eventdns_resolve(const char *name, int flags, eventdns_callback_type callback, void *ptr);
int eventdns_resolv_conf_parse(int flags, const char *);
+#ifdef MS_WINDOWS
+int eventdns_config_windows_nameservers(void);
+#endif
void eventdns_search_clear(void);
void eventdns_search_add(const char *domain);
void eventdns_search_ndots_set(const int ndots);