Commit a122bfb4 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

r7007@Kushana: nickm | 2006-08-03 09:58:30 -0700

 Export and use eventdns_config_windows_nameservers(); clean up some comments and log messages.


svn:r6974
parent 2299bbdb
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -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
+9 −5
Original line number Diff line number Diff line
/* $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>
+3 −0
Original line number Diff line number Diff line
@@ -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);