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

3778 commits

Author SHA1 Message Date
Bing Zhao
c604b9cb21 tls: add option to serialize ssl handshake
This is useful for memory constrained systems such as esp32
to improve heap usage minfree/watermark.

On esp32 with simultaneous_ssl_restriction = 2 (MQTT+H1),
Without this change, sys heap minfree ranges from 59k to 71k
  in 100 iterations, average 66.5k.
With this change, sys heap minfree ranges from 64k to 71k
  in 100 interations, average 68.7k
2021-07-08 06:22:47 +01:00
Bing Zhao
74799161b1 tls: fix inbalanced tls restrict borrow/return calls
lws_tls_restrict_borrow() returns error when tls restriction limit is
reached. However lws_ssl_close() still calls lws_tls_restrict_return()
to decrease simultaneous_ssl. Thus LWS accepts more than allowed ssl
links, making simultaneous_ssl_restriction useless.

Fix it by tracking lws_tls_restrict_borrow() return value and only
calling lws_tls_restrict_return() if lws_tls_restrict_borrow() is
successful.
2021-07-08 06:22:47 +01:00
Andy Green
46c84eec06 raw-proxy: fix role bind flag 2021-07-08 06:22:45 +01:00
Andy Green
ee510154a0 fi: wsi: fault to fake peer hangup after a delay range
Example usage, client

$ valgrind ./bin/lws-minimal-secure-streams-stress-client -c 4 --budget 40

proxy

$ valgrind ./lws-minimal-secure-streams-proxy --fault-injection "ss=mintest/wsi/timedclose(20%),ss=mintest/wsi/timedclose_ms(0..100)"
2021-07-04 10:29:54 +01:00
Andy Green
36e7e8af78 fault injection: pseudorandom 64-bit range support
This adds an api allowing fault injection path implementations to get hold
of pseudo-random numbers between an externally-provided range.

You can set it using, eg, --fault-injection "f1(10%),f1_delay(123..456)"
while f1 shows how to decide whether to inject the fault and f1_delay
provides a pseudo-random number between the two values for the fault
implementation code to use.
2021-07-04 10:29:54 +01:00
Andy Green
fabe78d222 Wextra
Add -Wextra (with -Wno-unused-parameter) to unix builds in addition to
-Wall -Werror.

This can successfully build everything in Sai without warnings / errors.
2021-07-04 10:29:54 +01:00
Andy Green
5432e8ae7b sspc: add concurrency stress
Add a way to perform sspc tests with increased concurrency and sequential
tests
2021-07-04 10:29:52 +01:00
Andy Green
a7edd16399 logs: more internal conversion to log_cx 2021-07-01 05:20:53 +01:00
Andy Green
5d8cf03221 logs: log contexts 2021-07-01 05:20:53 +01:00
Andy Green
8e76634ed3 logs: introduce log_cx 2021-07-01 05:20:53 +01:00
Chunho Lee
349cc1b635 mqtt: fix wrong packet id in some conditions 2021-07-01 05:11:25 +01:00
Andy Green
66afeaa5bc dns: handle EAI_NONAME as fatal
This causes the blocking dns lookup to treat EAI_NONAME as immediately
fatal, this is usually caused by an assertive NXDOMAIN from the DNS server
or similar.

Not being able to reach the server should continue to retry.

In order to make the problem visible, it reports the situation using
CLIENT_CONNECTION_ERROR, even though it is still inside the outer client
creation call.
2021-06-28 08:52:20 +01:00
Andy Green
34afca321c netlink: hold in COLDPLUG until we actually have some routing table contents 2021-06-27 08:42:26 +01:00
Andy Green
d5475807b0 tls restriction: check before doing bio 2021-06-26 14:59:50 +01:00
Andy Green
576bed631f sspc: close: differentiate between ss and sspc at final wsi close
A second chunk of ss / sspc handling did not get cleaned up
along with the other patch from a few weeks ago, it wrongly
treats sspc the same as ss.  This can cause the wrong thing
to be zeroed down, 64-bit and 32-bit builds end up with
different victims.

This patch makes it understand the difference and treat them
accordingly, same as the main for_ss handling.
2021-06-26 13:03:13 +01:00
Andy Green
9e8eb28c72 sul: improve debugging 2021-06-26 13:03:13 +01:00
Andy Green
c0680fa2b6 connect: fix cli_hostname leak breaking staggered h1 pipeline 2021-06-26 13:03:13 +01:00
David Jeffers
c90feba3f6 gcc: gcc8 only recognizes fallthu
Later gcc is more accepting, but there's at least one gcc8 toolchain that only likes
to hear "fallthru", or it will flag it
2021-06-24 17:32:57 +01:00
Andy Green
0dd8a4a503 tls-sessions: remove no stash warning
If there's no stash, we didn't get as far as having a session, so just fail
quietly
2021-06-24 06:31:39 +01:00
Andy Green
a095e6c60b ss: sspc: enforce not allowed to call lws_ss[pc]_destroy from callbacks
For both ss and sspc, enforce at runtime that user code cannot call
lws_ss[pc]_destroy on a handle from a callback.

The error indicates the remedy (return DESTROY_ME) and asserts.
2021-06-23 16:51:59 +01:00
Andy Green
5ea9194378 ss: check destroy null policy 2021-06-22 17:44:40 +01:00
Andy Green
7135b3113b ss: check serialize null policy 2021-06-22 16:54:04 +01:00
Andy Green
c859b60854 ss: avoid null ss policy on req tx len 2021-06-22 16:47:59 +01:00
Andy Green
9bd8819045 ss: avoid null ss policy on req tx 2021-06-22 16:47:11 +01:00
Andy Green
cf2dbdc6a0 vhost: create multiple listen sockets per AF
On some platforms AF_INET and AF_INET6 must be listened for on separate
sockets.  Adapt the vhost server creation code to use the new support for
multiple listen sockets per vhost to create up to two listen sockets for
AF_INET and AF_INET6.

It refactors how the decision about the AF is made and propagated so
there's only one place for it.
2021-06-22 16:25:50 +01:00
Andy Green
6163c96727 vhost: allow multiple listen sockets
Some platforms need two sockets with AF_INET and AF_INET6 to listen to both
protocols.

This patch changes the single listen socket each vhost could previously
handle to become an lws_dll2 and adapts the related code to handle them as
a linked-list rather than as a singleton.

The next patch adapts the listen / server code to create multiple listen
wsi for vhosts listening on multiple ip protocols.
2021-06-22 15:55:47 +01:00
Andy Green
8c122cd8bd redirect: make sure we start with / on path 2021-06-22 15:55:36 +01:00
Andy Green
272dba8307 http: redo redirects to follow close flow
Until now although we can follow redirects, and they can promote the
protocol from h1->h2, we couldn't handle h2 wsi reuse since there are many
states in the wsi affected by being h2.

This wipes the related states in lws_wsi_reset() and follows the generic
wsi close flow before deviating into the redirect really close to the end,
ensuring we cleaned out evidence of our previous life properly.

h2->h2 redirects work properly after this.

The max number of redirects is increased from 3 -> 4 since this was seen in
the wild with www and then geographic-based redirects.
2021-06-22 15:55:29 +01:00
Andy Green
2f9bb7a30a tls: JIT Trust
Add support for dynamically determining the CAs needed to validate server
certificates.  This allows you to avoid instantiating > 120 X.509 trusted
CA certs and have them take up heap the whole time.

Works for both openssl and mbedtls.

See READMEs/README.jit-trust.md for the documentation

You likely want the next patch for http redirect enhancements as well.
2021-06-22 15:55:29 +01:00
Andy Green
f8f1749be9 client: add option for allowing redirect tls downgrades 2021-06-22 15:55:29 +01:00
Andy Green
983edafdb4 mbedtls: add AKID and SKID support 2021-06-22 15:55:29 +01:00
Andy Green
b25079c4b4 lws_cache_ttl 2021-06-22 15:55:29 +01:00
Haopeng Li
cb5b1f720b ss: h1: log dereferences NULL 2021-06-22 15:54:22 +01:00
Andy Green
c476d30a94 android: getnameinfo uses nonstandard size_t 2021-06-20 13:39:46 +01:00
Andy Green
1929e1f128 getifaddrs: casts for android 2021-06-20 08:40:00 +01:00
Mykola Stryebkov
8886cc263f win32: client: just do WIN32 check 2021-06-20 07:51:28 +01:00
Andy Green
a2091bdbc8 windows: only conceal mode_t on windows 2021-06-20 07:51:24 +01:00
Andy Green
350a6dc9ef threadpool: disassociate wsi on close 2021-06-20 06:03:59 +01:00
RobHap
226c88ba32 freertos: check for forcing each time around service loop
https://github.com/warmcat/libwebsockets/issues/2325
2021-06-16 05:56:25 +01:00
kekxv
c61ce6f07f cmake: tls: use CHECK_SYMBOL_EXISTS 2021-06-15 15:17:34 +01:00
Jed Lu
2abf4115a8 ss: direct protocol string 2021-06-11 14:44:10 +01:00
Chunho Lee
af2067365e clean: else became a NOP 2021-06-09 08:11:20 +01:00
Haopeng Li
b3bff76a73 strexp: handle NULL better 2021-06-07 15:11:12 +01:00
Andy Green
9fe4b37650 wilcard: change api to use length for check
The wilcard part was always length driven... but the check part relied on
being NUL terminated.  Change that to also use a length specifier and not
need any NUL.

To migrate old uses, just add a fourth param as strlen(check).
2021-06-07 14:57:57 +01:00
DUOLabs333
d815c39c0c cygwin: include in unix type socket init 2021-06-07 08:17:52 +01:00
Andy Green
7baf400017 evlib: allow custom evlib ops
Adapt the event lib support slighly so we can pass an event lib "plugin"
header in at context creation time, and direct all event loop handling to
go via that.

This can then be lightly adapted to interface to an existing custom event
loop cleanly, without the problems of EXTERNAL_POLL.

The external loop must consult with us about the max wait timeout as shown
in the added minimal-http-server-eventlib-custom example.

The example shows a complete implementation working with a custom poll()
loop cleanly while only needing 5 ops in the custom event lib handler.
2021-06-07 08:17:49 +01:00
Khem Raj
4b180546db core-net: Remove unused variable
variable 'n' is being set but it is not used anywhere, latest clang is
able to detect this and flags it

Fixes

lib/core-net/route.c:41:6: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
|         int n = 0;
|             ^
2021-06-05 07:51:05 +01:00
Andy Green
890023f821 ss: h2: handle zero length COLON_PATH for metadata 2021-06-04 15:31:49 +01:00
Andy Green
6c5636889d sspc: handle nonexistent metadata cleanly 2021-06-04 15:05:36 +01:00
Andy Green
faad862fb2 coverity: ntp from blob: handle blob missing 2021-06-04 14:58:15 +01:00