169 Commits

Author SHA1 Message Date
Nick Mathewson
57b7248823 Small cleanups on freebsd-connect-refused patch.
There should be no need to call be_socket_enable: that does an
event_add().  What we really want to do is event_active(), to make
sure that the writecb is executed.

Also, there was one "} if () {" that was missing an else.

I've noted that the return value for evutil_socket_connect() is
getting screwy, but since that isn't an exported function, we can fix
it whenever.
2010-02-27 22:27:13 -05:00
Niels Provos
7bc48bfd3a deal with connect() failing immediately 2010-02-27 18:59:06 -08: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
6810bdb101 Always use our own gai_strerror() replacement.
This is necessary if we have any errors that the platform gai_strerror()
doesn't know how to handle.
2010-02-05 13:55:12 -05:00
Nick Mathewson
c18490e642 Add a check to make soure our EVUTIL_AI flags do not conflict with the native ones 2010-02-05 01:09:01 -05:00
Nick Mathewson
5c7a7bca4c Fix windows and msvc build 2010-01-23 20:07:05 -05:00
Nick Mathewson
918e9c5e72 Fix a number of warnings from gcc -pedantic 2010-01-23 16:38:36 -05:00
Nick Mathewson
26e1b6f298 Remove some commented-out code in evutil 2010-01-21 01:51:40 -05:00
Nick Mathewson
8d4aaf9086 Don't use a bind address for nameservers on loopback
If the user sets a bind address to use for nameservers, and a
nameserver happens to be on 127.0.0.1, the nameserver will generally
fail.  This patch alters this behavior so that the bind address is
only applied when the nameserver is on a non-loopback address.
2010-01-20 12:56:54 -05:00
Nick Mathewson
0f7144fd8b Refactor code from evdns into a new internal "read a file" function. 2010-01-08 19:36:35 -05:00
Nick Mathewson
ba2945f931 Merge branch 'ratelimit'
Conflicts:
	bufferevent_async.c
2010-01-06 17:59:44 -05:00
Nick Mathewson
165d30e31a Fix compilation of rate-limiting code on win32. 2009-12-30 14:29:56 -05:00
Jardel Weyrich
d0939d2b97 Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.
Use this to eliminate the various macros that called F_SETFD throughout
the code.
2009-12-29 15:12:56 -05:00
Jardel Weyrich
4df7dbcbdf Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking().
Apparently, a successful return value on F_SETFL is "anything but
-1".
2009-12-29 15:11:52 -05:00
Jardel Weyrich
5a43df82b8 Improve readability of evutil_unparse_protoname() 2009-12-28 16:03:47 -05:00
Jardel Weyrich
0d64051f5b Fix a bogus free in evutil_new_addrinfo() 2009-12-28 16:01:59 -05:00
Jardel Weyrich
4c8b7cdc64 Make evutil_make_socket_nonblocking() leave any other flags alone.
Fixes bug 2922121
2009-12-28 16:00:05 -05:00
Nick Mathewson
f070a4aed2 Do the proper hack for the (Open)BSD getaddrinfo quirk.
From evutil.c:

   Some older BSDs (like OpenBSD up to 4.6) used to believe that
   giving a numeric port without giving an ai_socktype was verboten.
   We test for this so we can apply an appropriate workaround.  If it
   turns out that the bug is present, then:

    - If nodename==NULL and servname is numeric, we build an answer
      ourselves using evutil_getaddrinfo_common().

    - If nodename!=NULL and servname is numeric, then we set
      servname=NULL when calling getaddrinfo, and post-process the
      result to set the ports on it.

   We test for this bug at runtime, since otherwise we can't have the
   same binary run on multiple BSD versions.

svn:r1550
2009-11-18 23:18:55 +00:00
Nick Mathewson
201d8d0baf Clarify even more about various system-specific problems with getaddrinfo
svn:r1542
2009-11-17 18:29:44 +00:00
Nick Mathewson
9151d000e6 Use the common-case code from getaddrinfo_common *always*; OS differences are just too huge.
svn:r1541
2009-11-17 03:36:43 +00:00
Nick Mathewson
3451c870da Never pass our weird flags to the system getaddrinfo. Make sure there is no overlap between flag values.
svn:r1540
2009-11-17 02:57:32 +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
629a613398 When running set[ug]id, don't check the environment.
Idea from OpenBSD, but made a bit more generic to handle uncivilized lands
that do not define issetugid.

svn:r1530
2009-11-15 18:59:59 +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
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
25af695441 When a bufferevent_connect() call fails, give the client an error callback.
Patch from Christopher Davis.

svn:r1444
2009-10-14 00:46:47 +00:00
Nick Mathewson
621aafd27a Export sockaddr comparison functionality.
svn:r1400
2009-07-30 22:11:23 +00:00
Nick Mathewson
7c20a6ae52 Export an ev_socklen_t.
svn:r1391
2009-07-30 17:01:21 +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
709c21c48c Bufferevent support for openssl.
This code adds a new Bufferevent type that is only compiled when the
openssl library is present.  It supports using an SSL object and an
event alert mechanism, which can either be an fd or an underlying
bufferevent.

There is still more work to do: the unit tests are incomplete, and we
need to support flush and shutdown much better.  Sometimes events are
generated needlessly: this will hose performance.

There's a new encrypting proxy in sample/le-proxy.c.

This code has only been tested on OSX, and nowhere else.

svn:r1382
2009-07-28 04:03:57 +00:00
Nick Mathewson
043515bc52 Stop using C++ style comments.
svn:r1343
2009-07-14 18:50:06 +00:00
Nick Mathewson
01be8708e9 Fix compile on cygwin. This isnt the solution I would like: I would prefer to get pton and ntop to work even when AF_INET6 is not defined.
svn:r1326
2009-06-11 19:09:08 +00:00
Nick Mathewson
f11dff2c7a Add and use locale-independent strcasecmp functions.
svn:r1280
2009-05-07 03:45:51 +00:00
Nick Mathewson
ebf294559e Compilation fixes for vc++ 2008 express. Not the end of them.
svn:r1260
2009-04-30 23:49:15 +00:00
Nick Mathewson
50e20fe076 fix a typo in a comment
svn:r1251
2009-04-29 20:48:35 +00:00
Nick Mathewson
a835c7cf18 fix a misindent
svn:r1200
2009-04-18 18:27:56 +00:00
Nick Mathewson
acaf65c359 Make evutil_parse_sockaddr_port give a useful socket-length output.
svn:r1118
2009-02-11 17:23:32 +00:00
Nick Mathewson
cd731b77d7 Do not use ctypes functions in cases when we need the "net" locale.
This patch adds a new set of EVUTIL_IS* functions to replace use of
the ctypes is* functions in all cases where we care about characters'
interpretations in net ascii rather than in the locale.  For example,
when we're working with DNS hostnames, we don't want to do the 0x20
hack on non-ascii characters, even if the host thinks they should be
isalpha.

svn:r1114
2009-02-10 21:40:12 +00:00
Nick Mathewson
da49d6a3b0 Stop using platform inet_aton/inet_addr; they can behave strangely on certain misformed addresses.
svn:r1111
2009-02-10 19:43:11 +00:00
Nick Mathewson
c7b2f8fdc9 New function to abstract SO_REUSEADDR.
svn:r1102
2009-02-10 19:38:05 +00:00
Nick Mathewson
722885fba9 Some mingws have AF_UNIX, which may have prevented our socketpair from working at all on them. Fix that.
svn:r1098
2009-02-02 21:59:53 +00:00
Nick Mathewson
f13bede758 Fix an unlikely degenerate case of evutil_vsnprintf
svn:r1067
2009-01-28 20:31:19 +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
Nick Mathewson
9993137cbb Remove all trailing whitespace in all the source files.
svn:r1063
2009-01-27 21:10:31 +00:00
Niels Provos
70405e3c7a fix freebsd compile; from Alexander Drozdov
svn:r1030
2009-01-21 07:18:31 +00:00
Nick Mathewson
9935d5b01e Fix win32 compilation. Surprisingly, unit tests pass too.
svn:r1002
2009-01-13 21:39:32 +00:00