235 Commits

Author SHA1 Message Date
Azat Khuzhin
c22f275744 Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility)
Since OpenSSL 3.0 there is new OPENSSL_VERSION_MAJOR, but previous
releases does not have it.

So let's use plain old OPENSSL_VERSION_NUMBER to avoid more preprocessor
macros.
2022-07-10 10:07:39 +03:00
William Marlow
29c420c418 Initial OpenSSL 3.0 support
* Don't use deprecated functions when building against OpenSSL 3.0.
* Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol.
  error in addition to the expected IO error produced by OpenSSL 1.1.1
* Update regress_mbedtls.c for compatibility with OpenSSL 3
2022-07-09 23:24:53 +03:00
Azat Khuzhin
6e310e3c6c sample/ssl-client-mbedtls.c: fix for MbedTLS 3
- use build_info.h over version.h
- provide own certs

P.S. since it is simpler then adding detection of the library version
into autotools.
2022-07-09 21:11:29 +03:00
Azat Khuzhin
ce20356a32 sample/ssl-client-mbedtls.c: break the loop on EOF 2022-07-09 21:07:49 +03:00
Azat Khuzhin
fcf85e4822 sample/ssl-client-mbedtls.c: fix printing response in readcb 2022-07-09 21:07:49 +03:00
Azat Khuzhin
1bc62ce171 https-client: fix strndup() for mingw build
Right now it still reports [1]:

    2022-07-09T10:53:05.4152800Z ../sample/https-client.c:558:43: warning: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
    2022-07-09T10:53:05.4153300Z   558 |                         char *host_ipv6 = strndup(&host[1], strlen(&host[1]) - 1);
    2022-07-09T10:53:05.4153651Z       |                                           ^~~~~~~
    2022-07-09T10:53:05.4154095Z ../sample/https-client.c:558:43: warning: incompatible implicit declaration of built-in function 'strndup' [-Wbuiltin-declaration-

  [1]: https://github.com/libevent/libevent/runs/7263194178?check_suite_focus=true
2022-07-09 14:39:32 +03:00
William Marlow
e43376df2a Add missing strndup function on Windows to fix build on MSVC 2022
v2: Only define strndup on non-Mingw32 Windows
2022-07-09 13:16:00 +03:00
Azat Khuzhin
41239c9dac https-client: fix connect to ipv6 address with square brackets
getaddrinfo() cannot process addresses like "[::1]", only "::1"

Fixes: #1275
2022-05-12 07:37:19 +03:00
Azat Khuzhin
862b83f9b6 dns-example: add CNAME support 2021-05-24 21:03:58 +03:00
Emil Engler
e77f187274 sample: use unsigned short instead of int for port
The C standard gurantees that an unsigned short is at least up to 65535
huge. Enough to store every TCP port. Also the parameter PORT is
overgiven to the `htons()` function which assumes that the parameter is
of type `uint16_t` which unsigned short is on most platforms.
2021-04-03 12:50:00 +03:00
Azat Khuzhin
eb822ac751 http-server: add -H option to change listen address 2020-10-27 01:23:33 +03:00
Azat Khuzhin
6135248a0c https-client: add newline into error messages 2020-10-27 01:19:40 +03:00
Azat Khuzhin
f51ec25306 https-client: add -4/-6 switches 2020-10-27 01:18:52 +03:00
Azat Khuzhin
22872176a4 becat: add timeout (client/server) and verbosity (event_enable_debug_logging()) 2020-10-15 23:23:15 +03:00
Azat Khuzhin
852af060af http-server: add cli argument for max body size 2020-10-04 17:44:34 +03:00
okhowang(王沛文)
b45a02efab sample: add https-client-mbedtls 2020-09-16 11:57:52 +08:00
okhowang(王沛文)
85c6759926 fix: compat mbedtls < 2.4 2020-07-24 17:19:14 +08:00
Azat Khuzhin
e458696c1e le-proxy: ignore SIGPIPE
Fixes: #1057
2020-07-23 00:28:09 +03:00
okhowang(王沛文)
028385f685 fix build system and add test and cleanup code 2020-07-22 22:53:23 +03:00
Jesse Fang
7680409aa1 simple https client example using mbedtls
Based on mbedtls's source code programs/ssl/ssl_client1.c
2020-07-22 22:52:58 +03:00
Enji Cooper
d4e392b54b Mute clang 8 compilation error with gcc pragma
Move the pragma ignoring outside the function to fix the build with gcc.
While here, add equivalent clang pragmas to mute the warning, as well.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
2020-03-26 18:31:13 -07:00
nntrab
02905413fd Add callback support for error pages
The existing error pages are very basic and don't allow for
multi-lingual support or for conformity with other pages in a web site.
The aim of the callback functionality is to allow custom error pages to
be supported for calls to evhttp_send_error() by both calling
applications and Libevent itself.

A backward-incompatible change has been made to the title of error pages
sent by evhttp_send_error(). The original version of the function used
the reason argument as part of the title. That might have unforeseen
side-effects if it contains HTML tags. Therefore the title has been
changed to always use the standard status text.

An example of the error callback can be found in this
[version](https://github.com/libevent/libevent/files/123607/http-server.zip)
of the 'http-server' sample. It will output error pages with very bright
backgrounds, the error code using a very large font size and the reason.

Closes: #323 (cherr-picked from PR)
2020-01-13 00:50:14 +03:00
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