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

363 commits

Author SHA1 Message Date
Dmitry Potapov
17bd1d0787 vhost: remove from defer binding on destroy
If a vhost is removed, it should remove references to it from the
defer binding list to avoid dangling pointers, which can crash the
application.
2022-08-17 08:59:18 +01:00
Andy Green
599adff99d sort-dns: fix scope comparison
https://github.com/warmcat/libwebsockets/issues/2537
2022-01-17 03:57:06 +00:00
Andy Green
0111d95d6b cmake: unbreak LWS_WITH_SYS_STATE disabled build 2021-09-27 06:37:25 +01:00
Yucong Sun
457ec95d0c asyncdns: provide correct length with CCE 2021-09-18 03:59:51 +01:00
Andy Green
b5ae1e3b5a conmon: async-dns: off-by-one 2021-09-14 05:59:16 +01:00
Andy Green
4dedd6f583 h2: make has_buffered_out check nwsi 2021-09-13 17:30:32 +01:00
Andy Green
9c20d32d33 validity: take context and pt lock before close 2021-08-27 13:13:41 +01:00
Andy Green
40db9f9f19 server: http-proxy: fix POST 2021-08-14 05:01:20 +01:00
Andy Green
6435bfe309 iface: score binds 2021-07-20 10:30:58 +01:00
Andy Green
e90f005a10 vhost: listen: protect listen port transfer between
...vhosts from vh destroy on zero refcount

https://github.com/warmcat/libwebsockets/issues/2343
2021-07-12 09:29:23 +01:00
Andy Green
a310e16f8f socks5: cast for mingw3 nonposix recv args 2021-07-10 08:28:06 +01:00
Bing Zhao
ff1b8ed0c9 tls: fix inbalanced tls restrict borrow/return calls
lws_tls_restrict_borrow() returns error when tls restriction limit is
reached. However lws_ssl_close() still calls lws_tls_restrict_return()
to decrease simultaneous_ssl. Thus LWS accepts more than allowed ssl
links, making simultaneous_ssl_restriction useless.

Fix it by tracking lws_tls_restrict_borrow() return value and only
calling lws_tls_restrict_return() if lws_tls_restrict_borrow() is
successful.
2021-07-07 08:47:37 +01:00
Andy Green
ad3901d0fe raw-proxy: fix role bind flag 2021-07-07 08:46:14 +01:00
Andy Green
eeea000ced dns: handle EAI_NONAME as fatal
This causes the blocking dns lookup to treat EAI_NONAME as immediately
fatal, this is usually caused by an assertive NXDOMAIN from the DNS server
or similar.

Not being able to reach the server should continue to retry.

In order to make the problem visible, it reports the situation using
CLIENT_CONNECTION_ERROR, even though it is still inside the outer client
creation call.
2021-07-07 08:43:56 +01:00
Andy Green
fa1a704046 sspc: close: differentiate between ss and sspc at final wsi close
A second chunk of ss / sspc handling did not get cleaned up
along with the other patch from a few weeks ago, it wrongly
treats sspc the same as ss.  This can cause the wrong thing
to be zeroed down, 64-bit and 32-bit builds end up with
different victims.

This patch makes it understand the difference and treat them
accordingly, same as the main for_ss handling.
2021-06-27 09:05:45 +01:00
Andy Green
ea4d800809 service: fix casts for EXTERNAL_POLL 2021-06-24 16:21:56 +01:00
Andy Green
e3da2a3b3b android: getnameinfo uses nonstandard size_t 2021-06-20 13:41:53 +01:00
Mykola Stryebkov
7c3c179e0e win32: client: just do WIN32 check 2021-06-20 07:21:31 +01:00
Andy Green
0ba8df6eb4 threadpool: disassociate wsi on close 2021-06-20 07:20:32 +01:00
DUOLabs333
aa090fc287 cygwin: include in unix type socket init 2021-06-17 14:19:40 +01:00
Khem Raj
014aa77ed3 core-net: Remove unused variable
variable 'n' is being set but it is not used anywhere, latest clang is
able to detect this and flags it

Fixes

lib/core-net/route.c:41:6: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
|         int n = 0;
|             ^
2021-06-06 11:47:52 +01:00
Jed Lu
4b6a7982b6 ss: do not restrict close handling to WITH_SERVER 2021-05-27 17:13:26 +01:00
Andy Green
531f998cf8 smp: fix client tsi detection 2021-05-20 14:07:25 +01:00
Andy Green
9cd1f4d78b listen: ip bind: force ipv4 if given ipv4 numeric iface 2021-05-20 14:06:39 +01:00
Jed Lu
0a71e0716c cpd: remove scheduled recheck on dns fail 2021-05-20 14:06:29 +01:00
Catalin
2fac32543a tls-sessions: Use OpenSSL API to test if a session was reused 2021-04-27 15:43:36 +01:00
Jin Wang
c3b1254747 client: make sure we get CCE if timeout on server reply
If facing a captive portal, we may seem to get a tcp level connection okay
but find that communication is silently dropped, leading to us timing out
in LRS_WAITING_SERVER_REPLY.

If so, we need to handle it as a connection fail in order to satisfy at
least Captive Portal detection.
2021-04-17 05:43:35 +01:00
Andy Green
24abd699f6 http: parser: straighten out %00 legality
https://github.com/warmcat/libwebsockets/issues/2262

This adds a README explaining what can be expected if your URLs contain
%00, and adds a safe helper for urlargs-by-name that is length-based.

Contains fix for extra NUL on some headers

https://github.com/warmcat/libwebsockets/issues/2267
2021-04-10 09:21:33 +01:00
Andy Green
b28b03eee1 smp: hold pt lock for lws_client_reset removing fds
https://github.com/warmcat/libwebsockets/issues/2268
2021-04-10 06:14:12 +01:00
Andy Green
42dc817d8f ss: proxy: get rx flow control working
This fixes the proxy rx flow by adding an lws_dsh helper to hide the
off-by-one in the "kind" array (kind 0 is reserved for tracking the
unallocated dsh blocks).

For testing, it adds a --blob option on minimal-secure-streams[-client]
which uses a streamtype "bulkproxflow" from here

https://warmcat.com/policy/minimal-proxy-v4.2-v2.json

		"bulkproxflow": {
			"endpoint": "warmcat.com",
			"port": 443,
			"protocol": "h1",
			"http_method": "GET",
			"http_url": "blob.bin",
			"proxy_buflen": 32768,
			"proxy_buflen_rxflow_on_above": 24576,
			"proxy_buflen_rxflow_off_below": 8192,
			"tls": true,
			"retry": "default",
			"tls_trust_store": "le_via_dst"
		}

This downloads a 51MB blob of random data with the SHA256sum

ed5720c16830810e5829dfb9b66c96b2e24efc4f93aa5e38c7ff4150d31cfbbf

The minimal-secure-streams --blob example client delays the download by
50ms every 10KiB it sees to force rx flow usage at the proxy.

It downloads the whole thing and checks the SHA256 is as expected.

Logs about rxflow status are available at LLL_INFO log level.
2021-04-07 15:54:26 +01:00
Mykola Stryebkov
0d06d4bad2 windows: work well with vcpkg pthreads 2021-04-05 10:55:04 +01:00
Andy Green
7f8e2edc3d windows: cancel pipe is in pts not context 2021-04-05 10:55:04 +01:00
Andy Green
7d8f742594 smp: more lock assertions 2021-04-05 10:55:04 +01:00
Andy Green
b582dd49fb client: add CONNECTING protocol cb 2021-04-05 10:55:04 +01:00
Andy Green
d291c02a23 ss: sspc: add conmon performance telemetry
This provides a way to get ahold of LWS_WITH_CONMON telemetry from Secure
Streams, it works the same with direct onward connections or via the proxy.

You can mark streamtypes with a "perf": true policy attribute... this
causes the onward connections on those streamtypes to collect information
about the connection performance, and the unsorted DNS results.

Streams with that policy attribute receive extra data in their rx callback,
with the LWSSS_FLAG_PERF_JSON flag set on it, containing JSON describing the
performance of the onward connection taken from CONMON data, in a JSON
representation.  Streams without the "perf" attribute set never receive
this extra rx.

The received JSON is based on the CONMON struct info and looks like

{"peer":"46.105.127.147","dns_us":596,"sockconn_us":31382,"tls_us":28180,"txn_resp_us:23015,"dns":["2001:41d0:2:ee93::1","46.105.127.147"]}

A new minimal example minimal-secure-streams-perf is added that collects
this data on an HTTP GET from warmcat.com, and is built with a -client
version as well if LWS_WITH_SECURE_STREAMS_PROXY_API is set, that operates
via the ss proxy and produces the same result at the client.
2021-04-05 10:55:04 +01:00
Andy Green
51490ae6e6 Fault injection
add lws_xos: xoshiro256 PRNG
2021-04-05 10:55:04 +01:00
Catalin
d5753b6298 tls: openssl-only: client-only: session caching 2021-04-04 05:34:11 +01:00
Bram Peeters
3ff6a9d462 vhost: dont log null origin 2021-04-02 16:50:49 +01:00
Andy Green
e2f42387b7 route: assert if route table becomes full 2021-04-02 16:50:49 +01:00
Andy Green
6c4a127310 active_conns: simplify h1 exclusion rule 2021-03-29 19:36:26 +01:00
Andy Green
51790705a0 unix_skt: handle 0 length read as close
This was commented during the metrics patch for some reason...
commenting it breaks UDS -> web serving proxying.

Uncomment it and see what the other problem is..
2021-03-25 08:40:52 +00:00
Andy Green
06509e287d lws_conmon: connection monitoring and stats generation
This provides a build option LWS_WITH_CONMON that lets user code recover
detailed connection stats on client connections with the LCCSCF_CONMON
flag.

In addition to latencies for dns, socket connection, tls and first protocol
response where possible, it also provides the user code an unfiltered list
of DNS responses that the client received, and the peer it actually
succeded to connect to.
2021-03-17 07:31:49 +00:00
Andy Green
1000a52df3 logs: prioritize WITH_NO_LOGS even in release
Really not having any logs makes it difficult to know what is really
happening, but if that's you're thing this will align debug and release
modes to just have ERR and USER if you give WITH_NO_LOGS
2021-03-15 12:56:15 +00:00
Andy Green
a7f7053591 connect2: log dereferences things that may have been destroyed
It's perfectly possible we will have destroyed the wsi and report that
back in the return code.  So let's not dumbly defreference the wsi to
make a log inbetweentimes.

Found with fault injection and valgrind.
2021-03-11 06:59:03 +00:00
Andy Green
9528acb4b8 connect: erase previous unusability when retrying connect
In the case that we try ipv6 that isn't routable, we get a POLLHUP, that
marks the wsi as unusable (for writes, not pending reads), that's what
we want.

But in the case we go around and retry other dns results that are
routable, we have to clear the wsi unusable flag.  Otherwise we will
connect and find that we can't write on the connection...
2021-03-11 06:59:03 +00:00
Andy Green
9d13b97e37 client: DNS failure should retry while waiting for connect timeout
If the DNS lookup fails, we just sit out the remaining connect time.

The adapts it to reuse the wsi->sul_connect_timeout to schedule DNS lookup
retries until we're out of time.

Eventually we want to try other things as well, this is aligned with that.

Found with fault injection.
2021-03-11 06:58:59 +00:00
Andy Green
3f4623bb36 lws_metrics
There are a few build options that are trying to keep and report
various statistics

 - DETAILED_LATENCY
 - SERVER_STATUS
 - WITH_STATS

remove all those and establish a generic rplacement, lws_metrics.

lws_metrics makes its stats available via an lws_system ops function
pointer that the user code can set.

Openmetrics export is supported, for, eg, prometheus scraping.
2021-03-08 21:47:28 +00:00
Andy Green
f9c3d432a8 netlink: migrate to context
For SMP case, it was desirable to have a netlink listener per pt so they
could deal with pt-level changes in the pt's local service thread.  But
Linux restricts the process to just one netlink listener.

We worked around it by only listening on pt[0], this aligns us a bit more
with the reality and moves to a single routing table in the context.
There's still more to do for SMP case locking.
2021-03-08 20:43:19 +00:00
Andy Green
cb5c0059a3 sai-resource 2021-02-24 08:56:27 +00:00
Andy Green
b47511352e async-dns: 2021-02-20 13:54:38 +00:00