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

571 commits

Author SHA1 Message Date
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
d339505f51 h2: cmake: build with NO_SERVER 2020-04-16 06:59:45 +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
ee9ab7c1fc fanalyzer: workarounds and fixes
GCC -fanalyzer did find a real issue (unchecked malloc return)
but it mainly reported things that weren't true due to what
was happening outside of the particular compilation unit that
it could see.
2020-03-27 19:16:06 +00:00
Andy Green
2f6e0ed10b h1: handle LRS_FLUSHING_BEFORE_CLOSE at ops read
read has a tight leash on the states it's happy to turn up there,
it's good to be like that but it turns out LRS_FLUSHING_BEFORE_CLOSE
should be whitelisted since it can happen under some transient
conditions and is valid.

https://github.com/warmcat/libwebsockets/issues/1872
2020-03-26 18:07:48 +00:00
Karl Rupp
6440521992 http server: Using default filename also for subdirectories.
If a user sets a default filename for a http mount (.def in lws_http_mount),
eg. 'default.html', then a GET request for '/' correctly forwards to
 '/default.html'.
However, without this commit the default filename is not taken into account for subdirectories. Thus,
 GET subdir/
will forward to
 'subdir/index.html'
instead of the expected
 'subdir/default.html'

This commit changes the behavior such that the user-provided default filename is also used for subdirectories.
2020-03-23 10:53:10 +00:00
Andy Green
8adcdbb189 lws_spa: avoid reading past table
Didn't check the lenghts of the NUL-terminated header
table properly.

https://github.com/warmcat/libwebsockets/issues/1859
2020-03-15 06:19:17 +00: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
Andy Green
5b9fe01863 build: release mode compile fixes 2020-03-10 06:45:24 +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
61cd344c13 minilex: fix ROLE_WS=0 case 2020-03-06 15:22:36 +00:00
Andy Green
7efe93bb34 fallback: dont check after first ssl accept attempt 2020-03-06 10:18:43 +00:00
Andy Green
1c6735e1a0 mux: disable already optimization
This leads to problems at the moment with sticky mux.requested_POLLOUT
causing writeable to not be sent.

Remove it and always set writeable on parents for now.
2020-03-06 07:55:05 +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
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