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

346 commits

Author SHA1 Message Date
Andy Green
5a34404b1a coverity 872858: hash gen overflow false positive
Help it ignore that we use the MS 7 bits in the next part of the operation
and discard it in the first part.
2025-01-19 16:58:57 +00:00
Andy Green
8fc7596fec event: blow error if runtime context options want eventlib we dont have
https://github.com/warmcat/libwebsockets/issues/3186
2024-09-25 09:03:36 +01:00
Andy Green
8c8a2a5be3 lws_map: remove typedef for some toolchains
This backports a change that has been in main for a while
2024-09-23 11:06:36 +01:00
Lio DongMiao
0fd97f652a context: fall back if no build-time mbedtls version 2024-03-07 09:50:26 +00:00
Luka Kudra
f8eac4e83b mbedtls: dont rely on potentially missing version api
https://github.com/warmcat/libwebsockets/issues/3013
2023-11-21 17:10:54 +00:00
Earl Robsham
7b5a070efc pt_destroy: possible leaking pipe side
Updates the `lws_pt_destroy()` logic to ensure the pipe fds are closed if either `pt->dummy_pipe_fds[0]` or `pt->dummy_pipe_fds[1]` are still valid (previously was only checking `pt->dummy_pipe_fds[0]` which was resulting in the write fd to leak whenever a context was destroyed).
2023-11-15 08:12:17 +00:00
Ogre Transporter
cf07fef590 msvc: avoid error about mixed ellipsis and cond
https://github.com/warmcat/libwebsockets/issues/3001
2023-11-07 06:38:18 +00:00
Andy Green
5a5c31312e mbedtls: print library version 2023-11-07 06:38:11 +00:00
Dmitry Potapov
12250cf3ef openssl3: change deprecated warnings suppression 2022-09-18 08:05:59 +01:00
Poljak181
5a8f790870 logs: setup earlier so we can use on fail path
https://github.com/warmcat/libwebsockets/issues/2679
2022-06-29 17:23:35 +01:00
Andy Green
9e658fa996 threadpool: improve relationship with LWS_HAVE_PTHREAD_H
Make it clear in more places that threadpool is only built if pthreads
available.

https://github.com/warmcat/libwebsockets/issues/2607
2022-05-17 15:37:16 +01:00
Andy Green
69e1507c8c logs: freertos adds free heap to all logs 2022-05-17 15:34:30 +01:00
Andy Green
15db074b70 context_destroy: clean up early fail path 2022-05-17 15:09:09 +01:00
Andy Green
310c8baa81 logs: lock log context refcount changes
Enabling the locking requires -DLWS_MAX_SMP=2 or more.
2022-01-27 14:31:29 +00:00
Felipe Gasper
ff5257e193 logs: migrate more to log context 2021-10-15 14:15:06 +01:00
Pavel Otchertsov
05e9362df2 context: fix compilation error 2021-10-07 13:29:12 +01:00
Andy Green
ee15b82b6e cmake: unbreak LWS_WITH_SYS_STATE disabled build 2021-10-05 07:40:17 +01:00
Andy Green
19ba1998fa tls: evolve handshake serialization into simultaneous_ssl_handshake_restriction
This patch adapts the recent change about serializing the number of
simultaneous tls handshakes allowed to 1, so you can set the number in the
context creation info, and the accounting for it is handled by counters
same as the overally tls restriction.

The name of the context info var to control it changes to simultaneous_ssl_handshake_restriction
which is now a count, the default 0 means no limit.

The count rejects tls connection attempts when the tls borrow is attempted,
and separately hands back the hs borrow from the tls borrow when the
connection attempt fails or succeeds.
2021-10-05 07:40:17 +01:00
Andy Green
0fda90c40a ws-server-threads-smp: modernize 2021-10-05 07:40:03 +01:00
Andy Green
372fdc7184 cancel pipe: make sure we closed it on destroy with no EVENTFD case 2021-09-09 07:27:31 +01:00
Andy Green
81a3ca3e84 ss: port binance example 2021-08-31 05:45:40 +01:00
Andy Green
4db2ff872b cose: keys and signing + validation
Support for COSE keys and signing / validation

 - lws_cose_key_t and import / export / generation apis for EC / RSA / SYMMETRIC

 - cose_sign1 ES256/384/512,RS256/384/512 sign + validate, passes RFC8152 WG tests sign1-tests
 - cose_sign  ES256/384/512,RS256/384/512 sign + validate, passes RFC8152 WG tests sign-tests
 - cose_mac0  HS256/HS256_64/384/512      sign + validate, passes RFC8152 WG tests hmac-examples
 - cose_mac   HS256/HS256_64/384/512             validate, passes RFC8152 WG tests hmac-examples

 - lws-crypto-cose-key commandline tool for key / key set dumping and
   creation
 - lws-crypro-cose-sign commandline tool for signing / validation

 - lws-api-test-cose - large number of test vectors and tests from RFC8152
2021-08-31 05:45:35 +01:00
Yichen Gu
b31c5d6ffe http: cookies: support cookie jar in and out 2021-08-21 17:44:40 +01:00
Andy Green
b67d192100 lws_map 2021-08-21 17:44:40 +01:00
Andy Green
eb8c8354c4 logs: handle LWS_LOGS_TIMESTAMP disabled 2021-08-13 05:25:01 +01:00
Andy Green
4b089788bc tls: mbedtls-3
Adapt mbedtls support for compatibility with v3, while maintaining
compatibility with v2.

Notice v3 has removed the ability to encrypt with pubkey and
decrypt with privkey.  Openssl still has it, atm with v3 these
fall back to encrypt with privkey and decrypt with pubkey.

> The RSA module no longer supports private-key operations with the
> public key or vice versa. As a consequence, RSA operation functions
> no longer have a mode parameter. If you were calling RSA operations
> with the normal mode (public key for verification or encryption,
> private key for signature or decryption), remove the
> MBEDTLS_MODE_PUBLIC or MBEDTLS_MODE_PRIVATE argument. If you were
> calling RSA operations with the wrong mode, which rarely makes sense
>from a security perspective, this is no longer supported.
2021-07-13 13:22:50 +01:00
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
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
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
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
a2091bdbc8 windows: only conceal mode_t on windows 2021-06-20 07:51:24 +01:00
Chunho Lee
af2067365e clean: else became a NOP 2021-06-09 08:11:20 +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
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
Andy Green
212690fb23 smd_queue_depth: cast around toolchain int16_t conv warning 2021-05-23 10:29:51 +01:00
Andy Green
9c6e2ffb65 smp: fix client tsi detection 2021-05-12 09:06:11 +01:00
Andy Green
ff8912ba96 netlink: make failure to bind nonfatal 2021-04-20 16:05:01 +01:00
Andy Green
aa6b3f418e mbedtls: allow central trust store preload
Mbedtls does not have the same concept as openssl about preloading the
system trust store into every SSL_CTX.

This patch allows you to simulate the behaviour by passing in a context
creation-time filepath that all client SSL_CTX will be initialized from.
2021-04-15 19:10:54 +01:00
Andy Green
402e97a679 ss: metrics: http: just report at wsi close
Defer recording the ss metrics histogram until wsi close, so it has a
chance to collect all the tags that apply.

Defer dumping metrics until the FINALIZE phase of context destroy, so we
had a chance to get any metrics recorded.
2021-04-08 06:47:54 +01:00
Mykola Stryebkov
0d06d4bad2 windows: work well with vcpkg pthreads 2021-04-05 10:55:04 +01:00
Andy Green
7f8e2edc3d windows: cancel pipe is in pts not context 2021-04-05 10:55:04 +01:00
Andy Green
7d8f742594 smp: more lock assertions 2021-04-05 10:55:04 +01:00
Andy Green
d291c02a23 ss: sspc: add conmon performance telemetry
This provides a way to get ahold of LWS_WITH_CONMON telemetry from Secure
Streams, it works the same with direct onward connections or via the proxy.

You can mark streamtypes with a "perf": true policy attribute... this
causes the onward connections on those streamtypes to collect information
about the connection performance, and the unsorted DNS results.

Streams with that policy attribute receive extra data in their rx callback,
with the LWSSS_FLAG_PERF_JSON flag set on it, containing JSON describing the
performance of the onward connection taken from CONMON data, in a JSON
representation.  Streams without the "perf" attribute set never receive
this extra rx.

The received JSON is based on the CONMON struct info and looks like

{"peer":"46.105.127.147","dns_us":596,"sockconn_us":31382,"tls_us":28180,"txn_resp_us:23015,"dns":["2001:41d0:2:ee93::1","46.105.127.147"]}

A new minimal example minimal-secure-streams-perf is added that collects
this data on an HTTP GET from warmcat.com, and is built with a -client
version as well if LWS_WITH_SECURE_STREAMS_PROXY_API is set, that operates
via the ss proxy and produces the same result at the client.
2021-04-05 10:55:04 +01:00
Andy Green
51490ae6e6 Fault injection
add lws_xos: xoshiro256 PRNG
2021-04-05 10:55:04 +01:00
Andy Green
e2f1dd1c82 mbedtls: session cache and resume 2021-04-04 05:44:08 +01:00
Pavel Otchertsov
932527a3e7 access-log: use localtime_r instead of localtime if possible
Also replace the WIN32 check to global LWS_HAVE_LOCALTIME_R in logs.c
2021-03-25 09:12:11 +00:00
Andy Green
ae0b52c0df lws_hex_from_byte_array 2021-03-25 08:40:52 +00:00
Andy Green
0f42f0d9ad uloop 2021-03-17 12:23:34 +00:00
Andy Green
1000a52df3 logs: prioritize WITH_NO_LOGS even in release
Really not having any logs makes it difficult to know what is really
happening, but if that's you're thing this will align debug and release
modes to just have ERR and USER if you give WITH_NO_LOGS
2021-03-15 12:56:15 +00:00