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

3620 commits

Author SHA1 Message Date
Andy Green
698eda63d7 ss: formalize user cb retcodes
It's not safe to destroy objects inside a callback from a parent that
still has references to the object.

Formalize what the user code can indicate by its return code from the
callback functions and provide the implementations at the parents.

 - LWSSSSRET_OK:            no action, OK
 - LWSSSSRET_DISCONNECT_ME: disconnect the underlying connection
 - LWSSSSRET_DESTROY_ME:    destroy the ss object
 - LWSSSSRET_TX_DONT_SEND:  for tx, give up the tx opportunity since nothing to send
2020-06-02 08:37:10 +01:00
Andy Green
e4ab18342a ss: allow NULL cbs
Some streamtypes do not pass or receive payload meaningfully.  Allow them
to just leave their related cb NULL.  Ditto for state, although I'm not sure
how useful such a streamtype can be.
2020-06-02 08:37:10 +01:00
Andy Green
ca3380fd56 deprecation: remove lws_dll1
lws_dll2 has been available for a couple of years and lws_dll1 marked as
deprecated since v3.2.  Remove it.

If it affects you, lws_dll2 has an almost identical api but has more
features, such as storing in the lws_dll2_t which owner it is listed by
and keeping a count of objects on the list at the owner object.
2020-06-02 08:37:10 +01:00
Andy Green
286cf4357a sul: multiple timer domains
Adapt the pt sul owner list to be an array, and define two different lists,
one that acts like before and is the default for existing users, and another
that has the ability to cooperate with systemwide suspend to restrict the
interval spent suspended so that it will wake in time for the earliest
thing on this wake-suspend sul list.

Clean the api a bit and add lws_sul_cancel() that only needs the sul as the
argument.

Add a flag for client creation info to indicate that this client connection
is important enough that, eg, validity checking it to detect silently dead
connections should go on the wake-suspend sul list.  That flag is exposed in
secure streams policy so it can be added to a streamtype with
"swake_validity": true

Deprecate out the old vhost timer stuff that predates sul.  Add a flag
LWS_WITH_DEPRECATED_THINGS in cmake so users can get it back temporarily
before it will be removed in a v4.2.

Adapt all remaining in-tree users of it to use explicit suls.
2020-06-02 08:37:10 +01:00
Andy Green
d5773c01be openssl-v3: deal with deprecated SSL_CTX_load_verify_locations
Add Sai for openssl-v3 and for boringssl
2020-06-02 08:37:10 +01:00
Andy Green
f98e4a845c sai: add f32 plus openssl-v3 combination 2020-06-02 08:37:10 +01:00
Jed Lu
9bf1392b13 ss: http: allow rideshare to gate EOM
When rideshare is in use, the scope of the EOM is the rideshare section.
2020-06-02 08:37:10 +01:00
Andy Green
2b21c2d608 async-dns: callback should leave caller deletion to caller
The guy calling the callback with LADNS_RET_FAILED is going to
inform his caller that it failed... let him decide to close and
fail the connection attempt.
2020-06-02 08:37:10 +01:00
Jed Lu
9290053f5b ss: Support content-length on PUT as well as PUSH 2020-06-02 08:37:10 +01:00
Andy Green
911898ad70 windows: recent win10 support Unix Domain
Allow selection of Unix Domain Sockets on windows since it is supported
for the last couple of years on windows 10

https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

... if only they could add a full set of posix pieces to go with it
(and abstract namespace UDS which doesn't work apparently) so that
the parts dealing with uid / gid don't have to be disabled.
2020-06-02 08:37:10 +01:00
Seonah Moon
b6e215ee7f openssl: fix improper use of negative value 2020-06-02 08:37:10 +01:00
Andy Green
4ff9b4f96e ss: add api test with ctest integration
Tests via httpbin.org
2020-06-02 08:37:10 +01:00
Andy Green
10146575a2 clean: turn down verbosity on some debugging printfs 2020-06-02 08:37:10 +01:00
Andy Green
90c7e789eb PEER_LIMITS: modernize to sa46 and add notification cb
There are a bunch of sa46-aware lws apis for formatting, etc sa46
in ./include/libwebsockets/lws-network-helper.h
2020-06-02 08:37:10 +01:00
dev31337
4f3e012cdd PEER_LIMITS: make sure to close socketfd on deny 2020-06-02 08:37:10 +01:00
Andy Green
ef787e578c lws_struct: clean warning on windows 2020-06-02 08:37:10 +01:00
dev31337
0b0482c127 listen: handle denied FILTER_NETWORK_CONNECTION correctly 2020-06-02 08:37:10 +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
cabe021955 esp32: shift to support latest esp-idf
Esp-idf has an improved but still kind of abused cmake-
based build system now.

If we see ESP_PLATFORM coming as a cmake var, we can know we
are being built from inside the esp-idf config system.

Leave the existing esp32 arrangements alone but triggered off
ESP_PLATFORM, adapt to use the cross toolchain file and
various quirks automatically.

In this way you can build lws a part of your project in a
much cleaner way.

Prepare a minimal esp32 test app for use in Sai

Adapt .sai.json to build for esp32
2020-05-27 08:40:12 +01:00
Andy Green
b6641af88d api-test: lws_struct-json: add worked example
Add support for implicit schema polymorphism
2020-05-27 08:40:12 +01:00
Andy Green
c1aac63a6d http: if no content length transaction completes at hangup
If you encounter an h1 transaction with no content length and you
parsed the headers, it actually means a hangup subsequently is an
indication of a correct transaction completion.  So take care to
do the _COMPLETION callback under those circumstances too.
2020-05-27 08:40:12 +01:00
Andy Green
33f8e219eb tls: defer listing of pending tls wsi to be managed by tls read only
https://github.com/warmcat/libwebsockets/issues/1920
2020-05-27 08:40:12 +01:00
Andy Green
2c46d3882f client: reset: detach wsi from buflist pending owner on reset 2020-05-27 08:40:12 +01:00
Andy Green
d7ac7f4deb unix domain: fix path name length
Unlike any other sockaddr variant it turns out when sockaddr_un reports its
sizeof() to connect() or listen(), it is trimmed to the used length of the
sun_path[] member not including any trailing 0x00.

Until now we worked fine, but our actual UDS paths have a large number of
trailing 0x00 (shown as @ in most tools).  Clients and servers can still
interoperate if they both have this broken name.

This patch fixes it to trim the sockaddr_un to the path length so the name
is as you would expect.
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
5623380803 libev: fix destroy path and example typo
https://github.com/warmcat/libwebsockets/issues/1913
2020-05-27 08:40:12 +01:00
Andy Green
b3576e7205 ss: make sure to use LWS_WRITE_HTTP_FINAL with SS EOM flag
When most of ss-h2 was combined into ss-h1 during development, the h2 difference
about needing HTTP_FINAL to signal h2 FIN flag was accidentally dropped.  In
many cases the peer can infer it, from, eg, content-length reached.  But we need
to replace explicitly doing it to cover all cases.
2020-05-27 08:40:12 +01:00
Sakthi Kannan
ee3b4a4b81 mqtt: avoid LRS_H1C_ISSUE_HANDSHAKE
Otherwise we can get the client connection stalling since H1C has no meaning on mqtt.
2020-05-27 08:40:12 +01:00
Andy Green
71f6f9a1f9 win: deal with FD_CONNECT better
POSIX connect() specifies it will signal POLLOUT available when
the connect result is available.  But windows has some non-posix
nonsense.

Improve the plat support to simulate the missing POLLOUT.
2020-05-27 08:40:12 +01:00
Andy Green
36ec353dac client: allow setting overall connect timeout from vh init
Add a member to the vh init struct allowing control of the overall
connection wait introduced in an earlier patch.  Set it to 20s
by default.


The timeout_secs member controls the individual DNS result
connect timeout and is reduced to 5s by default.
2020-05-26 17:05:39 +01:00
Andy Green
c97b68272c connect: enforce timeout for connect async wait
This patch allows client connections to recover from a nonresponsive
(ie, does not complete connect()) peer and continue to try subsequent
DNS results.
2020-05-11 21:21:01 +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
af26f0c765 lejp: correct return temp type to int
lejp_parse() return type is an int... but in the function, the temp
for it is a char.  This leads to badness that is currently worked
around by casting the return through a signed char type.

But that leads to more badness since if there's >127 bytes of buffer
left after the end of the JSON object, we misreport it.

Bite the bullet and fix the temp type, and fix up all the guys
who were working around it at the caller return casting to use the
resulting straight int.

If you are using this api, remove any casting you may have cut-
and-pasted like this

n = (int)(signed char)lejp_parse(...);

... to just be like this...

n = lejp_parse(...);
2020-05-11 15:17:14 +01:00
Kyle Greenwell
bebd3f71a6 h2: add prior knowledge support 2020-05-08 18:56:17 +01:00
Andy Green
c3a8387afd ss: support no tls in policy
If there's no trust store in use, create a default vhost so everything
can continue normally
2020-05-06 15:21:12 +01:00
Andy Green
43b83c333b client: allow setting keep warm time
Until now if the generic transaction completes and the connection is idle,
there's a fixed 5s grace period to keep the connection up in case something
else wants it.

This allows setting it in the client creation info struct .keep_warm_secs.
If left at 0, then it maintains the backward-compatible 5s wait.
2020-05-06 09:06:24 +01:00
Andy Green
641831b3c5 context: if linux and fd_limit_per_thread set try to configure by setrlimit 2020-05-06 09:06:24 +01:00
Jed Lu
f1f27562a0 ss: auth: lwa reacquire 2020-05-05 17:00:32 +01:00
Andy Green
401d6951da h2: client: do not apply host header if h2 negotiated by alpn
If client negotiated over alpn, it will have done SNI.  Some
peers like youtube.com reject with 400 if you sent a host: as
well.
2020-05-05 12:25:51 +01:00
Jed Lu
54e63cf75d ss auth: dont attempt auth if necessary blob unavailable 2020-05-05 06:36:50 +01:00
Andy Green
2cc0a7f6f6 ss: handle rx and tx return values properly
You can disconnect the stream by returning -1 from tx().  You can
give up your chance to send anything by returning 1 from tx().
Returning 0 sends `*len` amount of the provided buffer.

Returning <0 from rx() also disconnects the stream.
2020-05-05 06:36:39 +01:00
Andy Green
3d995cf7c5 fds: add sanity checks 2020-05-05 06:34:58 +01:00
Andy Green
2d3e62b112 h2: client sid: must be allocated at header send
There is no way to allocate a client wsi mux sid before the headers are
send, because we don't know the order in which new wsi headers will be sent
and so seen by the peer.

The peer inisists that sid indexes only increase... we cannot allocat sids
monotonically at the client and then send them disordered...
2020-05-05 06:34:48 +01:00
Andy Green
cced12822b lws_dir: add rm -rf and glob filter callbacks
Bring over two general-purpose callbacks for lws_dir from Sai
2020-05-03 14:16:48 +01:00
Andy Green
71e4b4118e strexp: reset out offset each time
A second strexp mustn't inherit the offset of the first, completed one
2020-05-03 14:16:48 +01:00
Andy Green
fa7c86951c lws_struct: blob
Add support for blob type in sqlite3... it's unusual in that it
is created into the table schema as a column of blob type, but is
not serialized or deserialized into or from JSON or sqlite.

Because the size of blobs is open-ended, accessing them in one
hit may not be possible, eg, exceed the size of available heap.
As binary, they would have to be base64-encoded in JSON
representation and that bloating may be excessive, with, eg,
a 500MB blob.  So while they can be defined using lws_struct
schema, and coexist inside a column of a table managed by
lws_struct, they must be read and written separately.
2020-05-03 13:04:15 +01:00
Steve Kyoungwon Kim
a9275d8dea BoringSSL: provide X509_VERYFY_PARAM_Set1_host length
X509_VERYFY_PARAM_Set1_host of openSSL allows the third argument, which
is the length of the hostname string, to be 0. Then, it assumes hostname
is a null-terminated C string. BoringSSL enforces the actual length to
be specified, and the hostname string should end with a null char.

Just provide the length, making both OpenSSL and BoringSSL happy.
2020-04-30 05:20:29 +01:00
Sakthi Kannan Ramabadran
abf3875d78 mqtt: some toolchains object to typedef
Use struct type instead of typedef to avoid it.
2020-04-27 19:45:32 +01:00
Andy Green
f2d5d4274b client: change default connect timeout to 30s 2020-04-26 06:34:00 +01:00