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

121 commits

Author SHA1 Message Date
Andy Green
dcaa0013b4 lecp: add CBOR stream parser LECP like JSON LEJP
This provides very memory-efficient CBOR stream parsing
and writing.

The parser  converts pieces of CBOR into callbacks that define
the structure and collate string and blobs into buffer chunks
for extensible and easy access.

It is fragementation-safe and does not need all the CBOR in
the same place at one time, chunks of CBOR are parsed and
discarded as provided.

It does not allocate and just needs a few hundred bytes of
stack for even huge CBOR objects.  Huge strings and blobs
are handled without needing memory to hold them atomically.

Includes ./minimal-examples/api-tests/api-test-lecp that
unit tests it against 82 official example CBORs and
26 additional test vectors from COSE (just checking the CBOR
parsing).

The writing apis allow printf style semantics with a variety
of CBOR-aware %-formats.  The apis write into a context that
manages output buffer usage, if the output buffer fills,
then the apis return with an AGAIN code that lets you issue
and reset the output buffer and repeat the api all to issue
more output.  The subsequent calls can occur much later or
from a different function context, so this is perfect for
WRITEABLE-mediated output from the network parts of lws.

See ./READMEs/README.cbor-lecp.md
2021-08-21 17:44:40 +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
9d123ea507 extpoll: clean up test server for Wconversion in extpoll parts
https://github.com/warmcat/libwebsockets/issues/2332
2021-07-01 05:20:49 +01:00
Pavel Otchertsov
b5ed38395e use ctime_r instead of ctime if possible 2021-03-25 10:08:38 +00:00
Andy Green
632ddd8b9e ssh-demo fix 2021-03-25 08:40:52 +00:00
Andy Green
8d5341d74e vh init: make sure protocol set 2021-02-20 13:54:32 +00:00
Andy Green
0e6df74409 plugins: add option LWS_WITH_PLUGINS_BUILTIN
Add the ability to just build plugins into the main library.
They are already designed to have a pinhole export for when
they are used as dynamic lib plugins so their namespace
does not conflict.
2021-01-31 20:24:29 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
8b82560014 cmake: netbsd: no libdl 2020-12-06 19:39:35 +00:00
Andy Green
224e155676 zip-fops: test-server: also install candide-uncompressed example 2020-12-01 17:29:00 +00:00
Andy Green
3952c2598d zip-fops: example: add concompressed mount too 2020-12-01 16:30:19 +00:00
Andy Green
40f4ce9ffc testapp: extpoll: add back missing EXTERNAL_POLL pieces
EXTERNAL_POLL is not recommended for use for a while, it's a hack to allow
integration of lws with random application poll() loops.

While lws is very happy to do that secondary job for any event lib using the
foreign loop support (for uv, event, glib, and ev), for random roll-your-
own poll() waits there's no api because there's no event lib.  The solution
with a future is upgrade your application to use an event loop.

The test app that supports EXTERNAL_POLL was broken in Apr 2018, so it's
apparently good news nobody has been using it in new implementations
since then.  This patch adds in the missing pieces so we can test it until
it is formally deprecated.
2020-09-18 11:37:21 +01:00
Andy Green
5c7b5af92a cmake: disable export visibility when building lws static
This is complicated by the fact extern on a function declaration implies
visibility... we have to make LWS_EXTERN empty when building static.

And, setting target_compile_definitions() doesn't work inside macros,
so it has to be set explicitly for the plugins.

Checking the symbol status needs nm -C -D as per

https://stackoverflow.com/questions/37934388/symbol-visibility-not-working-as-expected

after this patch, libwebsockets.a shows no symbols when checked like that and
the static-linked minimal examples only show -U for their other dynamic
imports.

In a handful of cases we use LWS_EXTERN on extern data declarations,
those then need to change to explicit extern.
2020-09-06 11:46:25 +01:00
Andy Green
21a22d20ca test-apps: dont build extension support if LWS_WITHOUT_EXTENSIONS 2020-08-31 16:51:37 +01:00
Andy Green
629c8138b1 sai: freebsd 2020-08-10 15:04:10 +01:00
Andy Green
4f84fcb124 cmake: windows: WIN32_HELPERS_PATH already ready for one-level-down CMakeLists.txt
https://github.com/warmcat/libwebsockets/issues/1992
2020-07-30 06:02:48 +01:00
Andy Green
6747ab830e content_info: make members conditional 2020-06-18 08:29:43 +01:00
Andy Green
2a772776a9 windows: for data exports use explicit extern
LWS_EXTERN needs to be empty for windows when declaring functions in the
headers.  But for data, it needs the explicit extern otherwise on windows
or mingw based builds, it thinks we are redeclaring the data each time.
2020-06-07 07:53:36 +01:00
Andy Green
b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
Andy Green
280c81278d ws: remove now unused ws_ping_pong_interval
https://github.com/warmcat/libwebsockets/issues/1915
2020-05-27 08:40:12 +01:00
Andy Green
e4a9307b11 lejp: support outer element is array 2020-05-11 21:20:29 +01:00
Andy Green
9f1d019352 CTest: migrate and deprecate existing selftest scripts
Replace the bash selftest plumbing with CTest.

To use the selftests, build with -DLWS_WITH_MINIMAL_EXAMPLES=1
and `CTEST_OUTPUT_ON_FAILURE=1 make test` or just
`make test`.

To disable tests that require internet access, also give
-DLWS_CTEST_INTERNET_AVAILABLE=0

Remove travis and appveyor scripts on master.

Remove travis and appveyor decals on README.md.
2020-05-11 15:40:13 +01:00
Andy Green
61cd344c13 minilex: fix ROLE_WS=0 case 2020-03-06 15:22:36 +00:00
Andy Green
4f6143fff0 lws logo: update minimal examples 2020-03-06 04:46:39 +00:00
Andy Green
5055096e47 clean: codacy 2020-01-14 10:06:26 +00:00
Andy Green
277d0e5e4c license: fix up last mentions of lgpl outside of the source file license grant part 2019-12-02 11:19:30 +00:00
Andy Green
fb907e1061 test-client: crl: declare vars before code
Some toolchains blow chunks otherwise

https://github.com/warmcat/libwebsockets/issues/1451
2019-11-06 09:02:59 +00:00
Zhiwen Zheng
14746d9014 illumos: fixes for build warnings 2019-10-12 12:41:14 +01:00
Andy Green
c36a1e8ed0 clean: internally use LWS_WITH_CLIENT and _SERVER
Remove some more things in LWS_WITH_SERVER=0 case
2019-08-26 09:58:57 +01:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
d302198019 external poll: add default-off cmake option
External poll support generates a lot of messages on a busy system
for no value unless you're one of the few people using it.  It's
not recommended for new users and is there for backwards compatibility.

Make it not built by default and selectable by cmake option.
2019-08-12 12:44:36 +01:00
Andy Green
498a4e2bd7 sul: all timed objects use a single pt sul list
wsi timeout, wsi hrtimer, sequencer timeout and vh-protocol timer
all now participate on a single sorted us list.

The whole idea of polling wakes is thrown out, poll waits ignore the
timeout field and always use infinite timeouts.

Introduce a public api that can schedule its own callback from the event
loop with us resolution (usually ms is all the platform can do).

Upgrade timeouts and sequencer timeouts to also be able to use us resolution.

Introduce a prepared fakewsi in the pt, so we don't have to allocate
one on the heap when we need it.

Directly handle vh-protocol timer if LWS_MAX_SMP == 1
2019-08-09 10:12:09 +01:00
hjfbswb
8d79c06f49 android: build fixes 2019-08-02 15:57:57 +01:00
Andy Green
3b44a745c9 h2-tx-credit-disallow-overflow 2019-07-08 08:48:58 +01:00
Andy Green
4692c1a7ee rtos: clean warnings where uint32_t is an unsigned long 2019-06-07 11:11:46 +01:00
Andy Green
48366de1d1 unix plat: add minimal wsi fd map option
An lws context usually contains a processwide fd -> wsi lookup table.

This allows any possible fd returned by a *nix type OS to be immediately
converted to a wsi just by indexing an array of struct lws * the size of
the highest possible fd, as found by ulimit -n or similar.

This works modestly for Linux type systems where the default ulimit -n for
a process is 1024, it means a 4KB or 8KB lookup table for 32-bit or
64-bit systems.

However in the case your lws usage is much simpler, like one outgoing
client connection and no serving, this represents increasing waste.  It's
made much worse if the system has a much larger default ulimit -n, eg 1M,
the table is occupying 4MB or 8MB, of which you will only use one.

Even so, because lws can't be sure the OS won't return a socket fd at any
number up to (ulimit -n - 1), it has to allocate the whole lookup table
at the moment.

This patch looks to see if the context creation info is setting
info->fd_limit_per_thread... if it leaves it at the default 0, then
everything is as it was before this patch.  However if finds that
(info->fd_limit_per_thread * actual_number_of_service_threads) where
the default number of service threads is 1, is less than the fd limit
set by ulimit -n, lws switches to a slower lookup table scheme, which
only allocates the requested number of slots.  Lookups happen then by
iterating the table and comparing rather than indexing the array
directly, which is obviously somewhat of a performance hit.

However in the case where you know lws will only have a very few wsi
maximum, this method can very usefully trade off speed to be able to
avoid the allocation sized by ulimit -n.

minimal examples for client that can make use of this are also modified
by this patch to use the smaller context allocations.
2019-05-18 12:10:19 +01:00
Andy Green
f7149e90c2 cc0: align dedication to CC0 FAQ recommended format
https://libwebsockets.org/pipermail/libwebsockets/2019-April/007937.html

thanks to Bruce Perens for noting it.

This doesn't change the intention or status of the CC0 files, they were
pure CC0 before (ie, public domain) and they are pure CC0 now.  It just
gets rid of the (C) part at the top of the dedication which may be read
to be a bit contradictory since the purpose is to make it public domain.
2019-05-02 09:29:01 +01:00
Andy Green
0405c0c878 lejp: make sure child object close is not mistaken for parent 2019-05-02 09:28:38 +01:00
Andy Green
e63b3a6348 daemonize: use pid_t
After report from Vitaly Shevtsov

https://libwebsockets.org/pipermail/libwebsockets/2019-January/007787.html
2019-01-23 18:06:32 +08:00
pblemel
39e19c85f1 qnx: qnx6.5 compatibility 2019-01-11 17:14:14 +08:00
Andy Green
eda102e397 jwe 2018-12-27 06:45:32 +08:00
Andy Green
08b5ad9299 role: raw-proxy 2018-12-01 11:05:59 +08:00
Andy Green
c027c3db28 docs: cleanups 2018-11-21 17:03:29 +08:00
Andy Green
d9f982a055 minimal examples: update for CSP best practices
1) update the logos to svg

2) add svg icon for strict security policy where used

3) define new vhost option flag to enforce sending CSP headers
   with the result code

4) add vhost option flag to minimal examples to
   enforce sending CSP where applicable

5) Go through all the affecting examples confirming they
   still work

6) add LWS_RECOMMENDED_MIN_HEADER_SPACE constant (currently
   2048) to clarify when we need a buffer to hold headers...
   with CSP the headers have become potentially a lot
   larger.
2018-11-21 17:03:29 +08:00
Andy Green
0a0b88174d minimal: minimal-ws-client-spam 2018-11-15 10:00:54 +08:00
Andy Green
93d4e186c2 openssl tls1.3: allow setting ciphersuites at context creation time
https://github.com/warmcat/libwebsockets/issues/1440
2018-10-27 08:05:21 +08:00
Andy Green
1f1314160a lws_hdr_copy: ensure enough extra space
Audit all lws_hdr_copy() usages inside lws and make sure we
take care about it failing.

Also since the patch around aggregation of headers by ',',
lws_hdr_copy() needs a little more space in the output buffer,
adjust one place where that caused it to start failing in an
exact-sized buffer.
2018-10-26 16:14:30 +08:00
Andy Green
33a6034875 codacy: minor fixes 2018-10-13 08:16:27 +08:00
Andy Green
fd810f198a http proxy: client: unix socket support
This allows the client stuff to understand that addresses beginning with '+'
represent unix sockets.

If the first character after the '+' is '@', it understands that the '@'
should be read as '\0', in order to use Linux "abstract namespace"
sockets.

Further the lws_parse_uri() helper is extended to understand the convention
that an address starting with + is a unix socket, and treats the socket
path as delimited by ':', eg

http://+/var/run/mysocket:/my/path

HTTP Proxy is updated to allow mounts to these unix socket paths.

Proxy connections go out on h1, but are dynamically translated to h1 or h2
on the incoming side.

Proxy usage of libhubbub is separated out... LWS_WITH_HTTP_PROXY is on by
default, and LWS_WITH_HUBBUB is off by default.
2018-09-12 13:58:13 +08:00
Andy Green
6a59af4282 test-app: remove -r resource path 2018-09-11 18:27:59 +08:00