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

214 commits

Author SHA1 Message Date
Andy Green
b72ab32c17 lws_netdev 2020-07-02 10:36:31 +01:00
Andy Green
a75a476026 ah: use unk_pos to clean up unknown header starts even without CUSTOM_HEADERS 2020-06-27 07:57:22 +01:00
Andy Green
4948291b8b multipart: quote boundary
https://github.com/warmcat/libwebsockets/issues/1948
2020-06-16 19:45:35 +01:00
Andy Green
16cbbe2b40 mingw: update cross toolchain and add 32 and 64 default builds to sai 2020-06-03 09:36:20 +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
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
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
Andy Green
4ff9b4f96e ss: add api test with ctest integration
Tests via httpbin.org
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
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
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
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
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
Kyle Greenwell
bebd3f71a6 h2: add prior knowledge support 2020-05-08 18:56:17 +01:00
Andy Green
3d995cf7c5 fds: add sanity checks 2020-05-05 06:34:58 +01:00
Andy Green
beb49292d4 client: fix bad state after early tls connection
If we are slow and we can complete the tls connection quickly,
if we want to send a hs we must use H1C...HANDSHAKE2 now we
have the tls negotiation done.
2020-04-21 21:51:07 +01:00
Andy Green
a57e62d502 ctest: fixes-and-changes 2020-04-19 08:43:01 +01:00
Andy Green
6e4eac2b80 http: client multipart: caulate remaining length correctly
The current position is understood to be in *p, but for the remaining length
calculation we are wrongly comparing to p...
2020-04-17 12:39:53 +01:00
Andy Green
a8eebc47a5 smp: helgrind and sai lock fixes 2020-04-15 20:57:56 +01:00
Andy Green
eca75ee14d http: pipelining: fixes from xenial sai 2020-04-15 20:35:13 +01:00
Andy Green
5e99b9f3ee h2: take care to retain initial sid 2020-04-06 13:22:01 +01:00
Andy Green
a60cb84c9e captive portal
Implement Captive Portal detection support in lws, with the actual
detection happening in platform code hooked up by lws_system_ops_t.

Add an implementation using Secure Streams as well, if the policy
defines captive_portal_detect streamtype, a SS using that streamtype
is used to probe if it's behind a captive portal.
2020-03-11 12:44:01 +00:00
Olivier Langlois
b6824c88fd http: allow receiving body in case ws upgrade failed
Process HTTP headers related to content length for ws connections
and make 1 callback before continuing to the ws upgrade code.
This gives one last opportunity to ws protocols to inspect server reply
before the ws upgrade code discard it. ie: download reply body in case
of any other response code than 101.
2020-03-07 21:07:54 +00:00
Andy Green
eaab6e28b0 client: unify post tls accept handling 2020-03-07 20:03:58 +00:00
Andy Green
c25c37febd client: make sure all paths after connect go via tls if set 2020-03-04 12:17:49 +00:00
Andy Green
28ce32af64 client: secure streams
Secure Streams is an optional layer on top of lws that separates policy
like endpoint selection and tls cert validation into a device JSON
policy document.

Code that wants to open a client connection just specifies a streamtype name,
and no longer deals with details like the endpoint, the protocol (!) or anything
else other than payloads and optionally generic metadata; the JSON policy
contains all the details for each streamtype.  h1, h2, ws and mqtt client
connections are supported.

Logical secure streams outlive any particular connection and supports "nailed-up"
connectivity regardless of underlying connection stability.
2020-03-04 12:17:49 +00:00
Sakthi Kannan
9d099ba7be client: MQTT
Adds client support for MQTT QoS0 and QoS1, compatible with AWS IoT

Supports stream binding where independent client connections to the
same endpoint can mux on a single tcp + tls connection with topic
routing managed internally.
2020-03-04 12:17:49 +00:00
Andy Green
d88d41090e cleaning: windows 2020-03-04 12:17:49 +00:00
Andy Green
9a1f184915 rtos diet: http: remove headers at buildtime according to config
Headers related to ws or h2 are now elided if the ws or h2 role
is not enabled for build.  In addition, a new build-time option
LWS_WITH_HTTP_UNCOMMON_HEADERS on by default allows removal of
less-common http headers to shrink the parser footprint.

Minilex is adapted to produce 8 different versions of the lex
table, chosen at build-time according to which headers are
included in the build.

If you don't need the unusual headers, or aren't using h2 or ws,
this chops down the size of the ah and the rodata needed to hold
the parsing table from 87 strings / pointers to 49, and the
parsing table from 1177 to 696 bytes.
2020-03-04 11:00:04 +00:00
Andy Green
bb1a8d37fb rtos diet: make basic auth support a config option on by default
Remove wrapper content for < tls v1.2
2020-03-04 11:00:04 +00:00
Andy Green
ed04a266ea rtos diet: make raw_file role optional 2020-03-04 11:00:04 +00:00
Andy Green
a9b00f50ee socks5: add support to raw skt 2020-03-04 11:00:04 +00:00
Andy Green
6bb116b8d8 socks5: cleanup and add test options
Refactor SOCKS5 client support to be gathered into
lib/core-net/socks5-client.c and make that build
contingent on LWS_WITH_SOCKS5.
2020-03-01 08:14:44 +00:00
Andy Green
0dd23d7073 tls restriction: account for pipelining and add test 2020-03-01 08:14:43 +00:00
Dev Akira
f29838e4e1 client: http: add PUT to stream bindable methods 2020-02-21 17:32:41 +00:00
Andy Green
ac1229f2f7 minimal-http-client-multi: add POST
This adds support for POST in both h1 and h2 queues / stream binding.

The previous queueing tried to keep the "leader" wsi who made the
actual connection around and have it act on the transaction queue
tail if it had done its own thing.

This refactors it so instead, who is the "leader" moves down the
queue and the queued guys inherit the fd, SSL * and queue from the
old leader as they take over.

This lets them operate in their own wsi identity directly and gets
rid of all the "effective wsi" checks, which was applied incompletely
and getting out of hand considering the separate lws_mux checks for
h2 and other muxed protocols alongside it.

This change also allows one wsi at a time to own the transaction for
POST.  --post is added as an option to lws-minimal-http-client-multi
and 6 extra selftests with POST on h1/h2, pipelined or not and
staggered or not are added to the CI.
2020-02-21 17:32:41 +00:00
Andy Green
818a93fab4 clean 2020-02-21 17:32:41 +00:00
Zevv
b09b416b1d http client: add flag to disable redir follow 2020-02-04 14:16:18 +00:00
Andy Green
af391e62ba http client: pipelined child wsi should expose master ah on callbacks 2020-02-04 14:16:18 +00:00
Andy Green
270f2f48c8 lws_buflist_aware_read: restrict to incoming ebuf length if non-NULL ebuf.token incoming
(Includes fixes from Yichen Gu)

Currently the incoming ebuf is always replaced to point to either a whole
buflist segment, or up to the (pt_serv_buf - LWS_PRE) length in the pt_serv_buf.

This is called on path for handling http read... some user code reasonably wants to
restrict the read size to what it can handle.

Change the other lws_buflist_aware_read() callers to zero ebuf before calling, and for
those have it keep the current behaviour; but if non-NULL ebuf.token on incoming, as
in http read path case, restrict both reported len of buflist content and the read length
to the incoming ebuf.len so the user code can control what it will get at one time.

Additionally muxed protocol wsi have no choice but to read what was sent to them
since it's HOL-blocking for other streams and its own WINDOW_UPDATEs.  So add an
internal param to lws_buflist_aware_read() forcing read even if buflist content
is available.
2020-01-20 10:02:56 +00:00
Andy Green
b0b8a684ed event-ops: rename accept member to sock_accept
Some toolchains have lwip accept() as a preprocessor define...
2020-01-15 12:20:50 +00:00
Andy Green
157acfc906 windows: clean type warnings
There are some minor public api type improvements rather than cast everywhere
inside lws and user code to work around them... these changed from int to
size_t

 - lws_buflist_use_segment() return
 - lws_tokenize_t .len and .token_len
 - lws_tokenize_cstr() length
 - lws_get_peer_simple() namelen
 - lws_get_peer_simple_fd() namelen, int fd -> lws_sockfd_type fd
 - lws_write_numeric_address() len
 - lws_sa46_write_numeric_address() len

These changes are typically a NOP for user code
2020-01-11 14:04:50 +00:00
Andy Green
60d7daccd2 client: change all remaining AWAITING_TIMEOUT to use context timeout_secs
https://github.com/warmcat/libwebsockets/issues/1822
2020-01-10 13:37:19 +00:00
Andy Green
673f90d076 client: fix wrong tls disable 2020-01-10 11:52:50 +00:00
Andy Green
e9c8cee5d5 client: lws_client_reset option to keep ws
With this, ws connection to https://libwebsockets.org/redir-testserver (which redirects to
https://libwebsockets.org/testserver) can work OK.

https://github.com/warmcat/libwebsockets/issues/1820
2020-01-10 11:49:49 +00:00
Andy Green
bc0ab4b656 http server: favour redirect over ws upgrade 2020-01-10 11:03:00 +00:00
Christian Thießen
6555d4d51c http client: Fix overwite of addrlen for connect if binding to iface
The addrlen argument to connect() was overwritten by the
lws_socket_bind() result, which is a port number.
Fixes https://github.com/warmcat/libwebsockets/issues/1817
2020-01-10 05:55:25 +00:00