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

651 commits

Author SHA1 Message Date
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
Andy Green
8a7e0edb7d lws_spawn_piped: break out from cgi
The vfork optimized spawn, stdxxx and terminal handling in the cgi
implementation is quite mature and sophisticated, and useful for
other things unrelated to cgi.  Break it out into its own public
api under LWS_WITH_SPAWN, off by default.

Expand it so the parent wsi is optional, and the role and protocol
bindings for stdxxx pipes can be set.  Allow optional sul timeout
and external lws_dll2 owner for extant children.

Remove inline style from minimal http-server-cgi
2020-02-21 17:32:41 +00:00
Andy Green
e9fd43e041 raw file: drain POLLIN before handling close as needed for pipes 2020-02-21 17:32:41 +00:00
Andy Green
f38a0d598c ws role: remove SO_SNDBUF 2020-02-21 17:32:41 +00:00
Oliver Langlois
a404f5e95a unix plat: use eventfd in place of pipe where possible
From eventfd man page:
Applications can use an eventfd file descriptor instead of a pipe (see
pipe(2)) in all cases where a pipe is used simply to signal events.
The kernel overhead of an eventfd file descriptor is much lower than
that of a pipe, and only one file descriptor is required
(versus the two required for a pipe).
2020-02-21 17:32:41 +00:00
Andy Green
af2f1f9a87 event-lib-glib
Adds support for glib event library.
2020-02-21 17:32:41 +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
Andy Green
271ca836c8 event lib: update http client multi to work with it and clean destroy flow
Add selectable event lib support to minimal-http-client-multi and
clean up context destroy flow so we can use lws_destroy_context() from
inside the callback to indicate we want to end the event loop, without
using the traditional "interrupted" flag and in a way that works no
matter which event loop backend is being used.
2020-02-04 14:16:18 +00:00
Zevv
b09b416b1d http client: add flag to disable redir follow 2020-02-04 14:16:18 +00:00
Zevv
e6f3aafe13 http client: allow HEAD method at h1 client bind 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
774240f73b linkit: support build using public sdk
This provides support to build lws using the linkit 7697 public SDK
from here https://docs.labs.mediatek.com/resource/mt7687-mt7697/en/downloads

This toolchain has some challenges, its int32_t / uint32_t are long,
so assumptions about format strings for those being %u / %d / %x all
break.  This fixes all the cases for the features enabled by the
default cmake settings.
2020-01-17 07:45:34 +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
6f2230a993 role structs to const
Indicate these are immutable (they're already treated as
such) and can go in .rodata
2020-01-15 06:31:19 +00:00
Andy Green
5055096e47 clean: codacy 2020-01-14 10:06:26 +00:00
Andy Green
0995c27f50 coverity: fixes plugin error path leak and logging method sign check
Broadened the checking config to

cmake .. -DCMAKE_BUILD_TYPE=DEBUG \
         -DLWS_WITH_SYS_ASYNC_DNS=1 \
         -DLWS_WITH_SYS_NTPCLIENT=1 \
         -DLWS_WITH_SYS_DHCP_CLIENT=1 \
         -DLWS_WITH_GENCRYPTO=1 \
         -DLWS_WITH_DETAILED_LATENCY=1 \
         -DLWS_IPV6=1 \
         -DLWS_WITH_FTS=1 \
         -DLWS_WITH_LWSWS=1 \
         -DLWS_UNIX_SOCK=1 \
         -DLWS_WITH_HTTP_PROXY=1 \
         -DLWS_WITH_MINIMAL_EXAMPLES=1
2020-01-14 08:23:25 +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
Andy Green
db15061e87 ah: simple_create an empty string removes header entry
Length is zero either way

https://github.com/warmcat/libwebsockets/issues/1820
2020-01-10 10:05:35 +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
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +00:00
Andy Green
7dcb4eeaa6 reverse-proxy: allow proxying rfc8441 ws CONNECT
Take the opportunity to provide public method index constants
2020-01-05 22:17:58 +00:00
Andy Green
2b456e734a client: make sure h2 direct mux get ESTABLISHED_CLIENT_HTTP 2020-01-05 22:17:58 +00:00
Andy Green
9cb4f25476 h2: LCCSCF_H2_MANUAL_RXFLOW and refactor txcr
This changes the approach of tx credit management to set the
initial stream tx credit window to zero.  This is the only way
with RFC7540 to gain the ability to selectively precisely rx
flow control incoming streams.

At the time the headers are sent, a WINDOW_UPDATE is sent with
the initial tx credit towards us for that specific stream.  By
default, this acts as before with a 256KB window added for both
the stream and the nwsi, and additional window management sent
as stuff is received.

It's now also possible to set a member in the client info
struct and a new option LCCSCF_H2_MANUAL_RXFLOW to precisely
manage both the initial tx credit for a specific stream and
the ongoing rate limit by meting out further tx credit
manually.

Add another minimal example http-client-h2-rxflow demonstrating how
to force a connection's peer's initial budget to transmit to us
and control it during the connection lifetime to restrict the amount
of incoming data we have to buffer.
2020-01-02 08:31:02 +00:00
Andy Green
22a6a0073d safari: update default CSP to specify ws and wss schema
https://github.com/warmcat/libwebsockets/issues/1806
2019-12-29 19:59:16 +00:00
Andy Green
7221bc57b5 mux children: generalize helpers out of h2 implementation
This should be a NOP for h2 support and only affects internal
apis.  But it lets us reuse the working and reliable h2 mux
arrangements directly in other protocols later, and share code
so building for h2 + new protocols can take advantage of common
mux child handling struct and code.

Break out common mux handling struct into its own type.

Convert all uses of members that used to be in wsi->h2 to wsi->mux

Audit all references to the members and break out generic helpers
for anything that is useful for other mux-capable protocols to
reuse wsi->mux related features.
2019-12-29 19:59:16 +00:00
Andy Green
1eb4d335d2 active_conns: move out dependency on ah 2019-12-23 09:25:56 +00:00
Andy Green
36de0ada7d http client basic auth add helper and example 2019-12-22 18:17:45 +00:00
Andy Green
c4ab815aaf _GNU_SOURCE: only define if not already defined
https://github.com/warmcat/libwebsockets/issues/1803
2019-12-22 18:17:45 +00:00
Andy Green
d911bce379 spa: report 0-length FINAL_CONTENT
https://github.com/warmcat/libwebsockets/issues/1468

Just always report FINAL_CONTENT at the end, a zero length one
is okay.
2019-12-22 18:17:45 +00:00
Andy Green
c21f2dbe46 lextable: fix x-forwarded-for
https://github.com/warmcat/libwebsockets/issues/1801
2019-12-20 18:42:29 +00:00
Dane
10290048b0 basic auth: add callback option
Allow an http mount to specify it wants to check Basic Auth
requests via a protocol callback instead of a text file.
2019-12-14 23:55:28 +00:00
Andy Green
392dfe186b LWS_ERRNO: audit uses for case logging may destroy errno
On some platforms, it's possible that logging flow may reset errno.  In the case where
we try to log errno on those platforms and afterwards try to query it, we will get a
nasty surprise that the logged errno is destroyed by the time we come to test it.

In the two cases of this in the tree at the moment, sample errno into a temp and
log and test the temp.

Thanks to Sakthi Ramabadran for finding this.
2019-12-14 23:55:28 +00:00
Andy Green
68de449093 raw: client: make sure we get CONNECT and opaque_user_data before RX 2019-12-02 11:19:32 +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
74712ea4f5 socks5: fix compile breakage
https://github.com/warmcat/libwebsockets/issues/1777
2019-11-27 19:19:48 +00:00
Andy Green
9d93677d7d ws pmd: deflatePending only has meaning during deflate
https://github.com/warmcat/libwebsockets/issues/1768
2019-11-23 07:44:05 +00:00