mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add async dns code from Adam Langley, tweaked to build on OSX. Long-term, we may want to switch to libevnet/c-ares, if they ever handle 10k fd situations properly. This one still needs work too, but at least it is small. This code is disabled by default, and not integrated with dns.c.
svn:r6524
This commit is contained in:
+13
-1
@@ -44,6 +44,18 @@ if test $enable_threads = "yes"; then
|
||||
AC_DEFINE(ENABLE_THREADS, 1, [Defined if we will try to use multithreading])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(eventdns,
|
||||
AC_HELP_STRING(--enable-eventdns, enable asynchronous dns module),
|
||||
[case "${enableval}" in
|
||||
yes) eventdns=true ;;
|
||||
no) eventdns=false ;;
|
||||
*) AC_MSG_ERROR(bad value for --enable-eventdns) ;;
|
||||
esac], [eventdns=false])
|
||||
AM_CONDITIONAL(EVENTDNS, test x$eventdns = xtrue)
|
||||
if test x$eventdns = xtrue; then
|
||||
AC_DEFINE([USE_EVENTDNS], 1, "Define to 1 if we'll be using eventdns.c")
|
||||
fi
|
||||
|
||||
case $host in
|
||||
*-*-solaris* )
|
||||
AC_DEFINE(_REENTRANT, 1, [Define on some platforms to activate x_r() functions in time.h])
|
||||
@@ -347,7 +359,7 @@ dnl These headers are not essential
|
||||
|
||||
AC_CHECK_HEADERS(stdint.h sys/types.h inttypes.h sys/param.h sys/wait.h sys/limits.h netinet/in.h arpa/inet.h machine/limits.h syslog.h sys/time.h sys/resource.h stddef.h inttypes.h utime.h sys/utime.h sys/mman.h)
|
||||
|
||||
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem mmap)
|
||||
AC_CHECK_FUNCS(gettimeofday ftime socketpair uname inet_aton strptime getrlimit setrlimit strlcat strlcpy strtoull getpwnam getpwuid ftello getaddrinfo localtime_r gmtime_r event_get_version event_get_method event_set_log_callback memmem mmap strtok_r)
|
||||
|
||||
if test $enable_threads = "yes"; then
|
||||
AC_CHECK_HEADERS(pthread.h)
|
||||
|
||||
@@ -4,12 +4,19 @@ noinst_PROGRAMS = test
|
||||
|
||||
bin_PROGRAMS = tor
|
||||
|
||||
if EVENTDNS
|
||||
EVDNSSRC = eventdns.c
|
||||
else
|
||||
EVDNSSRC =
|
||||
endif
|
||||
|
||||
tor_SOURCES = buffers.c circuitbuild.c circuitlist.c \
|
||||
circuituse.c command.c config.c \
|
||||
connection.c connection_edge.c connection_or.c control.c \
|
||||
cpuworker.c directory.c dirserv.c dns.c hibernate.c main.c \
|
||||
onion.c policies.c relay.c rendcommon.c rendclient.c rendmid.c \
|
||||
rendservice.c rephist.c router.c routerlist.c routerparse.c \
|
||||
$(EVDNSSRC) \
|
||||
tor_main.c
|
||||
|
||||
tor_LDADD = ../common/libor.a ../common/libor-crypto.a -lz -lssl -lcrypto
|
||||
@@ -20,6 +27,7 @@ test_SOURCES = buffers.c circuitbuild.c circuitlist.c \
|
||||
cpuworker.c directory.c dirserv.c dns.c hibernate.c main.c \
|
||||
onion.c policies.c relay.c rendcommon.c rendclient.c rendmid.c \
|
||||
rendservice.c rephist.c router.c routerlist.c routerparse.c \
|
||||
$(EVDNSSRC) \
|
||||
test.c
|
||||
|
||||
test_LDADD = ../common/libor.a ../common/libor-crypto.a -lz -lssl -lcrypto
|
||||
|
||||
+1585
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
||||
/* This software is Public Domain. To view a copy of the public domain dedication,
|
||||
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
|
||||
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
||||
*
|
||||
* I ask and expect, but do not require, that all derivative works contain an
|
||||
* attribution similar to:
|
||||
* Parts developed by Adam Langley <agl@imperialviolet.org>
|
||||
*
|
||||
* You may wish to replace the word "Parts" with something else depending on
|
||||
* the amount of original code.
|
||||
*
|
||||
* (Derivative works does not include programs which link against, run or include
|
||||
* the source verbatim in their source distributions)
|
||||
*/
|
||||
|
||||
#ifndef EVENTDNS_H
|
||||
#define EVENTDNS_H
|
||||
|
||||
#define DNS_ERR_NONE 0
|
||||
#define DNS_ERR_FORMAT 1
|
||||
#define DNS_ERR_SERVERFAILED 2
|
||||
#define DNS_ERR_NOTEXIST 3
|
||||
#define DNS_ERR_NOTIMPL 4
|
||||
#define DNS_ERR_REFUSED 5
|
||||
#define DNS_ERR_TRUNCATED 65
|
||||
#define DNS_ERR_UNKNOWN 66
|
||||
#define DNS_ERR_TIMEOUT 67
|
||||
|
||||
#define DNS_IPv4_A 1
|
||||
|
||||
#define DNS_QUERY_NO_SEARCH 1
|
||||
|
||||
#define DNS_OPTION_SEARCH 1
|
||||
#define DNS_OPTION_NAMESERVERS 2
|
||||
#define DNS_OPTION_MISC 4
|
||||
#define DNS_OPTIONS_ALL 7
|
||||
|
||||
typedef void (*eventdns_callback_type) (int result, char type, int count, int ttl, void *addresses, void *arg);
|
||||
|
||||
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 *);
|
||||
void eventdns_search_clear();
|
||||
void eventdns_search_add(const char *domain);
|
||||
void eventdns_search_ndots_set();
|
||||
|
||||
#define DNS_NO_SEARCH 1
|
||||
|
||||
#endif // !EVENTDNS_H
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
#include "orconfig.h"
|
||||
#define DNS_USE_OPENSSL_FOR_ID
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char u_char;
|
||||
+1
-1
@@ -924,7 +924,7 @@ rep_hist_circbuilding_dormant(void)
|
||||
return 0;
|
||||
|
||||
/* see if we'll still need to build testing circuits */
|
||||
if (server_mode(options) && !check_whether_orport_reachable())
|
||||
if (server_mode(get_options()) && !check_whether_orport_reachable())
|
||||
return 0;
|
||||
if (!check_whether_dirport_reachable())
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user