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

260 commits

Author SHA1 Message Date
Andy Green
6cdaf85b89 ss: allow POLL from CONNECTING
Since CONNECTING is async and may take a while, there's nothing actually
wrong if the application asks to write again in the meanwhile and provokes
POLL.
2021-10-05 07:40:17 +01:00
Andy Green
ad990a61a0 ss: policy: unwind after policy syntax errors cleanly 2021-10-05 07:40:17 +01:00
Andy Green
b6004e08c9 mqtt: allow indicating client_id is not on heap
Not sure why we don't leave any freeing to the caller, but since we don't
allow indicating that the provided client id should not be freed.
2021-10-05 07:09:47 +01:00
Andy Green
1e56dc9642 ss: http: defend against CONNECTED-CONNECTED 2021-10-04 12:55:45 +01:00
Andy Green
a0e60304a4 ss: h1: defeat CCE if told CONNECTED 2021-10-04 12:55:45 +01:00
Andy Green
9ff83d9e75 ss: h1: be sure to go through DISCONNECTING if CCE 2021-10-04 12:55:45 +01:00
Andy Green
65a954a9c4 ss-h1: reset message state for repeated use
This lets one "opportunistic" mode http policy SS be able to be used
multiple times.
2021-10-04 12:55:45 +01:00
Andy Green
81a3ca3e84 ss: port binance example 2021-08-31 05:45:40 +01:00
Yichen Gu
b31c5d6ffe http: cookies: support cookie jar in and out 2021-08-21 17:44:40 +01:00
Andy Green
1b9ef51a95 conmon: make sure we report http specific on close 2021-08-19 10:01:56 +01:00
Andy Green
33d06386ff ss: CREATING to TIMEOUT is possible with sspc and active timeout 2021-08-19 08:10:54 +01:00
Andy Green
5de5ee74bf ss: lws_ss_client_connect also only pass up return
We removed the _lws_ss_handle_state_ret_CAN_DESTROY_HANDLE() from
request_tx, hane to do the same for lws_ss_client_connect()
2021-08-19 05:31:15 +01:00
Andy Green
43f290adbc sspc: add LWSSSCS_UPSTREAM_LINK_RETRY state
Add a transient state that indicates that we are retrying an upstream link
before the sspc creation can proceed.

The state() ack paramemeter shows the number of ms we have been retrying.

This is only issued if proxy mode clients are having difficulty reaching
their proxy, and are retrying.

As a transient state it doesn't affect the ss overall state, which will not
have reached CREATING yet.
2021-08-19 05:31:15 +01:00
Andy Green
37f3244076 conmon: add dns and protocol_specific
This adds an indication of dns disposition to the conmon results,
and for http, if it gets that far a protocol-specific indication
of http response code.
2021-08-19 05:31:04 +01:00
Zhao Lou
2951a92ed8 conmon: fix missing quote in JSON 2021-08-19 05:28:27 +01:00
Yichen Gu
4c99f85a16 conmon: pass userobj to ss rx not handle 2021-08-16 08:07:35 +01:00
Andy Green
387a406f07 ss: conmon: assert if wsi ss handle is stale
Add a way to confirm that the ss handle recovered from a ss wsi is still
valid, by walking the pt ss list and confirming it is on there before using
it with conmon.

If it isn't, it will assert.
2021-08-16 08:07:35 +01:00
Andy Green
9cd8d1f9f3 sspc: enable CCEs on proxy link wsi
Normally we suppress CCEs while still in the client connection loop time,
since we can return failure directly to the caller.

In sspc client case, defeat that, in order to have a convenient place to
put code that cares about ongoing proxy link connection failures.
2021-08-16 08:07:35 +01:00
Andy Green
243c21deac ss: add fault injections in creation
Add 9 fault injection cases in SS creation flow, and 5 of those
instantiate in the minimal examples ctests.  The other 4 relate
to static policy and server, I tested the server ones by hand.

These tests confirm the recent change to unpick create using
lws_ss_destroy.
2021-08-16 08:07:35 +01:00
Jed Lu
ca16a07a9b ss: unpick failed create using destroy
The late_bail discrete unpick flow is missing some pieces compared
to lws_ss_destroy.  Unify the creation fail flow to also use
lws_ss_destroy so everything in one place.

Make lws_ss_destroy() not issue any states if the creation flow
didn't get as far as issuing CREATING.
2021-08-16 08:07:35 +01:00
Andy Green
406b79e440 ss: handle DESTROY_ME from inside ss creation
Normally when doing a Client Connection Error handling,
we can action any ss relationship straight away since
we are in a wsi callback without any ss-aware parents
in the call stack.

But in the specific case we're doing the initial onward
wsi connection part on behalf of a ss, in fact the call
stack does have earlier  parents holding references on
the related ss.

For example

  secstream_h1 (ss-h1.c:470)                          CCE
  lws_inform_client_conn_fail (close.c:319)           fails early
  lws_client_connect_2_dnsreq (connect2.c:349)
  lws_http_client_connect_via_info2 (connect.c:71)
  lws_header_table_attach (parsers.c:291)
  rops_client_bind_h1 (ops-h1.c:1001)
  lws_client_connect_via_info (connect.c:429)         start onward connect
  _lws_ss_client_connect (secure-streams.c:859)
  _lws_ss_request_tx (secure-streams.c:1577)
  lws_ss_request_tx (secure-streams.c:1515)           request tx
  ss_cpd_state (captive-portal-detect.c:50)
  lws_ss_event_helper (secure-streams.c:408)
  lws_ss_create (secure-streams.c:1256)                SS Create

Under these conditions, we can't action the DESTROY_ME that
is coming when the CCE exhausts the retries.

This patch adds a flag that is set during the SS's onward wsi
connection attempt and causes it to stash rather than action
the result code.

The result code is brought out from the stash when we return to
_lws_ss_client_connect level, and passed up in the SS flow until
it is actioned, cleanly aborting the ss create.
2021-08-16 08:07:35 +01:00
Andy Green
e644bb4a6e cpd: pass up lws_ss_request_tx ret 2021-08-16 08:07:32 +01:00
Andy Green
f3d5b9b99a service: assert on thread shenanigans 2021-08-13 05:25:01 +01:00
Yichen Gu
9365490ef0 conmon: only build if WITH_CONMON 2021-08-09 17:31:16 +01:00
Jed Lu
62b915c879 ss: increase set_metadata length type to size_t 2021-08-09 17:31:16 +01:00
Andy Green
3073655759 ss: zero on destroy 2021-08-09 17:31:16 +01:00
Andy Green
48541efcc2 mqtt: handle NULL mqtt publish metadata 2021-07-08 10:16:06 +01:00
Andy Green
ee510154a0 fi: wsi: fault to fake peer hangup after a delay range
Example usage, client

$ valgrind ./bin/lws-minimal-secure-streams-stress-client -c 4 --budget 40

proxy

$ valgrind ./lws-minimal-secure-streams-proxy --fault-injection "ss=mintest/wsi/timedclose(20%),ss=mintest/wsi/timedclose_ms(0..100)"
2021-07-04 10:29:54 +01:00
Andy Green
fabe78d222 Wextra
Add -Wextra (with -Wno-unused-parameter) to unix builds in addition to
-Wall -Werror.

This can successfully build everything in Sai without warnings / errors.
2021-07-04 10:29:54 +01:00
Andy Green
5432e8ae7b sspc: add concurrency stress
Add a way to perform sspc tests with increased concurrency and sequential
tests
2021-07-04 10:29:52 +01:00
Andy Green
5d8cf03221 logs: log contexts 2021-07-01 05:20:53 +01:00
Andy Green
8e76634ed3 logs: introduce log_cx 2021-07-01 05:20:53 +01:00
Andy Green
66afeaa5bc 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-06-28 08:52:20 +01:00
Andy Green
9e8eb28c72 sul: improve debugging 2021-06-26 13:03:13 +01:00
Andy Green
a095e6c60b ss: sspc: enforce not allowed to call lws_ss[pc]_destroy from callbacks
For both ss and sspc, enforce at runtime that user code cannot call
lws_ss[pc]_destroy on a handle from a callback.

The error indicates the remedy (return DESTROY_ME) and asserts.
2021-06-23 16:51:59 +01:00
Andy Green
5ea9194378 ss: check destroy null policy 2021-06-22 17:44:40 +01:00
Andy Green
7135b3113b ss: check serialize null policy 2021-06-22 16:54:04 +01:00
Andy Green
c859b60854 ss: avoid null ss policy on req tx len 2021-06-22 16:47:59 +01:00
Andy Green
9bd8819045 ss: avoid null ss policy on req tx 2021-06-22 16:47:11 +01:00
Haopeng Li
cb5b1f720b ss: h1: log dereferences NULL 2021-06-22 15:54:22 +01:00
Jed Lu
2abf4115a8 ss: direct protocol string 2021-06-11 14:44:10 +01:00
Haopeng Li
b3bff76a73 strexp: handle NULL better 2021-06-07 15:11:12 +01:00
Andy Green
890023f821 ss: h2: handle zero length COLON_PATH for metadata 2021-06-04 15:31:49 +01:00
Andy Green
6c5636889d sspc: handle nonexistent metadata cleanly 2021-06-04 15:05:36 +01:00
Andy Green
436bb70919 coverity: h->cwsi must be valid if we are handling rx on it 2021-06-04 14:17:13 +01:00
Jed Lu
5b1a260881 ss: sspc: handle destroy for client_connect and request_tx 2021-05-28 09:41:39 +01:00
Chunho Lee
c5484c0232 ss-mqtt: Add support for MQTT UNSUBSCRIBE and DISCONNECT
Send UNSUBSCRIBE and DISCONNECT when LWSSSSRET_DISCONNECT_ME is
returned.
2021-05-27 11:37:44 +01:00
Andy Green
c70c4bac89 coverity: ss: handle NULL omd 2021-05-26 14:07:02 +01:00
Andy Green
632ffa1eca ss: deal with missing handle metadata 2021-05-25 14:57:57 +01:00
Jin Wang
2197c2eafc sspc: handle DESTROY_ME at proxy link close cb
It's open to user state callback to respond to the DISCONNECT we issue on
the proxy link closure by escalating it to a DESTROY_ME... we have to deal
with that if it comes.
2021-05-20 15:24:42 +01:00