55 Commits

Author SHA1 Message Date
Nick Mathewson
274a7bd9a1 Fix some memory leaks in the unit tests
These don't matter except inasmuch as they give real memory leaks
a place to hide.

Found with valgrind
2010-03-13 00:56:07 -05:00
Nick Mathewson
17efc1cdfa Update all our copyright notices to say "2010" 2010-03-04 01:38:48 -05:00
Nick Mathewson
4faeaea90e Clean up formatting: function/keyword spacing consistency.
- Keywords always have a space before a paren.  Functions never do.

- No more than 3 blank lines in a row.
2010-02-19 03:39:50 -05:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
Nick Mathewson
d4de062efc Add an arc4random implementation for use by evdns
Previously, evdns was at the mercy of the user for providing a good
entropy source; without one, it would be vulnerable to various
active attacks.

This patch adds a port of OpenBSD's arc4random() calls to Libevent
[port by Chris Davis], and wraps it up a little bit so we can use it
more safely.
2010-02-11 12:53:32 -05:00
Nick Mathewson
1dd7e6dc3a Remove the 'flags' argument from evdns_base_set_option()
The 'flags' argument made sense when passed to
evdns_(base_)?parse_resolv_conf when it said which parts of the
resolv.conf file to obey.  But for evdns_set_option(), it was really
silly, since you wouldn't be calling evdns_set_option() unless you
actually wanted to set the option.  Its meaning was basically, "set
this to DNS_OPTIONS_ALL unless you want a funny surprise."

evdns_base_set_option was new in 2.0.1-alpha, so we aren't committed
to keeping it source-compatible.
2010-02-05 13:55:12 -05:00
Niels Provos
b8226390bc move dns utility functions into a separate file so that we can use them for http testing 2010-01-14 16:53:25 -08:00
Nick Mathewson
a334b31c6f More unit tests for getaddrinfo_async: v4timeout and cancel.
One covers the case where the v4 request times out but the v6 request
doesn't.  The other makes sure that cancelling a request actually works.
2010-01-14 14:46:16 -05:00
Nick Mathewson
72dd666777 evdns_getaddrinfo() now supports the /etc/hosts file.
The regular blocking evutil_getaddrinfo() already supported /etc/hosts
by falling back to getaddrinfo() or gethostbyname().  But
evdns_getaddrinfo() had no such facility.  Now it does.

The data structure here isn't very clever.  I guess people with huge
/etc/hosts files will either need to get out of the 1980s, or submit a
patch to this code so that it uses a hashtable instead of a linked
list.

Includes basic unit tests.
2010-01-08 19:36:37 -05:00
Nick Mathewson
1e56a32d08 Make the initial nameserver probe timeout configurable.
When we decide that a nameserver is down, we stop sending queries to
it, except to periodically probe it to see if it has come back up.
Our previous probe sechedule was an ad-hoc and hard-wired "10 seconds,
one minute, 5 minues, 15 minutes, 1 hour, 1 hour, 1 hour...".  There
was nothing wrong with having it be ad-hoc, but making it hard-wired
served no good purpose.

Now the user can set the initial timeout via a new
"initial-probe-timeout:" option; future timeouts back off by a factor
of 3 on every failure to a maximum of 1 hour.

As a side-benefit, this lets us cut the runtime of the dns/retry test
from about 40 seconds to about 3 seconds.  Faster unit tests are
always a good thing.
2009-12-29 16:04:16 -05:00
Nick Mathewson
7511b6a97c Fix a spelling error and remove some dead code
svn:r1551
2009-11-19 00:21:38 +00:00
Nick Mathewson
888007f9a4 Windows *does* have getservbyname, no matter what autoconf says.
TODO: figure out why autoconf is confused about this.

svn:r1538
2009-11-17 02:38:19 +00:00
Nick Mathewson
86f5742015 Add two implementations of getaddrinfo: one blocking and one nonblocking.
The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively.
There are fairly extensive unit tests.

I believe this code conforms to RFC3493 pretty closely, but there are
probably more issues.  It should get tested on more platforms.

This code means we can dump the well-intentioned but weirdly-implemented
bufferevent_evdns and evutil_resolve code.

svn:r1537
2009-11-16 22:25:46 +00:00
Nick Mathewson
72bafc175a Remove the stupid brokenness where DNS option names needed to end with a
colon.

svn:r1536
2009-11-16 22:23:55 +00:00
Nick Mathewson
784b8773a4 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H
svn:r1516
2009-11-06 21:46:57 +00:00
Nick Mathewson
ac633aebdf Fix some build warnings on MSVC, mostly related to signed/unsigned comparisons.
svn:r1510
2009-11-05 21:22:23 +00:00
Nick Mathewson
0b9eb1bffb Add a bufferevent function to resolve a name then connect to it.
This function, bufferevent_socket_connect_hostname() can either use
evdns to do the resolve, or use a new function (evutil_resolve) that
uses getaddrinfo or gethostbyname, like http.c does now.

This function is meant to eventually replace the hostname resolution mess in
http.c.

svn:r1496
2009-11-03 20:40:48 +00:00
Nick Mathewson
9976f1e74c reformat weird indentation in dns tests
svn:r1478
2009-10-29 17:11:12 +00:00
Nick Mathewson
3c2198cb48 Unit test for reverse ipv6 lookup
svn:r1477
2009-10-29 17:10:36 +00:00
Nick Mathewson
5082546682 Fix windows compilation warnings.
svn:r1449
2009-10-21 02:14:16 +00:00
Nick Mathewson
0c09fe5ada Add a couple more evdns tests. Libevent is now, for me, at 80.02% coverage.
svn:r1409
2009-08-03 20:50:56 +00:00
Nick Mathewson
94e8f9b901 Another DNS unit tests, to handle reissues.
The evdns module is now up to ~72% coverage; Libevent is up to nearly 80%.

svn:r1408
2009-08-03 20:15:45 +00:00
Nick Mathewson
dc1f5b1ee0 why say fprintf(stdout, X) when you can say printf?
svn:r1407
2009-08-03 20:15:39 +00:00
Nick Mathewson
213dc2a2ef Fix an annoying evdns crash bug, and add more unit tests for evdns.
svn:r1406
2009-08-03 20:15:32 +00:00
Nick Mathewson
a5006d80cd Unit tests for DNS search.
svn:r1405
2009-08-03 16:15:57 +00:00
Nick Mathewson
72ea534f8e Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
2009-07-28 19:41:57 +00:00
Nick Mathewson
a826a75800 Some tweaks to Brodie Thesfield's MSVC patch.
svn:r1386
2009-07-28 19:41:48 +00:00
Nick Mathewson
5b5b880be7 Various MSVC cleanups from Brodie Thiesfield.
svn:r1385
2009-07-28 19:41:39 +00:00
Nick Mathewson
d866f05585 Patch from Zack Weinberg: normalize perror() tt functions and add tt_fail/tt_abort_printf
svn:r1340
2009-07-13 20:03:00 +00:00
Nick Mathewson
ea664bf29a Refactor test wrappers to divide legacy items from useful stuff.
svn:r1212
2009-04-21 18:46:30 +00:00
Nick Mathewson
4d8919ec44 Do not try to double-free the nameserver in regression test
svn:r1202
2009-04-19 01:58:26 +00:00
Nick Mathewson
d2e9caa6fc Fix evdns_cancel to alert callback and free associated RAM.
Also, we add a test to make sure evdns_cancel is working properly.

svn:r1139
2009-04-06 20:38:19 +00:00
Nick Mathewson
d9628ef4ff Add missing initializers
svn:r1082
2009-01-31 18:36:08 +00:00
Nick Mathewson
eac75f91e4 Port DNS tests.
svn:r1081
2009-01-31 07:32:14 +00:00
Nick Mathewson
b85b710cf5 Update copyright statements to reflect the facts that:
a) this is 2009
b) niels and nick have been comaintainers for a while
c) saying "all rights reserved" when you then go on to explicitly
   disclaim some rights is sheer cargo-cultism.

svn:r1065
2009-01-27 22:34:36 +00:00
Nick Mathewson
8889a77039 Replace all use of config.h with event-config.h.
svn:r1064
2009-01-27 22:30:46 +00:00
Niels Provos
a077fb8c09 rename sys/signal.h to signal.h; configure m4 macro dir; this assist with compilation on Haiku
svn:r1033
2009-01-22 02:47:35 +00:00
Nick Mathewson
169321c9e6 Rename four internal headers to follow the -internal.h convention.
svn:r1000
2009-01-13 20:26:37 +00:00
Niels Provos
87be18daa1 implement evdns_cancel_request; test one of the new evdns_base functions
svn:r980
2008-12-25 16:25:37 +00:00
Nick Mathewson
dd73168556 Implement increased DSN-poisoning resistance via the 0x20 hack.
svn:r958
2008-12-03 20:09:13 +00:00
Nick Mathewson
4e8a339ef7 r19602@catbus: nickm | 2008-05-05 11:45:18 -0400
Make most of the tests use the new headers.


svn:r776
2008-05-05 15:46:00 +00:00
Nick Mathewson
ce4ee418d2 r16733@catbus: nickm | 2007-11-26 14:18:25 -0500
Add an --enable-gcc-warnings option (lifted from Tor) to the configure script.  When provided, and when we are using GCC, we enable a bunch of extra GCC warnings in the compiler.  Also, make the code all build happily with these warnings.


svn:r553
2007-11-26 19:18:49 +00:00
Nick Mathewson
bab0e6d440 r16492@catbus: nickm | 2007-11-06 23:27:32 -0500
Fix unit tests so that an outdated nameserver means "Skip IPv6 tests", not "Abort."


svn:r487
2007-11-07 04:28:54 +00:00
Nick Mathewson
7c507668d7 r16489@catbus: nickm | 2007-11-06 22:51:05 -0500
Do not use "class" as identifier in evdns.h; but use a backward-compatible fix. (Should fix bug 1826515, originally reported by Roger Clark)


svn:r486
2007-11-07 03:52:20 +00:00
Nick Mathewson
1e1f77c5b0 Make the test/ subdirectory buildable under Windows. Well, mingw at least. The tests still don't all pass, but at least now we know that.
svn:r447
2007-09-20 19:08:20 +00:00
Nick Mathewson
35983cd60f r14618@catbus: nickm | 2007-08-16 17:11:47 -0400
In ANSI C, int func() is a function with unspecified arguments, whereas int func(void) is a function that takes no arguments.  Using int func() to mean a function with no arguments is a C++ism, so let's not use or generate it.


svn:r395
2007-08-16 21:12:53 +00:00
Niels Provos
7c6df310c9 remove c++ comments from Jan Kneschke
svn:r373
2007-07-30 23:53:10 +00:00
Niels Provos
b5d2f9a255 rolling back r339: evconfig.h does not work
svn:r341
2007-03-01 06:25:18 +00:00
Niels Provos
127c260bb7 make evconfig.h available as installed header file; not
really ideal but good enough for me; from Nick Mathewson


svn:r339
2007-02-28 04:02:29 +00:00
Niels Provos
faf5f73a69 dns server support from Nick Mathewson; tiny tweaks
to the regression test from me to make it run on
systems where stack variables get initialized with
trash.


svn:r321
2007-02-08 16:39:15 +00:00