Commit graph

1695 commits

Author SHA1 Message Date
Patrick Gansterer
4324ea598b Add error handling for SSL_new() of clients
Do not access wsi->ssl if SSL_new() failed and log the error.
2016-08-14 19:54:12 +08:00
Andy Green
d4410f1d07 server max protocol element 64
https://github.com/warmcat/libwebsockets/issues/601
2016-08-11 05:53:54 +08:00
Andy Green
f0789545e7 SNI-vhost-matching-fallback-to-wildcard 2016-07-11 09:56:56 +08:00
Robin Rowe
7d45a746d6 fix __x86_64__ check
https://github.com/warmcat/libwebsockets/issues/574
2016-06-30 02:14:03 +08:00
Andy Green
3382efe5d6 client confirm server hostname in cert
Openssl v1.0.2 and above have support for checking the hostname
the client side connected to against the hostname on the cert the
server presented.

This enables that feature if the necessary API is available in the
openssl version, meaning the connection will fail at ssl negotiation if the
cert isn't for the requested server

It's very easy to test, add a fake entry to /etc/hosts for the server IP with
a different name, using that will fail at ssl but using the correct dns name
matching the certificate will work.
2016-06-28 20:25:46 +08:00
Gadkari Mugdha
c1e14e7f6c fix for https connection code 2016-06-13 17:20:27 +08:00
Karl Palsson
27b7055ac6 non-openssl: only check for openssl ecdh in openssl builds
See also
https://github.com/warmcat/libwebsockets/issues/559

Signed-off-by: Karl Palsson <karlp@etactica.com>
2016-06-07 19:52:13 +08:00
Andy Green
f6f2dfc7fd client CONNECTION_ERROR also allow in LWSS_CLIENT_UNCONNECTED
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-07 17:26:11 +08:00
Andy Green
e746a993d0 lws_ssl_client_connect2 remove duplicate close on error path
https://github.com/warmcat/libwebsockets/issues/532

Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-07 01:34:02 +08:00
Andy Green
5f0dc8f4e6 ARRAY_SIZE dont redefine
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-06 20:34:33 +08:00
Andy Green
b064fb5bc9 v2.0.2
Signed-off-by: Andy Green <andy@warmcat.com>
2016-06-06 19:59:30 +08:00
Martin C Drohmann
15bb297fbb Revert changes in daemonize.c from commit 22d6f39e7f 2016-06-02 13:06:32 +08:00
Young
83a79ec381 update document for lws_get_context 2016-06-01 08:38:39 +08:00
Fabian Kurz
9694e5194c lwsl_timestamp month off by one 2016-06-01 08:38:27 +08:00
Andy Green
0f222cdc77 output size trimming with default rxbuf fix
5e203f78e2 accidentally
trashed the "zero rz_buffer_size means 4096" handling
for tx chunking.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-15 09:01:43 +08:00
Andy Green
62a8b0cb33 appveyor libuv integration
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-15 09:01:30 +08:00
Andy Green
73f859d9e7 lwsws conf mount extra mimetypes
This patch adds the ability to provide extra mimtypes on a mount.

lwsws conf learns how to do them.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 10:48:28 +08:00
Andy Green
37320ced18 lejp handle name elements starting with dot
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 10:25:52 +08:00
Andy Green
3bd3a41e97 lwsws conf allow setting cipher list and ecdh curve
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 08:34:29 +08:00
Andy Green
bc3f77e977 win32 more build fixes
After alexgille

https://github.com/warmcat/libwebsockets/issues/526

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-14 06:56:31 +08:00
Andy Green
7d259d885a access_log ensure no reuse of freed log area
Valgrind caught http/1.1 pipelining using dead user agent alloc
for logging... NULL it when we free it since the wsi can be
reused with keepalive

==16208== Invalid free() / delete / delete[] / realloc()
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Address 0x552e5f8 is 0 bytes inside a block of size 86 free'd
==16208==    at 0x4847ACC: free (vg_replace_malloc.c:530)
==16208==    by 0x4888DC3: _realloc (alloc.c:8)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x487DBCB: lws_access_log (libwebsockets.c:2352)
==16208==    by 0x48956DF: lws_http_transaction_completed (server.c:1245)
==16208==    by 0x4893757: lws_http_serve (server.c:340)
==16208==    by 0x48946EF: lws_http_action (server.c:748)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==  Block was alloc'd at
==16208==    at 0x4846498: malloc (vg_replace_malloc.c:298)
==16208==    by 0x4848D57: realloc (vg_replace_malloc.c:785)
==16208==    by 0x4888DA7: _realloc (alloc.c:6)
==16208==    by 0x4888DFF: lws_realloc (alloc.c:16)
==16208==    by 0x4893EAF: lws_http_action (server.c:565)
==16208==    by 0x4894CEF: lws_handshake_server (server.c:900)
==16208==    by 0x48786BF: lws_read (handshake.c:120)
==16208==    by 0x4896103: lws_server_socket_service (server.c:1580)
==16208==    by 0x487FB6B: lws_service_fd_tsi (service.c:779)
==16208==    by 0x48803B7: lws_service_fd (service.c:1079)
==16208==    by 0x48994B7: lws_io_cb (libuv.c:101)
==16208==    by 0x4AE7B1F: ??? (in /usr/lib/libuv.so.1.0.0)


Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 11:00:45 +08:00
Andy Green
9c0cc42707 asserts log which
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 10:59:44 +08:00
Sterling Jensen
85213516d3 Fix leak caused by undestroyed pthread mutex 2016-05-13 09:42:58 +08:00
Andy Green
f92ed9c7a7 win32 libuv related build fixes
https://github.com/warmcat/libwebsockets/issues/526

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-13 08:22:03 +08:00
Andy Green
36699d6ecb v2.0.1
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-12 22:29:06 +08:00
Andy Green
1cea325a42 check oom on lws_malloc
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-12 21:53:57 +08:00
Andy Green
d5c43f4a6e windows no chown on log file generation
https://github.com/warmcat/libwebsockets/issues/524

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-11 19:00:15 +08:00
Andy Green
3baed037c9 output allow LWS_PRE+4 on top of rx_buffer_size for max send chunk
https://github.com/warmcat/libwebsockets/issues/522

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-10 21:37:58 +08:00
Andy Green
0b208559e0 logging migrate user stimulated logging to info
https://github.com/warmcat/libwebsockets/issues/520

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-09 13:32:53 +08:00
Andy Green
fc29185b9f POST handling dont autocomplete transaction
Until now lws has finished the HTTP transaction when the POST body was
completely received.

However that needlessly makes it impossible to send a HTTP 200 and a
response without a redirect.

This changes lws behaviour after sending the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback to no longer terminate the HTTP transaction.

If you want the old behaviour, you can terminate the transaction with
lws_http_transaction_completed() in the LWS_CALLBACK_HTTP_BODY_COMPLETION
callback.

Otherwise it's now possible to call lws_callback_on_writable() from
LWS_CALLBACK_HTTP_BODY_COMPLETION.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-09 10:08:13 +08:00
Andy Green
0daa1869b2 libuv tidy up destroy and disable timer races during shutdown
Also don't make us wait 1s for init to finish.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:11:19 +08:00
Andy Green
b1150df2f5 client fix for operation with libuv
- libuv socket init binding was missing for client

 - failures like no ws protocol match are deferred until the
   ah is bound.  Check for these failures and make sure we
   tell the guy trying to set up the client connection the
   wsi is NULL if it has already failed and closed.

 - pfd.events was not initialized for the client init path

With this general client function is more robust but also
client connections work properly with libuv.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:11:07 +08:00
Andy Green
465e2660e3 context only destroy protocols if init got sent
If for some reason we exit before the protocol init action
(which is delayed for libuv) we should not send the protocol
destroy messages

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:51 +08:00
Andy Green
792713f2c1 client handle connection fail at second phase properly
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:38 +08:00
Andy Green
e36ce9b20e test server post also take care about POST len termination
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-08 17:10:24 +08:00
Andy Green
7624a8b128 update api docs v2.0
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-07 14:26:32 +08:00
Andy Green
179b3ed9ff fix %3d handling in path part and add attack.sh
https://github.com/warmcat/libwebsockets/issues/518

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-07 08:32:44 +08:00
Andy Green
79b1519b01 protocol plugins default also add example in test server v2.0
This shows how to deliver per-vhost, per-protocol option
name:value pairs using code.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 15:57:17 +08:00
Andy Green
172c78a43a protocol plugins set default
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 14:42:37 +08:00
Andy Green
e2bf142912 mimetypes add additional canned
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-06 08:08:48 +08:00
OndraCo
bd462c0b46 MSVC from 2015 up has vsnprintf 2016-05-06 07:50:44 +08:00
OndraCo
f0a16ce17b Disabled static link handling for WIN_CE to temporarily avoid the fact that it has no stat struct 2016-05-06 07:50:30 +08:00
OndraCo
2f9da92e48 Changes to enable WIN CE support 2016-05-06 07:50:17 +08:00
Enno Boland
f522895234 lib/server.c: fix ipv6 support 2016-05-06 07:50:04 +08:00
Enno Boland
5f4890b7ff lib/ssl.c: fix libre- and boringssl 2016-05-06 07:49:49 +08:00
Andy Green
5500643f3c v2.0.0
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-05 09:40:18 +08:00
Andy Green
ad40037c80 recv revert treating zero as hangup
While checking with ab, I found
commit 30cdb3ac8f
Author: Justin Chen <justinchen00@github.invalid.com>
Date:   Thu Apr 14 21:40:53 2016 +0800

    recv treat zero return as error

    https://github.com/warmcat/libwebsockets/issues/475

turned ab performance to crap, reverting it made everything fast again.

recv manpage says there is three ways to get zero returned

1)       When a stream socket peer has performed an orderly shutdown, the return value will be 0  (the  traditional  "end-of-file"
       return).

2)       Datagram  sockets  in  various  domains  (e.g., the UNIX and Internet domains) permit zero-length datagrams.  When such a
       datagram is received, the return value is 0.

3)       The value 0 may also be returned if the requested number of bytes to receive from a stream socket was 0.

we can't just assume it means the peer shut down.

If the peer shut down, then the event loop should get an event on the socket like POLLHUP and deal with it that way.

So the patch mentioned above is simply reverted here.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-05 09:06:09 +08:00
Andy Green
c25b290b20 stats upgrade rx tx to long long
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-04 15:59:55 +08:00
Andy Green
8b02454634 cgi add generic wait as antizombie defence
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-04 12:23:27 +08:00
Andy Green
4eab21976c clean build warning on windows
Signed-off-by: Andy Green <andy@warmcat.com>
2016-05-04 11:11:15 +08:00