213 Commits

Author SHA1 Message Date
Azat Khuzhin
9c91fe1479 http-connect: do not check connection on GET cb 2020-01-12 15:34:01 +03:00
Azat Khuzhin
415ddee337 http-connect: set Host header (for CONNECT and GET) (like curl) 2020-01-12 15:34:01 +03:00
Azat Khuzhin
e54d5fc57c http-connect: cleanup and helpers 2020-01-12 15:34:01 +03:00
Azat Khuzhin
08981f8d75 Fix compilation without OPENSSL_API_COMPAT
Use the following for openssl 1.1+:
- X509_getm_notBefore over X509_get_notBefore
- X509_getm_notAfter  over X509_get_notAfter
- use OPENSSL_VERSION_NUMBER over SSLeay()
- add missing headers

Refs: openssl/openssl@0b7347effe
2020-01-07 22:15:08 +03:00
yangyongsheng
1edb6f6188 Initialize variable to 0 replace use memset function in sample/hello-world.c 2019-12-30 10:09:15 +08:00
yuangongji
78b5bca6d8 sample/https-client: link crypt32 explicitly when build with mingw-w64 2019-10-08 21:38:58 +08:00
yuangongji
572a565130 https-client: load certificates from the system cert store on Windows 2019-09-17 20:57:01 +08:00
Azat Khuzhin
c3f353450e Fix checking return value of the evdns_base_resolv_conf_parse()
Reported-by: Maxim Gorbachyov <maxim.gorbachyov@gmail.com>
2019-09-05 23:32:40 +03:00
David Disseldorp
7d71214e02 sample/http-server: fix parameter parsing
argv[1] is currently unconditionally passed as the docroot to
send_document_cb(). This is broken if any optional parameters are
provided, such as -p <port>.

Signed-off-by: David Disseldorp <ddiss@samba.org>
2019-08-21 01:23:33 +02:00
David Disseldorp
a0276292a5 sample/signal-test: fix use of uninitialized variable
signal_int is uninitialized in the !base error path.

Signed-off-by: David Disseldorp <ddiss@samba.org>
2019-08-21 01:00:07 +02:00
ygj6
759573c9e1 sample: fix 'INFINITY' undeclared error 2019-08-14 19:47:45 +08:00
ygj6
80009c50e5
becat: avoid using anonymous structures
It hasn't been part of the C standard until C11, although it is very
useful GCC extension it is better to avoid using this in cross platform
projects like libevent.
2019-08-14 01:10:50 +03:00
dota17
9c151f3c34
Fix typos in comments (sample/test/event-internal.h) 2019-08-09 12:34:46 +03:00
dota17
101fbe3100
sample/signal-test: add NULL checks
Fixes: #865
2019-08-09 12:31:02 +03:00
Azat Khuzhin
2d4ac10ea4
becat: remove extra SSL_CTX options usage [ci skip]
Because:
- this do not affects performance
- this breaks builds for with older openssl
2019-06-02 21:55:31 +03:00
wenyg
891dd1880f
https-client: correction error checking
When connecting to a non-existent HTTPS service, the "req" is not null
but the "evhttp_request_get_response_code(req)" is zero.

Closes: #822 (cherry-picked)
2019-06-01 00:41:25 +03:00
Azat Khuzhin
4c774b6ceb
time-test: disable buffering (mostly for windows) 2019-05-21 10:59:05 +03:00
Azat Khuzhin
c4de602433
http-server: add usage/help dialog 2019-05-12 18:44:20 +03:00
Azat Khuzhin
737d1beb14
http-server: add ability to bind to unix-socket
Usage example:
  http-server -u -U /tmp/sock /tmp/no-such-dir
  curl -v --unix-socket /tmp/sock 127.1:8080/foo
2019-05-12 18:21:21 +03:00
linxiaohui
16d8564a2c
le-proxy: initiate use of the Winsock DLL
Closes: #803 (cherry-picked)
2019-04-18 22:43:16 +03:00
Azat Khuzhin
428f36e5dd
https-client: do not try to free not initialized base
Otherwise:
  $ https-client --help
  Syntax:
     https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec] [-crt crt]
  Example:
     https-client -url https://ip.appspot.com/
  [warn] event_base_free_: no base to free
2019-04-03 23:24:17 +03:00
Dan Rosen
2f184f8bbf evwatch: Add "prepare" and "check" watchers.
Adds two new callbacks: "prepare" watchers, which fire immediately
before we poll for I/O, and "check" watchers, which fire immediately
after we finish polling and before we process events. This allows other
event loops to be embedded into libevent's, and enables certain
performance monitoring.

Closes: #710
2019-04-03 12:44:50 -04:00
Azat Khuzhin
d5b24cc0c8
sample/becat: bufferevent cat, ncat/nc/telnet analog 2019-03-16 17:40:20 +03:00
Azat Khuzhin
afdccee9b3
s/http-server: fix cleanup routines
Fixes: bdd71f18 ("s/http-server: graceful cleanup")
2019-01-29 01:23:02 +03:00
Azat Khuzhin
56f3bdefca
s/http-server: check for EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED 2018-11-13 23:24:26 +03:00
Azat Khuzhin
bdd71f18b1
s/http-server: graceful cleanup 2018-11-13 11:10:17 +03:00
Azat Khuzhin
41b6b279cd
s/http-server: enable debug logging if EVENT_DEBUG_LOGGING_ALL env isset 2018-11-13 11:10:15 +03:00
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