262 Commits

Author SHA1 Message Date
Kirill Rodriguez
a8cd11f90f
remove proxy-connection from http-connect 2024-10-29 11:18:48 +00:00
icy17
25f4439dbd sample/event-read-fifo: add proper exit path
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-07-09 07:12:47 +02:00
icy17
09738283d9 Fix potential Null pointer dereference in event-read-fifo.c 2024-07-09 07:12:20 +02:00
Cœur
49d6b4b099
samples: use evutil_socket_t instead and handle 64 bit Windows (#1682)
* Use evutil_socket_t instead in http server sample and handle 64 bit Windows

* Update http-server.c

* consistently using EV_SOCK_FMT for Windows compatibility

* code review: fix missing symbol strsignal

* Add evutil_strsignal() helper instead of strsignal() macro

---------

Co-authored-by: Hernan Martinez <hernan.c.martinez@gmail.com>
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-07-08 10:10:42 +02:00
Cœur
dabf4e132d
Fix potential Null pointer dereference in ws-chat-server.c (#1674)
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:10:56 +02:00
Cœur
6d8c38afe7 Reducing the number of mingw warnings 2024-06-02 18:21:49 +03:00
Andy Pan
ee4fa05dfe Fix the compiler errors in sample/http-server.c
---------

Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
icy17
64decd48e2
Fix potential Null pointer dereference in dns-example.c (#1601) 2024-04-29 07:51:22 +02:00
icy17
a584efaa0e Fix potential Null pointer dereference in time-test.c 2024-04-29 08:47:25 +03:00
Andy Pan
23cdd61063 Use evutil_set_tcp_keepalive for sample/becat.c
Since #1532 introduced the util function for consolidating TPC keep-alive settings,
there is no need to write other handmade functions elsewhere.
2024-01-15 10:49:55 +03:00
Hemanth Nandish
0c54433c12
time-test: use event_new for compatibility with future libevent (#1525) 2023-11-26 21:53:23 +01:00
Sam James
4c38de8cb3
Fix -Walloc-size (#1526)
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2023-11-26 21:52:32 +01:00
Azat Khuzhin
9e4693ed07 becat: change -R to -b (since it is more of a buffer size) 2023-09-22 10:21:06 +02:00
Azat Khuzhin
617cf5efa8 becat: add ability to set TCP keepalive 2023-09-22 10:21:06 +02:00
Azat Khuzhin
d9780cf96a Fix -Wsingle-bit-bitfield-constant-conversion warning in clang 16
report:

    /src/le/libevent/sample/becat.c:304:29: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
                            case 'k': o.extra.keep   = 1; break;
2023-09-21 22:04:17 +02:00
Dmitry Ilyin
f39ad1c494
ws: replace evws_send with evws_send_text/evws_send_binary (ABI breakage) (#1500)
Replace evws_send with evws_send_text, and introduce new API -
evws_send_binary, that can be used to send binary frames.

But note, that this commit breaks the ABI compatibility, but it should be OK,
since there was only alpha release with evws_send, and nobody should rely on
this, and I hope nobody does (we decided to go this way to avoid supporting
deprecated API).
2023-08-31 21:38:41 +02:00
Azat Khuzhin
2b729238e5 becat: fix handling positional arguments 2023-06-28 21:33:41 +02:00
Azat Khuzhin
687124d018 becat: handle -T correctly 2023-06-28 21:33:41 +02:00
Leo Zhang
1418e793ad build: fix some new warnings
/opensource/libevent/sample/ws-chat-server.c:253:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
2023-05-25 07:00:35 +02:00
Zhipeng Xue
3a0cf34ba5 ws-chat-server: fix potential resource leak 2023-03-05 16:48:27 +01:00
Zhipeng Xue
bac9d10a6d
Fix potential null dereference in http-server (#1430)
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2023-03-04 22:13:54 +01:00
Azat Khuzhin
72a4fe76fc ws-chat-server: fix session name initialization (using of uninitialized data) 2022-11-12 19:00:10 +01:00
Azat Khuzhin
8482e227a8 ws-chat-server: avoid SIGSEGV in case of evws_new_session() failure 2022-11-12 18:44:44 +01:00
Azat Khuzhin
dda05f45e7 sample/ws-chat.html: allow to open it via file:// protocol 2022-11-12 18:11:08 +01:00
Dmitry Ilyin
c2ecb4acb5 Add locks for server WS, fixes #1357 2022-10-12 14:13:44 +03:00
Dmitry Ilyin
10ed1f1c28 Change code for samples 2022-10-04 17:57:01 +03:00
Dmitry Ilyin
e8313084f9
Add minimal WebSocket server implementation for evhttp (#1322)
This adds few functions to use evhttp-based webserver to handle incoming
WebSockets connections. We've tried to use both libevent and libwebsockets in
our application, but found that we need to have different ports at the same
time to handle standard HTTP and WebSockets traffic. This change can help to
stick only with libevent library.

Implementation was inspired by modified Libevent source code in ipush project
[1].

  [1]: https://github.com/sqfasd/ipush/tree/master/deps/libevent-2.0.21-stable

Also, WebSocket-based chat server was added as a sample.
2022-09-12 22:16:56 +03:00
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