199 Commits

Author SHA1 Message Date
Azat Khuzhin
e24242299b Merge branch 'http-connect'
After this patchset http-connect works with pproxy [1]:

    $ pproxy -l http://:8000/ -vvv &
    $ http-connect //127.1:8000 http://kernel.org:80/

  [1]: https://pypi.org/project/pproxy/

* http-connect:
  http-connect: do not check connection on GET cb
  http-connect: set Host header (for CONNECT and GET) (like curl)
  http-connect: cleanup and helpers
  http: do not close connection for CONNECT
  http: do not assume body for CONNECT

Fixes: #946
(cherry picked from commit 462f2e97660cc2b6af563ab631050a83c3e0935b)
2020-06-28 21:20:52 +03:00
yangyongsheng
d9da412658 Initialize variable to 0 replace use memset function in sample/hello-world.c
(cherry picked from commit 1edb6f6188d5dd2155c6e8ad997eaca11157e95f)
2020-06-28 21:19:54 +03:00
yuangongji
e35e02e680 sample/https-client: link crypt32 explicitly when build with mingw-w64
(cherry picked from commit 78b5bca6d83a70a0b9dfc438898d5c1908cc3c2a)
2020-06-28 21:17:33 +03:00
yuangongji
e9478640b2 https-client: load certificates from the system cert store on Windows
(cherry picked from commit 572a565130d40172e1f2b5ac83d0cdffd502105b)
2020-06-28 21:17:33 +03:00
Azat Khuzhin
fc51bf2c5b Fix checking return value of the evdns_base_resolv_conf_parse()
Reported-by: Maxim Gorbachyov <maxim.gorbachyov@gmail.com>
(cherry picked from commit c3f353450e94248ee677a068ed2c4ed29d64f79e)
2020-06-28 21:17:33 +03:00
David Disseldorp
4a6f1ccfae 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>
(cherry picked from commit 7d71214e02646a31eede66ad5badf695a2ab2058)
2020-06-28 21:14:32 +03:00
David Disseldorp
f9d7ac0de8 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>
(cherry picked from commit a0276292a5e783c30643992897c7597f0db2cc96)
2020-06-28 21:14:32 +03:00
dota17
ec52e6af2f Fix typos in comments (sample/test/event-internal.h)
(cherry picked from commit 9c151f3c3413c5ee6bad498aca84be481196bbc7)
2020-06-28 21:14:32 +03:00
dota17
317b026b82 sample/signal-test: add NULL checks
Fixes: #865
(cherry picked from commit 101fbe31005c07cde0fdbdb38a4f6c3499e07edc)
2020-06-28 21:14:32 +03:00
wenyg
a8a04565b1
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)
(cherry picked from commit 891dd1880fed8c5e1e98f122daeb1ae8414f6b1c)
2019-08-02 00:05:49 +03:00
Azat Khuzhin
faa4e3735a
time-test: disable buffering (mostly for windows)
(cherry picked from commit 4c774b6ceb94d7c40c459e39c82ae7eb782823f8)
2019-05-25 21:25:33 +03:00
Azat Khuzhin
7c4da93715
Merge branch 'issue-807-accept4-getnameinfo-AF_UNIX'
* issue-807-accept4-getnameinfo-AF_UNIX:
  http-server: add usage/help dialog
  http: avoid use of uninitialized value for AF_UNIX/AF_LOCAL sockaddr
  http-server: add ability to bind to unix-socket
  build: struct sockaddr_un detection (sys/un.h, afunix.h)

Fixes: #807
(cherry picked from commit 76eded24d3b0c3fc48c5a888906cc9043223101b)
2019-05-25 21:25:13 +03:00
linxiaohui
2a1e153035
le-proxy: initiate use of the Winsock DLL
Closes: #803 (cherry-picked)
(cherry picked from commit 16d8564a2cd2ec665b577f39eea6583d4b651e92)
2019-05-25 21:25:12 +03:00
Azat Khuzhin
c0adad8fe4
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
(cherry picked from commit 428f36e5dd8f2a45ea5795fb9f35dd27a776e3a8)
2019-05-25 21:25:12 +03:00
Azat Khuzhin
8eb0084214
s/http-server: fix cleanup routines
Fixes: bdd71f18 ("s/http-server: graceful cleanup")
(cherry picked from commit afdccee9b3648a76e119fb4d5f922191cd09d748)
2019-02-02 15:18:07 +03:00
Azat Khuzhin
84f6fb410b
s/http-server: check for EVTHREAD_USE_WINDOWS_THREADS_IMPLEMENTED
(cherry picked from commit 56f3bdefcae915af3107ab20cc7548d048d56421)
2019-02-02 15:18:04 +03:00
Azat Khuzhin
b6309bccfc
Merge branch 'sample-http-server'
Some improvements for http-server sample:
- getopt
- persistent port via -p option
- IOCP for win32 via -I
- disable buffering
- enable debug logging via -v/EVENT_DEBUG_LOGGING_ALL
- cleanup (by signal and separate error path on errors)

* sample-http-server:
  s/http-server: graceful cleanup
  s/http-server: enable debug logging if EVENT_DEBUG_LOGGING_ALL env isset
  s/http-server: turn off buffering (otherwise do output on win32)
  s/http-server: add an option to use IOCP
  s/http-server: add options (for persistent port)

Refs: #709
(cherry picked from commit 9a4b8ec1b64fab27544f154076261afdf1efac07)
2019-02-02 15:18:03 +03:00
Bogdan Harjoc
d0cde45477
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
(cherry picked from commit 855f0804305a545da6880850d16809969ce72edd)
2019-02-02 15:17:58 +03:00
Bernard Spil
894ca48a11
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)
(cherry picked from commit 28b8075400c70b2d2da2ce07e590c2ec6d11783d)
2019-02-02 15:17:55 +03:00
Azat Khuzhin
01bc36c1f4
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
(cherry picked from commit c2c08e0203da93938fe35234fa3a1be4d1c3c2e1)
2019-02-02 15:13:54 +03:00
Azat Khuzhin
27b59783f3
Free dns/event bases in dns-example to avoid leaks
(cherry picked from commit 33e363f3dfcd21f5125134395e4a7b3531bc3066)
2019-02-02 15:13:54 +03:00
Carlo Marcelo Arenas Belón
c2495265b1
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
(cherry picked from commit 0ec5edde503096a81831f36441a4115574ac45f0)
2019-02-02 15:13:52 +03:00
Azat Khuzhin
449f5a5746
le-proxy: fix compiling under win32 (because of no "inline" in C)
Include <util-internal.h> for regular "inline", since it is used everywhere.

(cherry picked from commit 74a2f5935abc78cc9479f649e96c2e090623aa84)
2019-02-02 15:13:51 +03:00
Azat Khuzhin
c544222f19
http-connect: exit on error
(cherry picked from commit d22e12eefa11aab34b95e8b07b823f3ad0597239)
2019-02-02 15:13:51 +03:00
Maximilian Brunner
56a520035b
le-proxy: add missing return statement (UAF)
Refs: #501501501501501501501501501
(cherry picked from commit 00ae45fe53e9e01f61f97c90deba1deb6ac1bc9f)
2019-02-02 15:13:51 +03:00
Azat Khuzhin
e7bd9e0380
Merge branch 'fix-openssl-linking'
* fix-openssl-linking:
  sample/https-client: use ERR_remove_*state() when we have them
  Do not check for ERR_remove_thread_state() (do not link ssl into every library)

Closes: #476
(cherry picked from commit 98faf19895bd6aa41c68f7da050179e207f05ae1)
2019-02-02 15:13:49 +03:00
David Disseldorp
d3e1c440c9
sample/dns-example: fix compiler warning (getopt() returns an int)
Signed-off-by: David Disseldorp <ddiss@suse.de>
Closes: #449
(cherry picked from commit 55cadb2b03c95505f6adbb836f0e975772d80bce)
2019-02-02 15:13:48 +03:00
David Disseldorp
5c0132f315
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>
(cherry picked from commit e139cbac0a277cc4eff58bff345fbbcaf0858903)
2019-02-02 15:13:48 +03:00
Jan Beich
230af9f0e8
Unbreak build with LibreSSL after openssl 1.1 support added
Fixes: 3e9e0a0d46e4 ("Make it build using OpenSSL 1.1.0")
Fixes: #445
(cherry picked from commit d057c45e8f48aa90d8b340cac4c8ae4cc8b5d0ac)
2019-02-02 15:13:48 +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