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

3419 commits

Author SHA1 Message Date
Andy Green
ec9e8ab892 mbedtls: only free crt_parse when something came back
Mbedtls mbedtls_x509_crt_parse() returns 0 for success which is good.
But it has a complicated idea about what to return on fail... if it
couldn't make even one cert from the data, then it returns a negative
return indicating the parsing problem and there is nothing to free.

If it managed to parse at least one cert, instead it retuns a positive
number indicating the number of certs it didn't parse successfully,
and there is something to free.

Adapt the code to understand this quirk.
2020-07-09 14:11:46 +01:00
Andy Green
05fdf38750 coverity: force amount to 0 before read call 2020-07-08 18:28:11 +01:00
Andy Green
c4327e7f8e ss: reset retry count for explicit connection request
This differentiates between client connections for retry / writeable requests
and explicit lws_ss_client_connect() api calls.  The former effectively uses
retry / backoff, and the latter resets the retry / backoff.

If you receive ALL_RETRIES_FAILED due to the retry policy, you can do whatever
you need to do there and call lws_ss_client_connect() to try to connect again
with a fresh, reset retry / backoff state.
2020-06-26 11:33:46 +01:00
Andy Green
c9e698ab02 client: suppress CONNECTION_ERROR if still in client_connect_via_info
If the client connection attempt fails early, we report it will a NULL
return from the client connection api.  If it fails later, perhaps after
more times around the event loop, we report it as a CONNECTION_ERROR.

This patch makes sure we don't do CONNECTION_ERROR flow if in fact we
are still in the client_connect_via_info() and in a position to report
the failure by returning NULL from there, without it under some
conditions we will do both a CONNECTION_ERROR and return NULL.
2020-06-26 10:03:19 +01:00
Andy Green
d452cbea80 ah: use unk_pos to clean up unknown header starts even without CUSTOM_HEADERS 2020-06-26 07:38:28 +01:00
dev31337
1287e5757f lejp: enable negative integers
https://github.com/warmcat/libwebsockets/issues/1957
2020-06-20 17:23:40 +01:00
Andy Green
c09386cfee context_destroy: backport event-lib fixes from master 2020-06-19 20:34:38 +01:00
Andy Green
c930daeaa0 libevent: enforce no event state duplication
https://github.com/warmcat/libwebsockets/issues/1956
2020-06-19 19:56:58 +01:00
Jed Lu
44ead6a42c ss: http: if not retrying move to idle state 2020-06-19 19:22:37 +01:00
Andy Green
9b24e29b9a multipart: quote boundary
https://github.com/warmcat/libwebsockets/issues/1948
2020-06-12 07:26:24 +01:00
Andy Green
7840d455bb clean: additional-lws_intptr_t 2020-06-03 10:37:59 +01:00
Andy Green
d2b3bed3c9 clean: use lws_intptr_t where needed 2020-06-03 06:49:45 +01:00
Jed Lu
685d9cb690 ss: http: allow rideshare to gate EOM
When rideshare is in use, the scope of the EOM is the rideshare section.
2020-06-01 16:17:06 +01:00
Jed Lu
f1f7512e8d ss: Support content-length on PUT as well as PUSH 2020-05-27 14:00:52 +01:00
Andy Green
c47096c20b ss: add api test with ctest integration
Tests via httpbin.org
2020-05-25 13:22:51 +01:00
dev31337
10d59608c0 PEER_LIMITS: make sure to close socketfd on deny 2020-05-24 17:15:56 +01:00
dev31337
7d73c3341c listen: handle denied FILTER_NETWORK_CONNECTION correctly 2020-05-24 14:17:04 +01:00
Andy Green
36bcae17ab 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-19 18:37:53 +01:00
Andy Green
073a59264a 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-15 18:25:12 +01:00
Andy Green
2ad2316d32 libev: fix destroy path and example typo
https://github.com/warmcat/libwebsockets/issues/1913
2020-05-12 19:33:02 +01:00
Andy Green
2a5b54d0a6 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-11 15:11:11 +01:00
Sakthi Kannan
da38af3b2d mqtt: avoid LRS_H1C_ISSUE_HANDSHAKE
Otherwise we can get the client connection stalling since H1C has no meaning on mqtt.
2020-05-11 14:52:31 +01:00
Andy Green
8221450b20 ss: support no tls in policy 2020-05-06 15:27:59 +01:00
Andy Green
8021ab54f0 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:48:08 +01:00
Jed Lu
70ba29d568 ss auth: dont attempt auth if necessary blob unavailable 2020-05-04 17:03:08 +01:00
Andy Green
51ad2f2d9e 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-04 14:37:37 +01:00
Andy Green
85dc0883a2 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-04 14:36:39 +01:00
Andy Green
a59aaf6af9 strexp: reset out offset each time
A second strexp mustn't inherit the offset of the first, completed one
2020-04-30 20:32:30 +01:00
Steve Kyoungwon Kim
5dd57715dd 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:23:12 +01:00
Andy Green
59fb0988a6 v4.0.2 2020-04-29 11:34:05 +01:00
Sakthi Kannan Ramabadran
af9b4d0c66 mqtt: some toolchains object to typedef
Use struct type instead of typedef to avoid it.
2020-04-27 19:46:13 +01:00
huangkaicheng
d179acd62d cmake: remove unicode quote from lws_config_private template
Apparently some toolchains / platforms / locales don't handle UTF-8 well
2020-04-27 14:02:31 +01:00
Adam Duskett
182b5121d0 dhcpclient: Fix unused-variable error in release
dhcp_entry_names is only used when _DEBUG is defined, so wrap the array in

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
2020-04-23 20:04:01 +01:00
Andy Green
4e68e3b4bc logs: allow giving log bitfields from cmake to force build or exclusion
By default this doesn't change any existing logging behaviour at all.

But it allows you to define cmake options to force or force-disable the
build of individual log levels using new cmake option bitfields
LWS_LOGGING_BITFIELD_SET and LWS_LOGGING_BITFIELD_CLEAR.

Eg, -DLWS_LOGGING_BITFIELD_SET="(LLL_INFO)" can force INFO log level
built even in release mode.  -DLWS_LOGGING_BITFIELD_CLEAR="(LLL_NOTICE)"
will likewise remove NOTICE logging from the build regardless of
DEBUG or RELEASE mode.
2020-04-23 06:36:54 +01:00
huangkaicheng
e7b3cd7ec1 iOS: detect and avoid net/route.h
LWS builds OK on iOS SDK as unix type plat, except it
doesn't have net/route.h.

Detect we're building on iOS at CMake and export a
preprocessor define we can use to snip out the missing
include.
2020-04-23 06:22:00 +01:00
Valentin B
3a6ce18feb CMake: Silence CMP0048 warnings
When libwebsockets is included as a subdirectory in other projects that rely on a minimum CMake version of 3.x, a CMP0048 policy warning will be raised due to the project not specifying a version in the project call.

This patch silences the warning by explicitly setting the policy within libwebsockets to NEW if it has already been forwarded as such, without any further impact on the behavior of CMake.
2020-04-21 08:36:22 +01:00
Octavia93
dc3a1123fc alloc.c: add license header
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Is this file also licensed under MIT license, I don’t see a license header like the other files in this repo?
2020-04-13 16:17:30 +01:00
Andy Green
4114b610aa glib: remove unused watcher to align with master 2020-04-12 14:59:25 +01:00
Andy Green
d13f0444f3 lws_struct: sqlite3: avoid chown for windows 2020-04-11 16:56:13 +01:00
Andy Green
71a7064c19 async dns: test app: dont use exp as ambiguous 2020-04-11 16:50:53 +01:00
Andy Green
0824f77142 windows: async dns: fix typo 2020-04-10 16:44:51 +01:00
Andy Green
a147fb81dc windows: ipv6 compile fix
Via turtiain

https://github.com/warmcat/libwebsockets/issues/1880
2020-04-07 10:17:48 +01:00
Jaco Kroon
a9caff5b37 vhost: Fix unused var warning with some SOCKS5
after 6bb116b8d8 the variable p could be
declared without being used.

https://bugs.gentoo.org/716386 refers.

This just fixes that.
2020-04-06 17:40:40 +01:00
Andy Green
705d957ca2 ss: avs test: disable rate limiting
Rate limiting does not work correctly with VS server, the last
block of rx data is not coming.  Disable it for now so the
returned data comes as rapidly as the server can send and the
client receive.
2020-04-06 14:22:41 +01:00
Andy Green
b1d2bdbe20 h2: take care to retain initial sid 2020-04-06 14:08:01 +01:00
Andy Green
092e8f6614 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:09:49 +00:00
Karl Rupp
bb439e766a 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 21:03:54 +00:00
Akira Tsukamoto
b00e6949e6 jws: lws_gencrypto_jws_alg_to_definition needs sentinel
Otherwise segfault when end of array reached.
2020-03-21 07:01:58 +00:00
Andy Green
6247f5ea79 wolfssl: build fixes 2020-03-20 09:38:17 +00:00
Andy Green
77a1b4e058 lws_set_wsi_user: allow setting to override existing internal allocation 2020-03-19 17:03:11 +00:00