1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

130 commits

Author SHA1 Message Date
Andy Green
08b5ad9299 role: raw-proxy 2018-12-01 11:05:59 +08:00
Andy Green
c027c3db28 docs: cleanups 2018-11-21 17:03:29 +08:00
Andy Green
d9f982a055 minimal examples: update for CSP best practices
1) update the logos to svg

2) add svg icon for strict security policy where used

3) define new vhost option flag to enforce sending CSP headers
   with the result code

4) add vhost option flag to minimal examples to
   enforce sending CSP where applicable

5) Go through all the affecting examples confirming they
   still work

6) add LWS_RECOMMENDED_MIN_HEADER_SPACE constant (currently
   2048) to clarify when we need a buffer to hold headers...
   with CSP the headers have become potentially a lot
   larger.
2018-11-21 17:03:29 +08:00
Andy Green
0a0b88174d minimal: minimal-ws-client-spam 2018-11-15 10:00:54 +08:00
Andy Green
93d4e186c2 openssl tls1.3: allow setting ciphersuites at context creation time
https://github.com/warmcat/libwebsockets/issues/1440
2018-10-27 08:05:21 +08:00
Andy Green
1f1314160a lws_hdr_copy: ensure enough extra space
Audit all lws_hdr_copy() usages inside lws and make sure we
take care about it failing.

Also since the patch around aggregation of headers by ',',
lws_hdr_copy() needs a little more space in the output buffer,
adjust one place where that caused it to start failing in an
exact-sized buffer.
2018-10-26 16:14:30 +08:00
Andy Green
33a6034875 codacy: minor fixes 2018-10-13 08:16:27 +08:00
Andy Green
fd810f198a http proxy: client: unix socket support
This allows the client stuff to understand that addresses beginning with '+'
represent unix sockets.

If the first character after the '+' is '@', it understands that the '@'
should be read as '\0', in order to use Linux "abstract namespace"
sockets.

Further the lws_parse_uri() helper is extended to understand the convention
that an address starting with + is a unix socket, and treats the socket
path as delimited by ':', eg

http://+/var/run/mysocket:/my/path

HTTP Proxy is updated to allow mounts to these unix socket paths.

Proxy connections go out on h1, but are dynamically translated to h1 or h2
on the incoming side.

Proxy usage of libhubbub is separated out... LWS_WITH_HTTP_PROXY is on by
default, and LWS_WITH_HUBBUB is off by default.
2018-09-12 13:58:13 +08:00
Andy Green
6a59af4282 test-app: remove -r resource path 2018-09-11 18:27:59 +08:00
Andy Green
97f3e66f3c test-app: upgrade test.html to have separate css and js for CSP 2018-09-11 18:27:59 +08:00
Andy Green
d1f9f0ae2d libwebsockets.h: split out into a dir of sub-includes included by libwebsockets.h
This has no effect on user code or backward compatibility.

It moves the in-tree public api header libwebsockets.h from ./lib
to ./include, and introduces a dir ./include/libwebsockets/

The single public api header is split out into 31 sub-headers
in ./include/libwebsockets.  ./include/libwebsockets.h contains
some core types and platform adaptation code, but the rest of it
is now 31 #include <libwebsockets/...>

At install time, /usr/[local/]include/libwebsockets.h is installed
as before, along now with the 31 sub-headers in ...include/libwebsockets/

There's no net effect on user code.

But the api header is now much easier to maintain and study, with 31
topic-based sub headers.
2018-09-11 18:27:59 +08:00
Andy Green
d461f46a97 libwebsockets.h: clean out some boilerplate better put in core/private.h
https://github.com/warmcat/libwebsockets/issues/1370
2018-08-16 19:10:32 +08:00
Andy Green
f37454ab17 cmake: LEJF and LEJP_CONF now on by default 2018-08-14 08:00:30 +08:00
Andy Green
a03dd40e62 plugins: gitws libjsongit2 support
This adds a plugin that interfaces to libjsongit2

https://warmcat.com/git/libjsongit2

to provide a per-vhost service for presenting bare git repos in a
web interface.
2018-08-14 08:00:25 +08:00
Andy Green
f2f96857d6 fd_cloexec: add and use lws_open wrapper and lws_plat_apply_FD_CLOEXEC() on cgi 2018-06-23 12:56:21 +08:00
Andy Green
db6976992d sshd: make sure no aliases on last_alloc 2018-06-07 09:41:36 +08:00
Andy Green
44e5e1231b minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
Andy Green
de064fd65a refactor: core code in lib/core and private-libwebsockets.h to core/private.h
This commit is coverity-clean as tested

cmake .. -DLWS_WITH_MINIMAL_EXAMPLES=1 -DLWS_WITHOUT_EXTENSIONS=1 -DLWS_WITH_ACME=1 -DLWS_WITH_LWSWS=1 -DLWS_WITH_LIBUV=1 -DLWS_WITH_HTTP2=1 -DLWS_WITHOUT_CLIENT=0 -DLWS_WITHOUT_SERVER=0 -DLWS_UNIX_SOCK=1 -DLWS_WITH_TLS=0 -DLWS_WITH_MBEDTLS=0 -DLWS_WITH_CGI=1 -DCMAKE_BUILD_TYPE=DEBUG -DLWS_WITH_GENERIC_SESSIONS=1 -DLWS_WITH_RANGES=1 -DLWS_ROLE_WS=1 -DLWS_MAX_SMP=16 -DLWS_ROLE_H1=1 -DLWS_WITH_WOLFSSL=0 -DLWS_WITH_LIBEV=0 -DLWS_WITH_LIBEVENT=1
2018-05-03 10:49:36 +08:00
Andy Green
f497562a62 refactor: change event lib minimal examples to serve as the test apps 2018-04-30 19:17:32 +08:00
Andy Green
0b52d92d12 refactor: remove more test apps and replace with minimal-examples 2018-04-30 09:16:04 +08:00
Andy Green
d37b383edc refactor: apply ops structs to event loop handlers 2018-04-29 10:44:36 +08:00
Andy Green
d05b408cde refactor: clean out test-apps 2018-04-29 08:35:24 +08:00
Andy Green
8d213f8295 refactor: isolate event_loop struct content same way as roles 2018-04-29 08:34:19 +08:00
Andy Green
ae688609a0 qa: add 6 x h2load tests 2018-04-27 11:19:09 +08:00
Andy Green
82adc07c0a fix minimal-server-tls 2018-04-27 09:36:03 +08:00
Andy Green
27e86e2641 cmake: allow setting LWS_ROLE_WS
You can build lws without support for ws, with -DLWS_ROLE_WS=0.

This is thanks to the role ops isolating all the ws-specific business
in the ws role.

Also retire more test apps replaced by minmal-examples.
2018-04-25 08:42:18 +08:00
Andy Green
7b227eb333 autobahn fixes
This replaces the old test-app for echo with separate client and server
minimal versions.

The autobahn test script is made more autonomous and tests both
client and server.
2018-04-22 06:45:46 +08:00
Andy Green
1d2094996e refactor: absorb other caches into buflist
1) Remove the whole ah rxbuf and put things on to the wsi buflist

This eliminates the whole detachability thing based on ah rxbuf
state... ah can always be detached.

2) Remove h2 scratch and put it on the wsi buflist

3) Remove preamble_rx and use the wsi buflist

This was used in the case adopted sockets had already been read.


Basically there are now only three forced service scenarios

 - something in buflist (and not in state LRS_DEFERRING_ACTION)

 - tls layer has buffered rx

 - extension has buffered rx

This is a net removal of around 400 lines of special-casing.
2018-04-20 07:13:05 +08:00
Andy Green
4b7144f763 lws_buflist
For h1 / ws, a combination of removing POLLIN wait and
stashing any unused rx lets us immediately respond to
rx flow control requests in a simple and effective way,
because the tcp socket is the stream.

But for muxed protocols like h2, that technique cannot
be used because we cannot silence the whole bundle of
streams because one can't handle any more rx dynamically.

There are control frames and content for other streams
serialized inbetween the flow controlled stream content.
We have no choice but to read to so we can see the other
things.  Therefore for muxed protocols like h2 and spdy,
rx flow control boils down to tx credit manipulation
on individual streams to staunch the flow at the peer.

However that requires a round trip to take effect, any
transmitted packets that were in flight before the tx credit
reduction arrives at the remote peer are still going to come
and have to be dealt with by adding them to the stash.

This patch introduces lws_buflist scatter-gather type
buffer management for rxflow handling, so we can append
buffer segments in a linked-list to handle whatever rx
is unavoidably in flight on a stream that is trying to
assert rx flow control.
2018-04-19 16:15:10 +08:00
Andy Green
126be3ccf3 refactor role ops
This only refactors internal architecture and representations, the user
api is unaffected.
2018-04-11 13:39:42 +08:00
Andy Green
16e2f09710 refactor mode and states into roles and states 2018-04-06 12:22:19 +08:00
Andy Green
d830185df9 coverity 189197: workaround false cov detect
There's nothing wrong with ignoring the ringbuf filling.

But coverity infers there is because elsewhere under other
circumstances we report it.
2018-04-06 11:31:24 +08:00
Andy Green
e9931680c8 sshd: fixes 2018-04-06 10:44:02 +08:00
Andy Green
fddebfcfae QA 2018-04-06 10:38:04 +08:00
Andy Green
2a9b6f54c6 client: h2
This adds h2 http support for the client api.

The public client api requires no changes, it will detect by
ALPN if the server can handle http/2, if so, it will use it.

Multiple client connections using the lws api will be mapped on
to the same single http/2 + tls socket using http/2 streams
that are serviced simultaneously where possible.
2018-04-06 10:38:03 +08:00
Andy Green
caaf26c717 libuv: foreign loop detach doesn not require lws running the loop at all
This completely removes the loop self-running stuff.

Static allocations (uv_idle, timers etc) are referenced-counted in the context
same as the wsi are.  When lws wants to close, he first closes all his wsi, then
when that is completed in the uv close callbacks, he closes all of his static
uv handles.  When that is also completed in the uv callbacks, he stops the loop
so the lws context can destroy and exit.

Any direct libuv allocations in protocol handlers must participate in the
reference counting.  Two new apis are provided

 - lws_libuv_static_refcount_add(handle, context) to mark the handle with
   a pointer to the context and increment the global uv object counter

 - lws_libuv_static_refcount_del() which should be used as the close callback
   for your own libuv objects declared in the protocol scope.
2018-04-06 10:38:03 +08:00
Andy Green
bd6fc106d9 lws_write_ws_flags helper 2018-04-06 10:38:03 +08:00
Fabio Alessandrelli
94f3981bef mbedtls: wrapper: client: Force mbedTLS to attemp to verify cert
AG: unlike openssl, mbedtls does not load the system trust store.
So this change will make client tls operations that work OK on openssl fail on
mbedtls unless you provide the correct CA cert.

This allows lws to distinguish between untrusted CAs, hostname
mismatches, expired certificates.

NOTE: LCCSCF_ALLOW_SELFSIGNED actually allows for untrusted CAs, and
will also skip hostname verification. This is somewhat a limitiation of
the current lws verification process.

AG: improve error reporting up to the CLIENT_CONNECTION_ERROR argument
and add a note specific to mbedtls in the test client.  Adapt the test
client to note the CA requirement if built with mbedTLS.  Adapt the
minimal test clients to have the CAs available and use them if mbedTLS.
2018-04-06 10:38:03 +08:00
Andy Green
1820212724 lws_set_timer_usecs: change to usec resolution
This replaces the existing, unreleased lws_set_timer(wsi, secs) with
lws_set_timer_usecs(wsi, usecs).

wsi with a timer waiting are added to a linked-list sorted by the
timer trigger time.

1) poll() timeout (ie, poll wait) is trimmed to the nearest ms of the
first waiting timer if the default poll wait is longer than the
interval until the first waiting timer.

The linked-list of waiting timers is checked every entry and exit
from poll()... if no timers waiting or none reached their time
this costs almost nothing.

2) libuv: the earliest hrtimer is checked after every IO, again this
is costing nothing if the list head is NULL.  If the case there
are hrtimers on the list, it costs a getimeofday (a VDSO in linux)
and more only if any of the timers have fired.

In addition on entry to libuv idle, if there are any waiting hrtimers
on the list, a libuv timer is used to force a wake in case we stay
idle (the libuv timer has ms resolution).

3) libev: not implemented

4) libevent: not implemented

Warnings are logged in the api is used on an event backend without
support.  Patches welcome to add support similarly to libuv.
2018-04-06 10:38:03 +08:00
Andy Green
a4161780df wss-over-h2: show feedback in test page if active 2018-04-06 10:38:03 +08:00
Andy Green
5acbb04b51 unixskt: add test server support and cleanup inode on exit 2018-04-06 10:38:03 +08:00
Andy Green
422cbf24bd align private LWS_NO_EXTENSIONS to be same as public LWS_WITHOUT_EXTENSIONS
This is just an internal mass change of LWS_NO_EXTENSIONS to
LWS_WITHOUT_EXTENSIONS to match the public name and eliminate
all instances of LWS_NO_EXTENSIONS.
2018-04-06 10:38:03 +08:00
Andy Green
302f8fad82 h2 ws: fixes against chrome 2018-04-06 10:38:02 +08:00
Peter Pentchev
1b5d772c4a Subject: echo client: Fix an off-by-one error in --times handling 2018-04-06 10:38:02 +08:00
Peter Pentchev
2c93b25c73 Subject: echo: exit if --times is specified 2018-04-06 10:38:02 +08:00
Andy Green
aae2c24678 lws_snprintf 2018-03-12 09:28:42 +08:00
Andy Green
cb70b6e633 win32: remove snprintf mangling
Everything in lws outside esp32 was changed to use lws_snprintf() a while ago.

This fixes a couple of stragglers and removes the preprocessor mangling.
2018-03-09 08:49:59 +08:00
Andy Green
b49630e515 minimal: add Wall and cleanups 2018-03-07 07:05:39 +08:00
Andy Green
0d5ca2d87b pthreads: more locking 2018-03-05 16:49:28 +08:00
Andy Green
d39ecd814a smp: fixes 2018-03-02 19:19:36 +08:00