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

378 commits

Author SHA1 Message Date
Andy Green
8e0e0b91df 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-22 08:43:45 +00:00
zzblydia
c1b609db4f lws_snprintf: check null pointer before using 2024-11-02 09:36:19 +00:00
Andy Green
0a5a701cfc event: blow error if runtime context options want eventlib we dont have
https://github.com/warmcat/libwebsockets/issues/3186
2024-09-25 09:04:14 +01:00
Lio DongMiao
299b091ad4 context: fall back if no build-time mbedtls version 2024-03-07 09:49:11 +00:00
AD001\z0048zxj
4f3ce6458b openssl: support SSLKEYLOGFILE server secret logging 2024-02-16 15:45:45 +00:00
Andy Green
837db622eb clean: avoid maybe-uninitialized
https://github.com/warmcat/libwebsockets/issues/3049
2024-01-16 07:15:30 +00:00
Andy Green
52a6ab357e context info: add default_loglevel
Allow this kind of pattern for context creation info preparation

        struct lws_context_creation_info info;

        lws_context_info_defaults(&info, policy);
        info.default_loglevel = LLL_USER | LLL_ERR | LLL_WARN;
        lws_cmdline_option_handle_builtin(argc, argv, &info);

Calling lws_context_info_defaults() zeros down and prepares boilerplate in
the info struct, setting the default_loglevel asserts your application
default for the loglevel and then lws_cmdline_option_handle_builtin() will
set either that default loglevel, or override it from the commandline with
-d 1039 etc
2023-12-14 05:53:21 +00:00
Luka Kudra
8eb89bafb1 mbedtls: dont rely on potentially missing version api
https://github.com/warmcat/libwebsockets/issues/3013
2023-11-23 09:45:12 +00:00
Earl Robsham
8c4c5e6a21 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-23 09:45:12 +00:00
Andy Green
e5a9126e83 buflist: append: treat NULL additional buf as error not assert
Very very occasionally on server we try to add a NULL buffer to a buflist.

Let's try dealing with that by failing (caller must always be able to
handle failure from OOM) rather than asserting.
2023-11-23 09:45:11 +00:00
Ogre Transporter
65f977c7de msvc: avoid error about mixed ellipsis and cond
https://github.com/warmcat/libwebsockets/issues/3001
2023-11-07 06:31:45 +00:00
Andy Green
05e08a511a mbedtls: print library version 2023-11-02 08:07:58 +00:00
zoraaver
a1cbc02aeb Add guard for setrlimit
LWS_HAVE_SYS_RESOURCE_H is correctly set by lws to prevent including
sys/resource.h. However there is no corresponding guard for setrlimit (a
function from that header). This causes a build failure on platforms
which don't have sys/resource.h available.
2023-10-21 07:22:09 +01:00
Andy Green
b35128118e lws_map: stop c++ compiler complaints 2022-09-19 07:49:42 +01:00
Dmitry Potapov
bfbd80967a openssl3: change deprecated warnings suppression 2022-09-18 08:17:25 +01:00
Vladimir
8ab44ae28b client: win32: sul for client connection status polling
https://github.com/warmcat/libwebsockets/pull/2715
https://github.com/warmcat/libwebsockets/pull/2722
2022-09-18 06:16:14 +01:00
Poljak181
b0b4f0dd56 logs: setup earlier so we can use on fail path
https://github.com/warmcat/libwebsockets/issues/2679
2022-06-29 17:21:43 +01:00
Andy Green
4a443c3e2e lhp: add DLO layout support
Add a dlo-based layout callback for use with lhp.

If lhp_dl_render() is used as the Lws Html/CSS parser callback, it
produces a display_list representation of the Html as DLOs, referencing the
appropriate CSS to drive the layout as best it can.

The display list can be rasterized on to an lws_display using the display's
state object

  lds->disp->blit(lds, (uint8_t *)&dl, &box);
2022-05-04 08:43:26 +01:00
Andy Green
3063fe84aa http: lws_http_rel_to_url
URL-level relative-to-absolute converter given a base url
2022-05-04 08:43:26 +01:00
Andy Green
615a08b216 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-04-11 06:53:47 +01:00
Andy Green
047fb7bb21 tokenize: enhance to support chunked parsing
Add EXPECT_MORE flag to indicate that running out of input is not (yet)
indicating the end of the document.  The caller should remove this flag
when it identifies that it does not have the chunk with the end of the
document: the last chunk may be zero length.

Track line numbers so the caller can infer CR, absorb CRLF -> CR.

Also add COLON_NONTERM needed for ipv6 literal addresses.
2022-04-10 06:56:12 +01:00
Andy Green
76d8840c5f coverity: fixes 2022-04-10 06:56:12 +01:00
Andy Green
fcbc0dafa4 lws_ota 2022-03-25 08:18:30 +00:00
Andy Green
432bbf1d97 logs: freertos adds free heap to all logs 2022-03-25 08:18:29 +00:00
Andy Green
6a65d76779 hex-to-bin: api with input length 2022-03-25 08:18:29 +00:00
Andy Green
c11e31547f ss: introduce sinks 2022-03-25 08:18:29 +00:00
Andy Green
a3a4253ba9 dlo: lws_dlo_fops file_ops
This adds an optional lws VFS layer that exposes the named dlo object
registry.  So you can register a blob like a JPG named "my.jpg", and
access it on the vfs as, eg,  /dlofs/my.jpg (or file:///dlofs/my.jpg
if using the SS file:// support for VFS namespace).
2022-03-25 08:18:29 +00:00
Andy Green
e3dca87f23 lws_display: add display list / DLO support
This adds optional display list support to lws_display, using DLOs (Display
List Objects).  DLOs for rectangle / rounded rectangle (with circle as the
degenerate case), PNGs, JPEG and compressed, antialiased bitmapped fonts
and text primitives are provided.

Logical DLOs are instantiated on heap and listed into an lws_display_list
owner, DLOs handle attributes like position, bounding box, colour +
opacity, and local error diffusion backing buffer.

When the display list is complete, it can be rasterized a line at a time,
with scoped error diffusion resolved, such that no allocation for the
framebuffer is required at any point.  DLOs are freed as the rasterization
moves beyond their bounding box.

Adds a platform registry binding names and other metadata to lws_display
fonts / PNGs / JPEGs.  Provides registration, destruction and best match
selection apis.
2022-03-25 08:18:29 +00:00
Andy Green
a74fe5d760 upng: split out gzip
The adapted upng has a very compact fully-stateful lws-aligned
implementation already.

Adapt it to also be buildable and operable standalone, and to
understand gzip headers.

Provide some apis to inflate gzip simply reusing opaque inflator
contexts from upng.

Provide an api test that inflates gzip files from stdin -> stdout
2022-03-25 08:13:48 +00:00
Andy Green
aadcd3c44a lws_fx: fixed point 3232 arithmetic
This introduces a fixed precision signed 32.32 fractional type that can
work on devices without an FPU.

The integer part works as an int32_t, the fractional part represents the
fractional proportion expressed as part of 100M, so 8 fractional decimal
digit precision which is more than enough for many applications.

Add and Sub are reasonably fast as they are scaled on to a combined
uint64_t, Multiply is a little slower as it takes four uint64_t multiplies
that are summed, and divide is expensive but accurate, done bitwise taking
up to 32 iterations involving uint64_t div and mod.
2022-03-15 10:28:09 +00:00
Andy Green
3ed01ab4c9 context_destroy: clean up early fail path 2022-03-15 10:28:09 +00:00
Andy Green
67931757f8 alloc: compressed backtrace instrumentation support
This adds apis that enable usage of compressed backtraces in heap
instrumentation.

A decompressor tool is also provided that emits a textual
call stack suitable for use with addr2line.
2022-03-15 10:28:09 +00:00
Andy Green
2de67dd0ae file_ops: vfs: support prefix matches and use of bound ops members
VFS needs some small updates... pass in the bound fops as well as the
context fops to the member callbacks.  ZIP_FOPS only cared about doing
operations on the platform / context vfs to walk the ZIP file, but other
uses are valid where we are doing operation inside the bound VFS itself.

Also, stash a cx pointer into file ops struct for convenience.
2022-03-15 10:28:09 +00:00
Andy Green
d892b86b93 lws_flow helpers
Add a generic struct to manage a buflist with an incrementally-consumable
head, and helpers to deal with retiring the last segment and starting the
new head.

The lws_flow is added to using the buflist member directly, it autohandles
SS window management to try to keep the total buffered at the client to the
window member limit.
2022-02-22 14:37:31 +00:00
Andy Green
91c6667c04 ss: default policy
Just like there is a default protocol provided if none is specified that is
suitable for handling http GET, introduce a default SS policy that is also
suitable for the case of http GET where the user trusts the CA using the
ssl library or system trust store.
2022-02-22 14:35:43 +00:00
Andy Green
e5e1b34f84 logs: lock log context refcount changes
Enabling the locking requires -DLWS_MAX_SMP=2 or more.
2022-01-26 11:54:08 +00:00
Andy Green
65768cf3eb dll2: add api for inserting afer existing member 2022-01-04 16:08:50 +00:00
Andy Green
8b16aa18c8 minilex: add improved generic version in misc
Leave the http minilex as it is, and add an improved version in lib/misc

 - get a list of strings from stdin and emit C header to stdout

 - support ambiguous terminals (xxx and xxx-something) correctly regardless
   of introduction order

 - add generic parser in lib/misc

minilex doesn't build as part of lws since it's only needed by developers,
there's a one-line build documented at a comment at the top of
lib/misc/minilex.c
2022-01-04 16:08:44 +00:00
Andy Green
b8c4820be4 openssl: support SSLKEYLOGFILE client secret logging
This patch checks for the env var SSLKEYLOGFILE=path, if present, then
client connection tls secrets are appended into path.vhostname.

This allows decryption of captured encrypted data for debugging purposes.

SSKEYLOGFILE=path env var method is the same as provided by Firefox and
Chrome for this purpose.
2021-12-13 19:02:49 +00:00
Andy Green
ba89af373b async dns: allow multiple servers and public add remove apis 2021-11-17 14:50:08 +00:00
Felipe Gasper
81830a3979 logs: migrate more to log context 2021-10-15 14:11:41 +01:00
Andy Green
3ae573cf9b remove: ss plugins
These have been disabled via a preprocessor symbol with no UI to enable it
for a year or so, it looks like they are not going to be needed.

The model of in-tree auth selectable from cmake looks like it will do for
everything, or if not, the solution will probably look different to this.
2021-10-12 07:33:18 +01:00
Andy Green
f5edf9d75a remove: lws_sequencer
lws_sequencer and lws_abstract were both false starts trying to do the
functionality of secure streams.

Since Secure Streams does a better job for both and there are no known
out-of-tree users of them, let's remove them and focus on Secure Streams.
2021-10-12 07:33:15 +01:00
Andy Green
8fd1ea6180 examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
Andy Green
2cfa260e62 sspc: refactor to allow different transports
This is a NOP for existing usecases.

At the moment the only implemented transport for serialized SS is wsi, it's
typically used with Unix Domain Sockets, but it also works over tcp the
same.

It generalizes the interface between serialized chunks and the
transport, separately for client and proxy.  The wsi transport is migrated
to use the new transport ops structs.

It will then be possible to "bring your own transport", so long as it is
reliable, and in-order, both for proxy and client / sspc.

We also adapt minimal-secure-streams-binance to build the -client variant
via SS proxy as well.

LWS_ONLY_SSPC is added so libwebsockets can be produced with just sspc
client support even for tiny targets.

A new embedded minimal example for rpi pico is also provided that
demonstrates using Serialized SS over a UART to an SS proxy, to implement
the SS Binance example on the pico, even though it has no networking itself.
2021-10-08 09:48:41 +01:00
Andy Green
135234bd39 plat: baremetal and rpi pico support 2021-10-08 09:48:41 +01:00
Andy Green
43bb8aead0 dsh: coalesce 2021-10-08 09:48:41 +01:00
Pavel Otchertsov
3cee5910ac context: fix compilation error 2021-10-07 13:25:40 +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