186 Commits

Author SHA1 Message Date
Azat Khuzhin
3c8ded5c96
s/http-server: turn off buffering (otherwise do output on win32) 2018-11-13 11:10:12 +03:00
Azat Khuzhin
5d3f9d4d92
s/http-server: add an option to use IOCP 2018-11-13 11:10:11 +03:00
Azat Khuzhin
ed705ba704
s/http-server: add options (for persistent port) 2018-11-13 11:10:08 +03:00
Bogdan Harjoc
855f080430
dns-example: free result in getaddrinfo callback
According to evdns.c, the result not freed by libevent after
the callback runs:

evdns_getaddrinfo_gotresolve()
{
    ...
    data->user_cb(0, data->pending_result, data->user_data);
    data->pending_result = NULL;
    ...
}

To reproduce, build with -fsanitize=address, add -g to the getopt
list in dns-example.c like in the current commit and run

  dns-example -g google.com

Closes: #681 # cherry-picked
2018-08-17 03:22:28 +03:00
Bernard Spil
28b8075400 Fix build with LibreSSL 2.7
LibreSSL 2.7 implements OpenSSL 1.1 API except for BIO_get_init()

See also: https://bugs.freebsd.org/226900
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
Closes: #617 (cherry-pick)
2018-04-02 23:13:28 +03:00
Azat Khuzhin
c2c08e0203 Add missing includes into openssl-compat.h
Before it depends from the caller #include appropriate headers (at least
for OPENSSL_VERSION_NUMBER), but let's make it independent.

Fixes: #574
2017-11-22 10:35:01 +03:00
Azat Khuzhin
33e363f3df Free dns/event bases in dns-example to avoid leaks 2017-11-20 02:08:08 +03:00
Carlo Marcelo Arenas Belón
0ec5edde50 autotools: pass $(OPENSSL_INCS) for samples (FTBFS macOS)
if OpenSSL is in a non standard location, need to pass that information
to any sample that needs it

Closes: #550
2017-08-22 11:28:41 +03:00
Azat Khuzhin
74a2f5935a le-proxy: fix compiling under win32 (because of no "inline" in C)
Include <util-internal.h> for regular "inline", since it is used everywhere.
2017-05-29 21:49:58 +03:00
Azat Khuzhin
d22e12eefa http-connect: exit on error 2017-05-28 16:38:55 +03:00
Maximilian Brunner
00ae45fe53 le-proxy: add missing return statement (UAF)
Refs: #501501501501501501501501501
2017-04-30 02:00:23 +03:00
Pierce Lopez
05318f1314 sample/https-client: use ERR_remove_*state() when we have them
ERR_remove_thread_state:
- openssl 0.9.8         does not have
- openssl 1.0/libressl  has
- openssl 1.1           deprecates
2017-03-06 02:44:58 +03:00
Pierce Lopez
5d18d87916 Do not check for ERR_remove_thread_state() (do not link ssl into every library)
This reverts commit c4e9d9bd662de7f575f2172c160795d452ebe709
("sample/https-client: check for ERR_remove_thread_state() existence").

Calling AC_SEARCH_LIBS() modifies LIBS - -lcrypto incorrectly
ends up in LIBS, and thus linked to by libevent_core.so.

Checking for ERR_remove_thread_state should no longer be needed
because it was introduced in openssl 1.0.0, and the previous line
0.9.8 had support discontinued at the end of 2015.

Fixes: #473
2017-03-06 01:39:29 +03:00
David Disseldorp
55cadb2b03 sample/dns-example: fix compiler warning (getopt() returns an int)
Signed-off-by: David Disseldorp <ddiss@suse.de>
Closes: #449
2017-02-28 00:39:50 +03:00
David Disseldorp
e139cbac0a sample/https-client: use host SSL certificate store by default
Currently a static (Debian) certificate path is used by default, which
can be overridden using the -crt parameter. This commit changes the
default behaviour such that the openssl default certificate store is
used, unless overridden by -crt.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2017-02-28 00:39:50 +03:00
Jan Beich
d057c45e8f Unbreak build with LibreSSL after openssl 1.1 support added
Fixes: 3e9e0a0d46e4 ("Make it build using OpenSSL 1.1.0")
Fixes: #445
2017-01-30 00:25:26 +03:00
johnsonlee
23f9a20e8d Fix incorrect MIME type 2016-12-13 11:54:09 +08:00
Azat Khuzhin
fa58cb1da0 sample/le-proxy: use TLS_method instead of SSLv23_method (latest deprecated) 2016-12-07 01:14:16 +03:00
Azat Khuzhin
122bf144cf le-proxy: fix building under openssl 1.1 (init functions has been deprecated)
Refs: #397
2016-12-07 01:14:16 +03:00
Azat Khuzhin
13a4acdae3 https-cilent: fix compilation warnings about unused vars/functions on win32 2016-12-06 13:27:02 +03:00
Azat Khuzhin
253e7fa90c util-internal: fix __func__ redefinition (netbsd)
==> netbsd: In file included from ../listener.c:57:0:
==> netbsd: ../util-internal.h:58:0: warning: "__func__" redefined [enabled by default]
==> netbsd:  #define __func__ EVENT____func__
==> netbsd:  ^
==> netbsd: In file included from /usr/include/amd64/types.h:39:0,
==> netbsd:                  from /usr/include/sys/types.h:45,
==> netbsd:                  from ../listener.c:30:
==> netbsd: /usr/include/sys/cdefs.h:394:0: note: this is the location of the previous definition
==> netbsd:  #define __func__ __PRETTY_FUNCTION__
2016-12-06 12:54:33 +03:00
Azat Khuzhin
0abe4eba83 sample/http-connect: fix compilation with VS2010
Fixes: nmathewson/Libevent#137
2016-12-06 09:57:16 +03:00
Thomas Bernard
e983712456 use ev_uint16_t instead of unsigned short for port
Like in `sockaddr_in` structure in /usr/include/netinet/in.h

@azat: convert all other users (bench, compat, ..) and tweak message
Fixes: #178
Fixes: #196
Refs: 6bf1ca78
Link: https://codereview.appspot.com/156040043/#msg4
2016-10-26 01:41:13 +03:00
Kurt Roeckx
3e9e0a0d46 Make it build using OpenSSL 1.1.0
Rebased (azat):
- tabs instead of whitespaces
- make openssl-compat.h safe for complex expressions
- do not call sk_SSL_COMP_free() in 1.1 (fixes double free)

TODO:
- clean methods_bufferevent

Closes: #397 (cherry-picked)
2016-10-16 19:05:24 +03:00
basavesh.as
666db91af0 Fix memory leak in signal-test.c 2016-06-29 15:11:50 +05:30
kirillDanshin
2d3cd35362 sample/hello-world: exAmple, not eXMple
Fixes: #334
2016-03-09 01:10:51 +03:00
Azat Khuzhin
1bf7595644 http-connect: make it win32 compilable
Fixes: commit 1d34498ea31134bd7a8fcadcb95910b30a479e19 ("sample: add HTTP
CONNECT tunnelling example using libevent http layer")
2016-01-14 11:58:39 +03:00
Azat Khuzhin
fdf713a08b sample/https-client: allow to change path to ca-certificates
And default to one that linux have, for freebsd you will need:
$ https-client -url https://google.com -crt /usr/local/share/certs/ca-root-nss.crt
2015-11-24 01:37:06 +03:00
Azat Khuzhin
c4e9d9bd66 sample/https-client: check for ERR_remove_thread_state() existence
Fixes: freebsd 9.2 build
2015-11-24 01:19:25 +03:00
Azat Khuzhin
77ad68a658 sample/https-client: replace ERR_remove_state() by ERR_remove_thread_state()
Since ERR_remove_state() is deprecated:
  $ git log --grep ERR_remove_thread_state
  commit 2ecd2ededece66bf090fefc93ef3ddb672d9e71a
  Author: Bodo Möller <bodo@openssl.org>
  Date:   Wed Aug 13 19:30:01 2008 +0000

      Mention ERR_remove_state() deprecation, and ERR_remove_thread_state(NULL).

Link: https://www.openssl.org/docs/manmaster/crypto/ERR_remove_state.html
2015-11-18 15:39:08 +03:00
Azat Khuzhin
3316a21005 Add missing <string.h> for openssl_hostname_validation module
Now it included by openssl, but nfter
openssl/openssl@master-post-reformat-1494-g6329b60 it will print warning
(apparently they dropped <string.h> from the generic headers).
2015-11-18 15:39:00 +03:00
Azat Khuzhin
4637aa8841 sample/https-client: add -timeout option 2015-09-02 19:34:52 +03:00
Azat Khuzhin
f3d7ff5da2 sample/https-client: don't try to free uninitialized SSL
sample/https-client.c:459:3: warning: ‘ssl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   SSL_free(ssl);
2015-08-19 13:23:20 +03:00
Azat Khuzhin
24a1f25ab6 sample/https-client: graceful exit with freeing memory (to make valgrind happy) 2015-08-19 13:19:41 +03:00
Andrey Skriabin
29a04825d0 https-client: correctly handle URLs with no path (like "https://host:port")
path == NULL check removed

Fixes: #233
Fixes: #234
2015-08-19 12:28:03 +03:00
Azat Khuzhin
6dc71e70dc sample/http-connect: don't use assert() to make it work with NDEBUG
Otherwise it will not work for cmake release target type.
2015-08-18 21:59:25 +03:00
Azat Khuzhin
f976d4360b sample/http-connect: made it compatible with C90 2015-08-18 21:29:03 +03:00
Azat Khuzhin
1d34498ea3 sample: add HTTP CONNECT tunnelling example using libevent http layer 2015-08-18 12:59:50 +03:00
Mark Ellzey
620ff243c6 Update dns-example.
There's somebody out there who is going to have a compiler from 1986 who will complain. Better to fix c99 now.
2015-06-17 08:05:53 -07:00
Mark Ellzey
bde231d725 Merge pull request #183 from azat/dns-example
Some improvements for dns-example
2015-06-17 08:00:19 -07:00
Azat Khuzhin
df19a970e1 dns-example: allow to set ns from args
We can't do this using resolv.conf:
$ dns-example -v -c <(echo nameserver 127.0.0.1:10053) ya.ru
Because of how evutil_read_file_() works (using fstat())

And actually glibc for example will not use port from nameserver line, and
because of inet_aton() it will fail if nameserver will have arbitary port:
(gdb) p inet_aton("127.0.0.1", malloc(10000))
$1 = 1
(gdb) p inet_aton("127.0.0.1:53", malloc(10000))
$2 = 0

From glibc/resolv/res_init.c:
  if (MATCH(buf, "nameserver") && nserv < MAXNS) {
      struct in_addr a;
      cp = buf + sizeof("nameserver") - 1;
      while (*cp == ' ' || *cp == '\t')
          cp++;
      if ((*cp != '\0') && (*cp != '\n')
          && __inet_aton(cp, &a)) {
          statp->nsaddr_list[nservall].sin_addr = a;
          statp->nsaddr_list[nservall].sin_family = AF_INET;
          statp->nsaddr_list[nservall].sin_port =
                  htons(NAMESERVER_PORT);
2014-11-08 16:18:52 +03:00
Azat Khuzhin
32f8592c8b dns-example: convert to getopt() 2014-11-08 15:50:45 +03:00
Nick Mathewson
2e2d18bcd3 Merge pull request #170 from azat/https-client-retries
https-client: add -retries argument, for connection retries
2014-10-09 11:29:17 -04:00
Joakim Soderberg
5c7282f7a5 Fix compilation for older OpenSSL versions.
For instance OpenSSL 0.9.7 does not have SSL_set_tlsext_host_name.

Also add the missing EVENT__DISABLE_SAMPLES CMake option.
2014-09-24 13:46:09 +02:00
Azat Khuzhin
d9da844369 https-client: add -retries argument, for connection retries
Using evhttp_connection_set_retries() API.
2014-09-21 23:48:07 +04:00
Nick Mathewson
8bf769c47a Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	sample/http-server.c
2014-08-29 14:32:10 -04:00
Nick Mathewson
6466e88ac1 Use FindClose for handle from FindFirstFile in http-server.c
Noted by Miles Chan as issue #145
2014-08-29 14:31:07 -04:00
Mike Frysinger
0c492b33f9 add a --disable-samples configure flag
For people building & installing libevent in a distro, building all these
sample apps are not useful.  Add a flag to turn them off.
2014-06-13 17:19:50 -04:00
Nick Mathewson
6d72bdca01 Make http-server.c output into good html5 2014-05-30 13:53:27 -04:00
Nick Mathewson
462e6b609b add a cast to https-client.c 2014-03-12 12:45:41 -04:00