diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-06-04 01:05:23 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-06-12 14:27:52 -0400 |
commit | e5b88dc83fb44622f2b0f9c0c242907d1c02311f (patch) | |
tree | 4a3932831da9df966b74ddf59b16aaa2445edb12 /src/or/dns.c | |
parent | cfce7d5deab7839c0ac67c3777e70a2264176ca0 (diff) | |
download | tor-e5b88dc83fb44622f2b0f9c0c242907d1c02311f.tar.gz tor-e5b88dc83fb44622f2b0f9c0c242907d1c02311f.zip |
Update Tor to use Libevent 2.0 APIs when available.
This patch adds a new compat_libevent.[ch] set of files, and moves our
Libevent compatibility and utilitity functions there. We build them
into a separate .a so that nothing else in src/commmon depends on
Libevent (partially fixing bug 507).
Also, do not use our own built-in evdns copy when we have Libevent
2.0, whose evdns is finally good enough (thus fixing Bug 920).
Diffstat (limited to 'src/or/dns.c')
-rw-r--r-- | src/or/dns.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/or/dns.c b/src/or/dns.c index b8dd460889..ba34b406b9 100644 --- a/src/or/dns.c +++ b/src/or/dns.c @@ -13,7 +13,15 @@ #include "or.h" #include "ht.h" +#ifdef HAVE_EVENT2_DNS_H +#include <event2/dns.h> +#include <event2/dns_compat.h> +#else #include "eventdns.h" +#ifndef HAVE_EVDNS_SET_DEFAULT_OUTGOING_BIND_ADDRESS +#define HAVE_EVDNS_SET_DEFAULT_OUTGOING_BIND_ADDRESS +#endif +#endif /** Longest hostname we're willing to resolve. */ #define MAX_ADDRESSLEN 256 @@ -1108,6 +1116,7 @@ configure_nameservers(int force) conf_fname = "/etc/resolv.conf"; #endif +#ifdef HAVE_EVDNS_SET_DEFAULT_OUTGOING_BIND_ADDRESS if (options->OutboundBindAddress) { tor_addr_t addr; if (tor_addr_from_str(&addr, options->OutboundBindAddress) < 0) { @@ -1127,6 +1136,7 @@ configure_nameservers(int force) } } } +#endif if (options->ServerDNSRandomizeCase) evdns_set_option("randomize-case:", "1", DNS_OPTIONS_ALL); @@ -1547,7 +1557,7 @@ dns_launch_wildcard_checks(void) void dns_launch_correctness_checks(void) { - static struct event launch_event; + static struct event *launch_event = NULL; struct timeval timeout; if (!get_options()->ServerDNSDetectHijacking) return; @@ -1555,10 +1565,11 @@ dns_launch_correctness_checks(void) /* Wait a while before launching requests for test addresses, so we can * get the results from checking for wildcarding. */ - evtimer_set(&launch_event, launch_test_addresses, NULL); + if (! launch_event) + launch_event = tor_evtimer_new(NULL, launch_test_addresses, NULL); timeout.tv_sec = 30; timeout.tv_usec = 0; - if (evtimer_add(&launch_event, &timeout)<0) { + if (evtimer_add(launch_event, &timeout)<0) { log_warn(LD_BUG, "Couldn't add timer for checking for dns hijacking"); } } |