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

163 commits

Author SHA1 Message Date
oaleshina
c6cd4150c1 h2: ping pong: separate payloads 2021-09-13 17:31:02 +01:00
Andy Green
2ea2c37f9d h2: data: frame header already parsed out 2021-08-13 05:45:51 +01:00
Andy Green
2f9ed48d93 coverity: report problem in hpack_dynamic_size() to parent 2021-06-06 11:47:09 +01:00
Andy Green
edcf346f9f h2: migration: migrate for_ss
The attribute indicating that a wsi belongs to an SS object also must be
migrated when we split out the original transaction wsi into a new nwsi, if we're
not going to lose track of its affiliation.

Likewise if the affiliated SS object points to the original wsi, we have to
migrate his pointer when we migrate the wsi.

Taking care of this book-keeping is necessary to get correct behaviours at
close-time.
2021-05-20 14:07:01 +01:00
Andy Green
354b29c747 http: redirect: dont try from h2 at the moment
h1->h1, h1->h2 are OK, but h2->anything needs more work.
Just fail it early at the moment.
2021-04-10 09:20:33 +01:00
Andy Green
7d8f742594 smp: more lock assertions 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
Andy Green
ffb49e2612 http: post: defer body pending end until no more buffered out 2021-03-25 08:40:52 +00:00
Andy Green
50e1f1ed13 h2: dont try to get ahead of POST if its a cgi mount or proxied 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
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
ede7f8b0f3 ss: support huge urls 2021-03-05 14:13:26 +00:00
Andy Green
09b9ac6e33 minimal-http-client: set option to fix broken server window update 2021-02-28 12:10:26 +00:00
Andy Green
f42c97baa9 route: on change also check source address still extant 2021-02-17 11:39:12 +00:00
Andy Green
611e6477fd h2: post: handle lws_h2_bind_for_post_before_action error 2021-02-01 19:12:54 +00:00
Andy Green
d73c4baab2 options: fixes
sai: add default-noudp and windows plats for noserver
2021-02-01 15:19:38 +00:00
Yichen Gu
403a6591e1 h2: client: handle END_STREAM and END_HEADERS togther on all paths 2021-01-29 21:22:35 +00:00
Andy Green
1236114303 h2: client: action END_STREAM and END_HEADERS immediately 2021-01-23 20:58:39 +00:00
Andy Green
bf9c517b39 set-cookie: force semicolon for concatenation 2021-01-22 12:25:03 +00:00
Andy Green
95a545b741 evlib: count extant evlib handles instead of wsi 2021-01-19 17:07:33 +00:00
Andy Green
46c925e3b7 h2: post: adapt in on _HTTP to be after mountpoint 2021-01-18 19:49:04 +00:00
Andy Green
e5b191be35 h2: post buflist: track rx_content_length
On h2 server POST, there's a race to see if the POST body is going to be
received coalesced with the headers.

The problem is on h2, we can't action the stream http request or body until
the stream is writeable, since we may start issuing the response right away;
there's already DEFERRING_ACTION state to manage this.  And indeed, the
coalesced, not-immediately-actionable POST body is buflisted properly.

However when we come to action the POST using buflisted data, we don't follow
the same pattern as dealing with the incoming data immediately.

This patch aligns the pattern dumping the buflist content to track
expected rx_content_length and handle BODY_COMPLETION if we got to
the end of it, along with removal from the pt list of wsi with pending
buflists if we used it up.
2021-01-18 19:49:02 +00:00
Andy Green
9be508bdd7 h2: make sure we see END_STREAM with END_HEADERS on client 2021-01-15 19:54:14 +00:00
Andy Green
abc60c755a smd: add more scenarios to tests
Let's have 4 x forked clients all intercommunicate via the SS proxy,
and add it to ctest.
2021-01-05 10:56:38 +00:00
Andy Green
c48bebc9ae h2: post: http_action: issue _HTTP and consume deferred body when resuming
When we have to defer http_action for a stream because we may not have
any writeability, we stash any incoming body on the rx buflist for the wsi
which is good.

But when we resume under some conditions, we don't issue the _HTTP cb and
don't drain the stashed body.  It's cleaned out in the close flow, but it's
broken.

This makes the deferred resume flow do the right thing under those conditions.
2021-01-05 10:56:38 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
0ceba15d9c lws_lifecycle
This adds some new objects and helpers for keeping and logging
info on grouped allocations, a group is, eg, SS handles or client
wsis.

Allocated objects get a context-unique "tag" string intended to replace
%p / wsi pointers etc.  Pointers quickly become confusing when
allocations are freed and reused, the tag string won't repeat
until you produce 2^64 objects in a context.

In addition the tag string documents the object group, with prefixes
like "wsi-" or "vh-" and contain object-specific additional
information like the vhost name, address / port  or the role of the wsi.
At creation time the lws code can use a format string and args
to add whatever group-specific info makes sense, eg, a wsi bound
to a secure stream can also append the guid of the secure stream,
it's copied into the new object tag and so is still available
cleanly after the stream is destroyed if the wsi outlives it.
2021-01-04 05:26:50 +00:00
Andy Green
eb5f437578 h2: post: add states to wait for body 2020-12-24 16:14:36 +00:00
Andy Green
677b6e370c h2: remove length tracking just use pointer arithmetic 2020-12-24 16:14:36 +00:00
Andy Green
e560d2c049 h2: stay a client if a client 2020-12-24 16:14:36 +00:00
Andy Green
587f24f71d clean: remove h2 debug spew 2020-12-06 19:06:05 +00:00
Andy Green
7d355912c3 h2: fix ignoring unknown frame payloads 2020-12-01 15:38:09 +00:00
Andy Green
10714c58e9 h2: ignore unknown frame types a bit earlier
Chrome has started being able to issue frame type 0x42, we drop the connection
before we realize we wanted to ignore it.

This explicitly ignores it a bit earlier.
2020-11-28 10:58:38 +00:00
Andy Green
2bcae2b3b6 context: refactor destroy flow 2020-11-28 10:58:38 +00:00
Andy Green
3549a94ce6 roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two.  No single
role has more than 14 of the ops.  On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.

First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.

Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is

2 + (4 x ops_used)

and for 64-bit

6 + (8 x ops_used)

for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160

For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)

This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions

For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata

before patch:          553282
accessor macro:        552714 (568 byte saving)
accessor functions:    553674 (392 bytes worse than without patch)

therefore we went with the macros
2020-11-28 10:58:38 +00:00
Andy Green
44e860642b docs: switch to use main 2020-10-19 16:35:03 +01:00
Andy Green
62e566b9de client: move staged connect pieces into core-net
They have been in lib/roles/http for historical reasons, and all
ended up in client-handshake.c that doesn't describe what they
actually do any more.  Separate out the staged client connect
related stage functions into

  lib/core-net/client/client2.c: lws_client_connect_2_dnsreq()
  lib/core-net/client/client3.c: lws_client_connect_3_connect()
  lib/core-net/client/client4.c: lws_client_connect_4_established()

Move a couple of other functions from there that don't belong out to
tls-client.c and client-http.c, which is related to http and remains
in the http role dir.
2020-09-21 12:47:11 +01:00
Andy Green
21546e511d h2: mark :protocol as an h2 psuedoheader 2020-09-20 09:17:09 +01:00
Andy Green
5c7b5af92a cmake: disable export visibility when building lws static
This is complicated by the fact extern on a function declaration implies
visibility... we have to make LWS_EXTERN empty when building static.

And, setting target_compile_definitions() doesn't work inside macros,
so it has to be set explicitly for the plugins.

Checking the symbol status needs nm -C -D as per

https://stackoverflow.com/questions/37934388/symbol-visibility-not-working-as-expected

after this patch, libwebsockets.a shows no symbols when checked like that and
the static-linked minimal examples only show -U for their other dynamic
imports.

In a handful of cases we use LWS_EXTERN on extern data declarations,
those then need to change to explicit extern.
2020-09-06 11:46:25 +01:00
Andy Green
c54a35e1a9 h2: allow empty SETTINGS
https://libwebsockets.org/pipermail/libwebsockets/2020-August/008676.html
2020-08-31 16:51:37 +01:00
Andy Green
72b245ea38 h2: fix breakage with LWS_WITH_HTTP2=0 2020-08-31 16:51:37 +01:00
Andy Green
d69b91d2d9 coverity: 62123: explicitly check things to guide coverity
Coverity sees we sometimes check if header length is 0 and extrapolates
from that not checking header length return is a violation.  But often
we are OK if the header length is 0 and there is no error return to
check from that.

It also doesn't understand that if we saw a nonzero length for a header,
then we are going to get a non-null simple_ptr() return for sure.  Just
give up and explicitly, unneccessarily check everything so coverity can
stop telling us about it.
2020-08-19 07:11:59 +01:00
Andy Green
d5497d5f55 coverity: 62535: another simple_ptr NULL check after confirmed by other means 2020-08-18 14:00:54 +01:00
Andy Green
398a9e1bad coverity: 62134: protect debug-only statement with preprocessor conditional
Compiler has no problem with it but coverity complains nobody uses p in release build
2020-08-18 14:00:54 +01:00
Andy Green
598a82ca1d coverity: 62512: remove unused assignment 2020-08-18 14:00:54 +01:00
Andy Green
795d20081e coverity: 232068: hpack 6-bit index may be garbage
It's possible an attacker may send an illegal dynamic index
we can't succeed to look up
2020-08-14 08:56:19 +01:00
Andy Green
ecb8de3386 coverity: 232025: modulo with zero modulus
Add a generic helper macro that has defined operation with modulus 0
2020-08-14 08:46:31 +01:00
Andy Green
4a28bc8c87 coverity: 231739: clear false positive by needless checks
Client connection api must provide host
2020-08-14 07:27:08 +01:00
Andy Green
146858fb54 coverity: 231926: clear false positive by showing coverity what it wants to see
We can't get here without testing for COLON_PATH existing in http2.c as part of
the h2spec pass code.

		if (!lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_PATH) ||
		    !lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_METHOD) ||
		    !lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_SCHEME) ||
		     lws_hdr_total_length(h2n->swsi, WSI_TOKEN_HTTP_COLON_STATUS) ||
		     lws_hdr_extant(h2n->swsi, WSI_TOKEN_CONNECTION)) {
			lws_h2_goaway(wsi, H2_ERR_PROTOCOL_ERROR,
				      "Pseudoheader checks");
			break;
		}

So there is no issue.  But show Coverity what it wants so we don't keep getting this
false positive reported by different coverity users.
2020-08-14 06:35:31 +01:00
Andy Green
1f0cd18dd6 ss: server: check more carefully if built but not used on a wsi 2020-08-10 15:04:10 +01:00