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

4507 commits

Author SHA1 Message Date
Andy Green
1d3ec6a3a1 lws-jpeg
Introduce a rewritten picojpeg that is able to operate statefully and
rasterize into an internal line ringbuffer, emitting a line of pixels
at a time to the caller.  This is the JPEG equivalent of the lws
PNG decoder.

JPEG is based around 8- or 16- line height MCU blocks, depending on
the chroma coding, mandating a corresponding internal line buffer
requirement.

Example total heap requirement for various kinds of 600px width jpeg
decoding:

  Grayscale:    6.5KB
  RGB 4:4:4:   16.4KB
  RGB 4:2:2v:  16.4KB
  RGB 4:4:2h:  31KB
  RGB 4:4:0:   31KB

No other allocations occur during decode.

Stateful stream parsing means decode can be paused for lack of input
at any time and resumed seamlessly when more input becomes available.
2022-03-25 08:13:48 +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
48907fca0a upng: rewrite for stateful stream decode
Add a rewritten version of upng that decodes statefully line by line, and so
does not require a bitmap buffer for the output.  This compares to original
upng approach that needs heap allocations for the input, the whole output
and intermediate allocations.

Instead of buffers for input, decompression and output, it only allocates
2 x lines of RGBA pixels (ie, a few KB), and 32KB of decompressed data for
backward references in the decoder, and decodes as needed into the 2-line
buffer to produce line rasterized results.  For a 600px width PNG, this is
just 40KB heap for the duration.
2022-03-16 12:59: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
tjwalton
3070709f18 clean: Remove redundant redeclaration 2022-03-15 10:28:09 +00:00
Andy Green
bad7a28bfd esp32: heltec: change delay
Newer esp-idf has lost ets-delay-us
2022-03-15 10:28:09 +00:00
Andy Green
7ccd7e10aa gcc12: fix potential test app string overflow 2022-03-15 10:28:09 +00:00
Andy Green
946b1fbff1 coverity: 2021-12-1 uplevel fixes 2022-03-15 10:28:09 +00:00
Andy Green
843ee10205 mbedtls: v3.1 reverts privacy of mbedtls_net_context fd
mbedtls seemed to realize that they went overboard with the privacy stuff
on v3.0 and removed some of it.  Introduce support for those members that
are only private on exactly v3.0 and unprotected before and after.
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
wayneonway
73b61f6a2e route: extend lws_route_uidx_t from 1 byte to 2 bytes 2022-03-15 10:28:09 +00:00
Andy Green
155b1c83b5 plugins: openmetrics_export: graceful fail if unconfigured 2022-03-15 10:28:09 +00:00
Andy Green
d7b912c539 gcc4: conceal typedef in public header
Modern toolchains are fine with giving a typedef as a forward reference,
but gcc 4.3 can't cope with that and then seeing the real definition in the
.c later.

Just conceal the typedef and use the struct form for the forward reference
resolution type in the public header so even senior toolchains are happy.
2022-03-15 10:28:09 +00:00
Andy Green
9011f913d5 netlink: always delete route if it exists
https://github.com/warmcat/libwebsockets/issues/2567
2022-03-15 10:28:09 +00:00
Andy Green
d408e67d05 pkgconfig: use appropriate static lib name 2022-03-15 10:28:09 +00:00
Andy Green
64144e0c15 ss: support VFS via file://
This gives you a way to access VFS files via a generic SS.

Typcially you would use the default streamtype having set the ${endpoint}
metadata to file://mypath/vpath.suffix or similar.

The lws VFS lets you register handlers for path prefixes (like /myvfsname)
or suffixes (like .zip).  Matches create a vfs fd that is bound to the
matching file_ops that receives the open, close, read, write etc
"syscalls" for lws VFS operations on the vfs fd.

This gives you a way not just to access files from the platform root
filesystem, but also VFS layers like DLO filesystem blobs, by name,
from a normal SS.
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
Luciano Iam
b61174b4b0 mingw: correct winsock recv() and send() buffer ptr type
This allows to build libwebsockets on MinGW. Winsock recv() and send()
expect non unsigned char* while lws uses uint_8*.

https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-send
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recv
2022-03-15 10:28:09 +00:00
Andy Green
6829dba9a1 http: server: mounts: dont assume Basic Auth if no FILE_OPS 2022-03-15 10:28:09 +00:00
Andy Green
e4a556333a FILE_OPS: add deps for disabled case 2022-03-15 10:28:09 +00:00
Andy Green
24758bd479 ss: POLL to all retries failed is possible
It's possible we started POLL, but no connection could happen for some
reason, and we end in the window between POLL and trying the connection.
2022-03-15 10:28:09 +00:00
Andy Green
5c24f1edad ss: avoid POLL-POLL transition 2022-03-15 10:28:09 +00:00
Andy Green
c8b9ac4aaf seq: remove last vestiges
Sequencer went away a while ago, remove api tests and minimal examples.

Use Secure Streams to get an object with a lifetime longer than a wsi that
can autonomously retry.
2022-03-15 10:28:09 +00:00
Andy Green
445651b2c6 cgi: gracefully handle missing wsi->http.cgi 2022-03-15 10:28:09 +00:00
Andy Green
717272d65d h1: deal with WAITING_CONNECT in ops-h1
We don't normally see events on the wsi in this state, but it is possible
since warmcat.com lwsws asserted on it in WAITING_CONNECT.

Explicitly handle it so we don't blow up.
2022-03-15 10:28:09 +00:00
Andy Green
32698a2f4b lejp-conf: provide matches for block start paths
Also valgrind shows we should zero down the lejp context to avoid problems
with the wildcard stack
2022-03-15 10:28:09 +00:00
Andy Green
1b70ae9296 adns: bump DNS_MAX to 128 2022-03-15 10:28:09 +00:00
Andy Green
5985f817da lgtm.yml 2022-03-15 10:28:09 +00:00
Poppy
6c53da692e tls: libressl: refactor set_options to work with macro implementations
Libressl uses macros for set_options(), causing compilation failure.
Refactor the related code to work well with macro definitions for
these apis.

https://github.com/warmcat/libwebsockets/issues/2554
2022-03-15 10:28:09 +00:00
Andy Green
8cc4c1713d http: proxy server: move C99 VLA to heap 2022-03-15 10:28:09 +00:00
Andy Green
99a8b9c442 cmake: remove duplicate LwsCheckRequirements 2022-03-15 10:28:09 +00:00
Chunho Lee
3af7a16531 ss: mqtt: add support for retained message 2022-03-15 10:28:09 +00:00
Andy Green
4bf39f55d4 h2: improve logging for zero length DATA with EOS 2022-03-15 10:28:09 +00:00
Andy Green
b9e290d70a ss: http: unreachable superfluous if we did DISCONNECTED 2022-03-15 10:28:09 +00:00
Andy Green
ba2441585d jit-trust: adapt for esp-idf pre v3 mbedtls
Ensure we still work with mbedtls_ssl_conf_verify() as well as
mbedtls_ssl_set_verify() if that's what we have got.

Make sure mbedtls tls validation is noisy and fast.

Disable Xenial + mbedtls in sai, it fails but not when the same
tests are run from the commandline.  Very few people will be
using Xenial (2016 Ubuntu release) with mbedtls.
2022-03-15 10:28:09 +00:00
Chunho Lee
f57d84f6fc minimal: ss: mqtt: update certificate
test.mosquitto.org mutual auth certs only have a 6mo lifetime...
2022-03-15 10:28:09 +00:00
Chunho Lee
a34e60581c minimal: ss: policy2c: add more MQTT related fields
This adds 'aws_iot', 'birth_topic', and 'birth_message'
on policy2c.
2022-03-15 10:28:09 +00:00
Chunho Lee
3a98dbb918 ss: mqtt: fix wrong QoS value on Birth message 2022-03-15 10:28:09 +00:00
Sylvain Saunier
84956d280a route: fix nl groups and local ipv6 ads 2022-03-15 10:28:09 +00:00
Andy Green
442f9aeaa8 coverity: mark false positive 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
9b92c47101 ss: reject direct protocol metadata if NULL ss wsi
The ss wsi may be NULL after any time around the event loop.  Make sure we
check that before we start trying to use it.
2022-02-22 14:37:31 +00:00
Andy Green
3bfb854503 ss: http: ensure SS points to wsi when using wsi pointing to SS
If we're going to take a wsi's word for it that it is bound to a particular
SS, make sure the SS is also bound to the same wsi.
2022-02-22 14:37:31 +00:00
Andy Green
dd1e07b28a ss: hello_world uses default policy
This switches the current hello_world to be hello_world-policy now,
and hello_world is simplified to use the __default policy without any
explicit policy of its own.

Using the default policy means it relies on the system tls library to
validate the tls connections using system trust arrangements, that won't
work in cases where the configured tls library does not have its own trust
store.
2022-02-22 14:37:10 +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
0ca97586d6 mbedtls: improve api detection
mbedtls cmake api detection was not able to work on esp-idf well.

Improve diagnostics and reaction if we ever see that again.
2022-02-01 11:09:48 +00:00
Rosen Penev
2f93a8b178 genec: show correct nid when not allowed
As noticed by gcc11 warning

https://github.com/warmcat/libwebsockets/pull/2551
2022-02-01 09:13:58 +00:00
yogpstop
2148becb3a http: lws_add_http_header_by_name: add colon if needed 2022-01-27 13:08:35 +00:00
Andy Green
5124ffe9d4 openssl: x509: truncate CN in presence of other attr
https://github.com/warmcat/libwebsockets/issues/2542
2022-01-26 11:54:08 +00:00