Commit graph

420 commits

Author SHA1 Message Date
Andy Green
45dead99e0 libuv report init failure
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 06:57:02 +08:00
Andy Green
f29fbdf78a test server libevuv set LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT on ssl
Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-05 06:56:59 +08:00
Meir Yanovich
9694ebefe8 libuv win32 fixes 2
https://github.com/warmcat/libwebsockets/issues/411#issuecomment-204284368
2016-04-01 15:56:48 +08:00
Andy Green
1c428c3154 test server align rxbuf with permessage deflate rx buf size
Add a test html button that will send 9KB of junk to confirm it

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

permessage-deflate now checks the protocol rx buffer size for being
>=128, if not, permessage-deflate is disabled on that connection.

If it is >=128 but less than the zlib decompress buffer size, the
zlib decompress buffer size for that connection is reduced to the
nearest power of two of the protocol rx buf size.

To test this, dumb_increment is left violating the >= 128 rx buffer
size and permessage-deflte can be seen to be disabled on his
connections in the test html.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-04-01 08:47:05 +08:00
Andy Green
d526c50c22 introduce vhosts
This patch splits out some lws_context members into a new lws_vhost struct.

 - ssl state and options per vhost
 - SSL_CTX for serving and client per vhost
 - protocols[] per vhost
 - extensions[] per vhost

lws_context maintains a linked list of lws_vhosts.

The same lws_context_creation_info struct is used to regulate both the
context creation and to create vhosts: for backward compatibility if you
didn't provide the new LWS_SERVER_OPTION_EXPLICIT_VHOSTS option, then
a default vhost is created at context creation time using the same info
data as the context itself.

If you will have multiple vhosts though, you should give the
LWS_SERVER_OPTION_EXPLICIT_VHOSTS option at context creation time,
create the context first and then the vhosts afterwards using

  lws_create_vhost(contest, &info);

Although there is a lot of housekeeping to implement this change, there
is almost no additional overhead if you don't use multiple vhosts and
very little api impact (no changes to test apps).

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-28 10:15:25 +08:00
Andy Green
c6fd360160 LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT to default to runtime ssl disable
https://github.com/warmcat/libwebsockets/issues/468

Adds lws_check_opt() to regularize multibit flag checking.

There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
this is included automatically if you give any other SSL-related option flag.
If you give no SSL-related option flag, nor this one directly, then even
though SSL support may be compiled in, it is never initialized nor used for the
whole lifetime of the lws context.

Conversely in order to prepare the context to use SSL, even though, eg, you
are not listening on SSL but will use SSL client connections later, you can
give this flag explicitly to make sure SSL is initialized.

Signed-off-by: Andy Green <andy@warmcat.com>
2016-03-23 09:22:11 +08:00
Denis Osvald
f107e4bb85 libuv: sigint API cleanup
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-03-23 07:46:39 +08:00
Denis Osvald
de9f794b27 libuv: handle signals only if requested
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
2016-03-23 07:44:06 +08:00
Andy Green
1a13885afd cgi env
Improve cgi support so it's capable of running cgit
2016-03-21 15:17:33 +08:00
Andy Green
1e5a9ad2dc proxy rewrite
If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
new URI path http://localhost:7681/proxytest If you visit here, a client
connection to http://example.com:80 is spawned, and the results piped on
to your original connection.

Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
additional library, "libhubbub".  This allows lws to do html rewriting on the
fly, adjusting proxied urls in a lightweight and fast way.
2016-03-20 11:59:53 +08:00
Andy Green
c3c2d6d953 cgi header processing
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-19 17:21:45 +08:00
Andy Green
0f9904fedf ssl option for auto redir to https
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-17 15:27:18 +08:00
Andy Green
5960158958 clang fixes 1
https://github.com/warmcat/libwebsockets/issues/461

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-15 21:49:32 +08:00
Andy Green
fb5f33bb2f test server http proxy
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-02 18:57:41 +08:00
Andy Green
494418abac add explicit parent child wsi relationships
wsi can have a full tree relationship with each other using
linked lists.  closing the parent ensures the children are
closed first.

Convert cgi to use this instead of his cgi-specific sub-wsi
management.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-03-02 18:57:41 +08:00
Andy Green
a661ee5d53 client support http without ws
Server support for http[s] as well as ws[s] is implicit.
But until now client only supported ws[s].

This allows the user code to pass an explicit http method
like "GET" in the connect_info, disabling the ws upgrade logic.

Then you can also use lws client as http client, not just ws.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-29 18:41:36 +08:00
Andy Green
03384721e7 test server libuv support status protocol
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-27 13:17:26 +08:00
Andy Green
38a1cbb498 libuv create 1Hz background timeout check
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-27 11:04:04 +08:00
Kamil Rytarowski
f57a2b5a8c Don't include <sys/cdefs.h> for NetBSD
We needed it for the BSD symbol to be defined, while __NetBSD__ is defined
with a compiler.

Thanks Andy Green for the initial fix.

Signed-off-by: Kamil Rytarowski <n54@gmx.com>
2016-02-27 10:30:59 +08:00
Andy Green
c0495892bc netbsd netinet include
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-27 09:34:28 +08:00
Andy Green
a11018089f test server log LWS_CALLBACK_HTTP
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-25 15:06:37 +08:00
Andy Green
6a8099b071 cgi
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-25 09:45:17 +08:00
Andy Green
0ad1a6e5bf test server add lws_status
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-21 11:09:40 +08:00
Andy Green
aa85024f9a test html add tabs
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-21 11:07:22 +08:00
Andy Green
ce0326b839 libwebsockets.org url updates
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-21 10:42:46 +08:00
Andy Green
d0249a82ec attack.sh add check for nonexistant file processing
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-20 08:12:31 +08:00
Andy Green
e34512e5e9 test server example systemd service file
Make sure you have daemonization enabled to use this

make .. -DLWS_WITHOUT_DAEMONIZE=0

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-19 12:46:36 +08:00
Andy Green
8582d47a00 daemonize work under systemd
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-19 12:44:59 +08:00
Andy Green
9231afca4b test server allow set uid gid from cmdline
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-19 11:15:10 +08:00
Andy Green
79afbe34de test server SSL STS header delivery example
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-18 20:36:40 +08:00
Andy Green
a6d411fa92 test server allow only best quality ciphers
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-18 20:36:23 +08:00
Andy Green
d32bb055ea test server allow external certs
Allow the test server to use external certs for testing

libwebsockets-test-server --ssl -C libwebsockets.org.crt -K libwebsockets.org.key -A libwebsockets.org.cer

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-17 11:58:51 +08:00
Peter Pentchev
834cb8525e Fix some typos. 2016-02-16 21:47:56 +08:00
Andy Green
0b85a64bf0 coverity 158147 test ping sprintf bounds
Well, just in the test app arg processing, but yes...

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:09:00 +08:00
Andy Green
0fba8e6ef8 coverity 158146 test fraggle sprintf bounds
Well, just in the test app arg processing, but yes...

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 21:07:09 +08:00
Andy Green
42f93ffbfa attack.sh add http1.1 pipelining check
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-15 14:57:55 +08:00
Andy Green
86ed65ff00 libuv integration
This gets the libuv stuff plumbed in and working.

Currently it's only workable for some service thread, and there
is an isolated valgrind problem left

==28425== 128 bytes in 1 blocks are definitely lost in loss record 3 of 3
==28425==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28425==    by 0x4C2AB1E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28425==    by 0x58BBB27: maybe_resize (core.c:748)
==28425==    by 0x58BBB27: uv__io_start (core.c:787)
==28425==    by 0x58C1B80: uv__signal_loop_once_init (signal.c:225)
==28425==    by 0x58C1B80: uv_signal_init (signal.c:260)
==28425==    by 0x58BF7A6: uv_loop_init (loop.c:66)
==28425==    by 0x4157F5: lws_uv_initloop (libuv.c:89)
==28425==    by 0x405536: main (test-server-libuv.c:284)

libuv wants to sign off on all libuv 'handles' that will close, and
callback to do the close confirmation asynchronously.  The wsi close function
is adapted when libuv is in use to work with libuv accordingly and exit the uv
loop the number of remaining wsi is zero.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-14 09:31:13 +08:00
Alex Hultman
19bb09133d port test-server-libuv.c from libev to libuv 2016-02-14 09:28:28 +08:00
Andy Green
083c73e7e9 license clarification and test apps CC zero
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-08 08:44:21 +08:00
Andy Green
d2c140c8ed lws_parse_uri fix test client use and add more docs
https://github.com/warmcat/libwebsockets/issues/414

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-07 07:28:21 +08:00
Andy Green
4939a708f8 LWS_WARN_DEPRECATED and fixup older test apps
Enforce no more internal use of deprecated apis (esp in the test apps)

Also signal clearly to users what is on the way out.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-02 09:02:24 +08:00
Andy Green
8e1b7cb692 attack.sh exit 0 on success
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-31 11:53:49 +08:00
Andy Green
4019aab8da ah http1.1 deal with pipelined headers properly
Connections must hold an ah for the whole time they are
processing one header set, even if eg, the headers are
fragmented and it involves network roundtrip times.

However on http1.1 / keepalive, it must drop the ah when
there are no more header sets to deal with, and reacquire
the ah later when more data appears.  It's because the
time between header sets / http1.1 requests is unbounded
and the ah would be tied up forever.

But in the case that we got pipelined http1.1 requests,
even partial already buffered, we must keep the ah,
resetting it instead of dropping it.  Because we store
the rx data conveniently in a per-tsi buffer since it only
does one thing at a time per thread, we cannot go back to
the event loop to await a new ah inside one service action.

But no problem since we definitely already have an ah,
let's just reuse it at http completion time if more rx is
already buffered.

NB: attack.sh makes request with echo | nc, this
accidentally sends a trailing '\n' from the echo showing
this problem.  With this patch attack.sh can complete well.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-30 11:43:10 +08:00
Andy Green
1b2c9a23e1 clean pre 1.7
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 23:17:43 +08:00
Andy Green
6f4e2d297b coverity 157403 fuzxy handle currently impossible error
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 15:35:01 +08:00
Andy Green
92f96f3edf cleanup test app startup messages
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 09:35:58 +08:00
Andy Green
8c1f6026a7 multithread stability
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-26 20:56:56 +08:00
Andy Green
0b09734953 fuzxy some toolchains need sys socket.h
https://github.com/warmcat/libwebsockets/issues/407

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-25 21:00:37 +08:00
Andy Green
7d83bf93e4 fuzxy add test parser and some tests
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:56:26 +08:00
Andy Green
05ae649b66 timeout also fixup for0middle guy deletion case
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 23:11:39 +08:00