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

316 commits

Author SHA1 Message Date
Andy Green
4692c1a7ee rtos: clean warnings where uint32_t is an unsigned long 2019-06-07 11:11:46 +01:00
Chen Xi
892cde2c71 rtos: add support for AMAZON_RTOS 2019-06-05 05:04:17 +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
f89aa401cc generic-sessions update
Generic sessions has been overdue some love to align it with
the progress in the rest of lws.

1) Strict Content Security Policy
2) http2 compatibility
3) fixes and additions for use in a separate process via unix domain socket
4) work on ws and http proxying in lws
5) add minimal example
2019-05-06 10:24:51 +01:00
Andy Green
ae6346db64 ws: connection parse: check just the resolved token
Add strncasecmp to correctly restrict the check to just the
tokenizer token extent
2019-05-04 08:28:29 +01:00
Andy Green
80135635bb permissions: adapt drop permissions plat function to do uid and gid lookup separately 2019-05-02 09:28:25 +01:00
Andy Green
38fb0e31da lws_struct
lws_struct JSON + sqlite3 serializer and deserializer


See READMEs/README.lws_struct.md
2019-04-06 06:08:47 +08:00
Andy Green
1062370f07 unix skt: allow control over skt user:group
If you're providing a unix socket service that will be proxied / served by another
process on the same machine, the unix fd permissions on the listening unix socket fd
have to be managed so only something running under the server credentials
can open the listening unix socket.
2019-03-26 14:54:49 +08:00
Andy Green
ce1f395ead context: add info members to drop privileges using user and group name strings
Up until now if you wanted to drop privs, a numeric uid and gid had to be
given in info to control post-init permissions... this adds info.username
and info.groupname where you can do the same using user and group names.

The internal plat helper lws_plat_drop_app_privileges() is updated to directly use
context instead of info both ways it can be called, and to be able to return fatal
errors.

All failures to lookup non-0 or -1 uid or gid names from uid, or to look up
uid or gid from username or groupnames given, get an err message and fatal exit.
2019-03-26 14:54:49 +08:00
Andy Green
53c932e05d lws_hex_to_byte_array
Convert ascii hex into byte array
2019-03-23 12:41:29 +08:00
Andy Green
303c78a5dd hrtimer: insert must handle head tail pointers 2019-03-21 18:53:59 +08:00
Andy Green
668a3f440f minimal-http-server-eventlib-smp 2019-03-21 10:26:42 +08:00
Andy Green
13ae9927a3 lws_dll[2]_foreach_safe: add user cb param
The callback flow is a bit more disruptive than doing the iteration
directly in your function.  This helps by passing a user void *
into the callback set as an lws_dll[2]_foreach_safe() arg.
2019-03-21 10:24:58 +08:00
Andy Green
462847bb6f lws_dll: remove lws_dll_lws and deprecate lws_dll_remove 2019-03-21 06:19:31 +08:00
Andy Green
ce5b9a3ad4 lws_dll: teach it to track tail as well as head 2019-03-21 06:19:30 +08:00
Andy Green
8dd3383368 lws_dll_foreach_safe 2019-03-21 06:19:30 +08:00
Andy Green
4c3146c27c glibc: if malloc_trim() exists, call it periodically 2019-03-16 08:10:47 +08:00
Andy Green
09fe212432 bzero: replace all with memset
lws_explicit_bzero() is available if the goal is to have volatile zeroing.
2019-03-10 08:02:02 +08:00
Andy Green
b31ab02786 ipv6: force ipv4 if iface bind uses ipv4 address 2019-03-10 08:02:02 +08:00
Andy Green
c289ee3199 ipv6: migrate header includes to private.h 2019-03-10 08:02:02 +08: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
t00416110
8a4b72463f ws: fix coredump of lws_create_context
Signed-off-by: t00416110 <tanyifeng1@huawei.com>
2019-01-22 18:36:02 +08:00
Andy Green
043700a4b0 optee: remove build system 2019-01-15 06:59:48 +08:00
Andy Green
84a57540ab LWS_WITH_NETWORK: cmake option for no network code 2019-01-13 07:54:57 +08:00
pblemel
39e19c85f1 qnx: qnx6.5 compatibility 2019-01-11 17:14:14 +08:00
Andy Green
d2a1bbd8aa optee: other plat fixes 2019-01-11 17:14:14 +08:00
Andy Green
ad9c99a6d3 mbedtls: finer-grained enable checks and OP-TEE 2019-01-11 13:17:06 +08:00
Andy Green
d995d75ffb adopt: keep most of adopt.c even with WITHOUT_SERVER 2019-01-11 13:16:59 +08:00
Andy Green
c8987a14bc adaptations 2019-01-11 13:13:19 +08:00
Andy Green
0adc845507 lws-x509: validation functions 2018-12-31 20:35:54 +08:00
Andy Green
21889b53f7 ecdh-es
Mainly JWE support for ecdh-es and initial refactor to support multiple
recipients / signatures.
2018-12-27 06:45:32 +08:00
Andy Green
eda102e397 jwe 2018-12-27 06:45:32 +08:00
Andy Green
ddb94d4e27 genaes: generic AES layer independent of tls library
Although RSA can be used directly for signing / JWS
on large chunks of data since it's only operating on
the hash, when JWE support arrives, which allows bulk
encryption, it's going to be mandatory to support
secondary AES ciphers to use on the bulk data.

This adds generic support for all AES modes that OpenSSL
and mbedTLS have in common, works on both mbedTLS and
OpenSSL the same, and adds unit tests for each mode
in api-test-gencrypto, to run in CI.
2018-12-27 06:45:31 +08:00
Andy Green
440dacc992 JOSE: refactor and prepare for JWE
Until now the JOSE pieces only had enough support for ACME.
This patch improves the JWK parsing to prepare for more
complete support and for adding JWE, genaes and genec in
later patches.
2018-12-27 06:45:31 +08:00
Andy Green
08b5ad9299 role: raw-proxy 2018-12-01 11:05:59 +08:00
Andy Green
d78457425d lws_raw_transaction_completed
This provides a way to defer closing if the output buflist has
unsent content for the wsi, until the buflist is drained.

It doesn't make any assumption about the content being related
to http, so you can use it on raw.

It follows the semantics of the http transaction completed, ie

     if (lws_raw_transaction_completed(wsi))
	return -1

     return 0;
2018-12-01 11:05:59 +08:00
Andy Green
43cf8bb391 wsi: opaque_user_data and accessors
Under some circumstances it's useful to tag a wsi with user
data, while still having an lws-allocated and destroyed pss.
2018-12-01 11:05:59 +08:00
Andy Green
6830f2d296 cgi: use transaction_complete when stdout goes away
transaction_complete includes processing for the case we are holding
an output-side buflist, and arranges for it to be sent before the
connection is actually closed.

This stops very slow links not being ablet to use git clone via
cgi mount, because the close races the flushing of the output-side
buflist and in the case the connection is bad, closes before
everything was sent.
2018-12-01 11:05:59 +08:00
Andy Green
b318877cd9 adopt: allow associated accepted vhost connections to specific role
Normalize the vhost options around optionally handling noncompliant
traffic at the listening socket for both non-tls and tls cases.

By default everything is as before.

However it's now possible to tell the vhost to allow noncompliant
connects to fall back to a specific role and protocol, both set
by name in the vhost creation info struct.

The original vhost flags allowing http redirect to https and
direct http serving from https server (which is a security
downgrade if enabled) are cleaned up and tested.

A minimal example minimal-raw-fallback-http-server is added with
switches to confirm operation of all the valid possibilities (see
the readme on that).
2018-12-01 11:05:59 +08:00
Andy Green
4e2eef35d4 plugin: lws deaddrop 2018-11-28 15:06:10 +08:00
Andy Green
a74a966fbf ws: support basic auth
Until now basic auth only protected http actions in the protected
mount.

This extends the existing basic auth scheme to also be consulted for
ws upgrades if a "basic-auth" pvo exists on the selected protocol for
the vhost.  The value of the pvo is the usual basic auth credentials
file same as for the http case.
2018-11-28 15:06:10 +08:00
Andy Green
9bed6d6fc6 clean: general whitespace cleanup 2018-11-23 08:47:56 +08:00
Andy Green
cdd8ad702c bind: treat EADDRINUSE as fatal
The retry stuff for bind failures is actually aimed at the scenarios the interface
either doesn't exist yet, or is not configured enough (having an IP) to be bindable yet.

This patch treats EADDRINUSE as fatal at vhost init.
2018-11-22 17:58:30 +08:00
Andy Green
8f2edbe822 minimal-example-pmd-corner: pmd corner case exerciser 2018-11-21 17:03:29 +08:00
Andy Green
c4c60fb95e minimal: update copies of test assets to CSP-compatible versions 2018-11-15 17:15:29 +08:00
Andy Green
b2b58b5b14 smp: lws_timed_callback_vh_protocol: request sets handler tsi and other fixes 2018-11-15 16:37:55 +08:00
Andy Green
0a0b88174d minimal: minimal-ws-client-spam 2018-11-15 10:00:54 +08:00
Andy Green
129d080a8a service: if we got POLLIN service it before checking timeout 2018-11-14 20:04:14 +08:00
Andy Green
7d9ff98263 logs: go back to ansi only on tty and add lwsl_emit_stderr_notimestamp 2018-11-13 17:03:33 +08:00
Andy Green
97f9af5e3b tokenizer: flags for dot not delim and floats as strings 2018-11-13 09:34:10 +08:00