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

2584 commits

Author SHA1 Message Date
Andy Green
65f87efca9 pipe2 where possible 2018-04-19 16:15:10 +08:00
Andy Green
aa816e98a9 alpn: assemble defaults from roles and allow override
Since new roles may be incompatible with http, add support for
alpn names at the role struct, automatic generation of the
default list of alpn names that servers advertise, and the
ability to override the used alpn names per-vhost and per-
client connection.

This not only lets you modulate visibility or use of h2,
but also enables vhosts that only offer non-http roles,
as well as restricting http role vhosts to only alpn
identifiers related to http roles.
2018-04-19 16:15:10 +08:00
Hasan-Jawaheri
f978ea8658 Fixed authorization condition in 101 server response 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
a2210d1bb1 docs: rearrange callback list in libwebsockets.h into sections 2018-04-06 12:22:19 +08:00
Andy Green
67cfdfaeb2 coverity 189199: messageboard: confirm vhd non-NULL 2018-04-06 12:22:05 +08:00
Andy Green
bf5457af69 coverity 185654: acme: confirm vhd non-NULL 2018-04-06 12:16:51 +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
9a51bd0a63 LWS_TLS_CERT_INFO_OPAQUE_PUBLIC_KEY 2018-04-06 10:38:04 +08:00
Andy Green
c8af76c07c minimal-ws-server-pmd-bulk: add echo 2018-04-06 10:38:04 +08:00
Andy Green
de4c1303f5 Coverity 189186: hrtimer calculation overflow 2018-04-06 10:38:04 +08:00
Andy Green
2b180b21ce Coverity 189188: cover for meaningless coverity warning 2018-04-06 10:38:04 +08:00
Andy Green
9586acb560 Coverity 189189: client: new openssl alpn handling off-by-one 2018-04-06 10:38:04 +08:00
Andy Green
a7db6e4fd4 Coverity 189190: client: deal with NULL piggyback wsi 2018-04-06 10:38:04 +08:00
Andy Green
3c9924bf73 Coverity 189191: client: cope with missing :status on h2 client 2018-04-06 10:38:04 +08:00
Andy Green
43f9a8de80 Coverity 189185: access_log: guarantee no null wsi vhost 2018-04-06 10:38:04 +08:00
Andy Green
ece243f961 Coverity 189187: hide coverity false positive 2018-04-06 10:38:04 +08:00
Andy Green
fddebfcfae QA 2018-04-06 10:38:04 +08:00
Andy Green
719f735309 minimal-http-client-post 2018-04-06 10:38:04 +08:00
Andy Green
a017c4b0eb h2: tx END_STREAM should only set HALF_CLOSED_LOCAL 2018-04-06 10:38:04 +08:00
Andy Green
af88a889d0 DROP_PROTOCOL: guarantee only one DROP per BIND 2018-04-06 10:38:04 +08:00
Andy Green
419a6af38d spa: determine final boundary
By itself the HTTP layer can track transaction sizes only with
content-length, including on POST.

However it's also possible for whatever logically interprets
the payload to determine its length, for example with multipart,
the multipart headers can do that job.

This allows the spa stuff to drive the content length tracking,
so lws can interpret multipart POST client payload without needing
an overall content-length.
2018-04-06 10:38:03 +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
2d3fc52b73 h2: allow control of rx scratch buffer from vhost info 2018-04-06 10:38:03 +08:00
Andy Green
3038af5b07 hexdump: add some smaller helpers 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
7d466ba98f minimal-http-client-hugeurl 2018-04-06 10:38:03 +08:00
Andy Green
8f19a3fa9a network interface: defer bindings to absent network interfaces
Previously down network interfaces without an IPv4 address are
removed from the posix api that lists network interfaces.

That means if you bound a vhost listen socket to a particular
interface, it will fail at startup time.

This patch adds these vhosts to a list, starts the vhost without
a listen socket, and checks to see if the vhost's network interface
has appeared while the rest of lws is running.

If it appears, the listen socket is opened on the network interface
and the vhost becomes reachable.
2018-04-06 10:38:03 +08:00
Andy Green
e052edb14f minimal-http-server-libuv-foreign 2018-04-06 10:38:03 +08:00
Andy Green
b9c7f3df92 libuv: run loop to clean up per-pt objects before exiting 2018-04-06 10:38:03 +08:00
Andy Green
80d84896f1 minimal-http-server-form-post-file 2018-04-06 10:38:03 +08:00
Andy Green
3a020c1eab lws_filename_purify_inplace 2018-04-06 10:38:03 +08:00
Andy Green
764d0d3b45 minimal-http-server-form-get 2018-04-06 10:38:03 +08:00
Andy Green
020a8a2c38 minimal-http-server-form-post 2018-04-06 10:38:03 +08:00
Andy Green
cd30656e01 logging: reduce logs related to POST and spa 2018-04-06 10:38:03 +08:00
Andy Green
865b2439ce mingw: also workaround ENOTCONN 2018-04-06 10:38:03 +08:00
Andy Green
b45956fcb9 client: add alpn processing on mbedtls and openssl
This just supports "http/1.1" alpn and lets the client know it
can use keepalive earlier if it affirmitively negotiated
"http/1.1" on alpn.

mbedTLS wrapper needed a small adaptation to also allow
per-client-ssl control of the alpn negotiation list.
2018-04-06 10:38:03 +08:00
Andy Green
04e1661411 client: http1.1 pipelining 2018-04-06 10:38:03 +08:00
Andy Green
3647cd8968 minimal: client multi 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
d5bb8ecbc6 minimal: raw udp 2018-04-06 10:38:03 +08:00
Andy Green
7cef6fcc7b udp 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
9cf641dece minimal: minimal-raw-adopt-tcp 2018-04-06 10:38:03 +08:00
Andy Green
feeca915b9 lwsws: fix inherited vhost info 2018-04-06 10:38:03 +08:00
Andy Green
eedee9c0d3 cmake: remove unused check on inttypes.h 2018-04-06 10:38:03 +08:00
Andy Green
7aa511d8c5 minimal: minimal raw vhost 2018-04-06 10:38:03 +08:00