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

4581 commits

Author SHA1 Message Date
Andy Green
db5b2c1403 close: ensure any pending sul_connect_timeout cancelled 2020-10-09 21:30:49 +01:00
Andy Green
8d88d2f4f1 plugins: use new export symbol convention 2020-10-09 21:30:49 +01:00
Andy Green
170a5db028 cgi: support evlib_wsi in stdwsi 2020-10-09 21:30:45 +01:00
Andy Green
27964ddaf2 ws: reporting PONG with pmd enabled
Add a return code NOTHING_WE_SHOULD_DO indicating that the
extension determined by ext-specific means its operation was
disabled on this frame.

https://github.com/warmcat/libwebsockets/issues/2076
2020-10-09 08:00:44 +01:00
casey
e44c8698ca windows: null check wsi before udp check 2020-10-09 06:55:02 +01:00
casey
5d025839c6 windows: fix WSA event destruction
pt->events became an array
2020-10-09 06:53:44 +01:00
Andy Green
04d947b6f7 windows: WSA loop fixes 2020-10-08 14:52:54 +01:00
Andy Green
2ad378095d freertos: have lwip choose the cancel pipe port
Rather than a magic port, let's have lwip pick the port for
the UDP cancel "pipe", so no chance of conflict.
2020-10-08 11:21:45 +01:00
Jed Lu
ee78b90c8c ss: take care to free any metadata heap values before overwrite
Break out the core ss_set_metadata action into a subfunction that
takes the lws_ss_metadata_t, and is fixed to retire heap-based
values before they go out of scope, and adapt the exported version
to call through to that.

Simplify extract_metadata() to reuse the subfunction as well, in
both well-known and custom header cases.
2020-10-07 19:20:12 +01:00
Andy Green
5f7da4a530 struct_json: adapt api test for 32-bit int on windows 2020-10-06 21:21:19 +01:00
Sylvain Rochet
309b08d830 contrib: cross-atmel: build-out FILE_OPS
Fix build failure against Atmel ASF3 SDK that does not provide a file
API conforming to POSIX.

libwebsockets/lib/core/libwebsockets.c: In function 'lws_open':
libwebsockets/lib/core/libwebsockets.c:187:18: error: 'O_CREAT' undeclared (first use in this function)
  if (((__oflag & O_CREAT) == O_CREAT)
                  ^~~~~~~
2020-10-06 20:30:29 +01:00
Andy Green
8c88b857a9 h1: explicitly close when post txn completes
https://github.com/warmcat/libwebsockets/issues/2072
2020-10-06 13:56:45 +01:00
Mykola Stryebkov
89f4b739e1 minimal: smp + foreign: libuv foreign loops
AG: various fixes and adaptation of test protocol to use ring lock
to protect global wsi list against modifications from other threads
while in use
2020-10-05 08:39:05 +01:00
Andy Green
26a0d500a1 smp: additional locking for libuv
With SMP + event lib, extra locking is required when dealing with cross-thread
adoption case, and cross-vhost cases like wsi close, we need to hold the pt or
context lock.

These lock apis are NOPs when LWS_MAX_SMP == 1 which is the default.
2020-10-01 10:46:51 +01:00
Andy Green
3fa221f9d6 smp: lws_wsi_tsi
This lets you find out the SMP Thread Service Index (tsi) that a wsi
is bound to.  This allows you to, eg, filter a global wsi list so
you can find the ones that exist in your service thread context.
2020-10-01 10:43:12 +01:00
Andy Green
6490dc3e89 smp: set tsi in fakewsi used with WAIT_CANCELLED
Together with the new lws_wsi_tsi(wsi) this lets the WAIT_CANCELLED
callback understand its tsi context, the broadcasts are done for each
pt / loop.
2020-10-01 10:41:46 +01:00
Andy Green
636f9c7f01 evlib: export LWS_MAX_SMP locking for evlib plugin case with SMP
Now we're also looking at SMP + event lib, SMP locking pieces are
going to be needed for import into the event lib plugins if built
as plugins.
2020-10-01 10:41:43 +01:00
Andy Green
08c9395da5 update some wording 2020-09-30 06:42:13 +01:00
Andy Green
ef8bfb2488 windows: build fixes 2020-09-30 06:42:09 +01:00
Andy Green
bdc3a1102d cmake: remove fixed -g 2020-09-29 16:58:33 +01:00
Andy Green
cb2e04f602 ss: compiler may complain in release mode due to info 2020-09-29 16:52:51 +01:00
Andy Green
c75654c3f6 sequencer: disable by default 2020-09-29 09:29:59 +01:00
Andy Green
90a12db7ef lws_ctx_t
Let's start using a typedef for struct lws_context *, lws_ctx_t and
the convention to call it ctx.
2020-09-29 06:56:19 +01:00
Andy Green
90496da82e cmake: bump minimum version
Next release of cmake will choke by default if minimum version < 2.8.12
2020-09-28 07:35:27 +01:00
Jed Lu
9bff4d84ed sspc: http map proxying fixes 2020-09-22 07:39:24 +01:00
Sakthi Kannan
4e9f433b7e mqtt: fix extra byte on SUBSCRIBE 2020-09-21 17:04:42 +01:00
小明
c8fc7a6f37 ios: adapt to MSG_NOSIGNAL available in iOS SDK 12+ 2020-09-21 12:47:11 +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
80388bf72d sspc: extend RXPRE_CONNSTATE to handle 8 or 32-bit states
Currently only the low 8 bits of an SS state are proxied in a total packet
length of 8 octets.  Keep that format and behaviour since all the defined
states fit in 8 bits, but also allow for 32-bit states using a packet length
of 11 octets with the same command.

This lets us proxy user states (from http mapping) which start at a user
base of 1000.
2020-09-20 09:17:09 +01:00
Andy Green
21546e511d h2: mark :protocol as an h2 psuedoheader 2020-09-20 09:17:09 +01:00
Andy Green
49e92ba089 http: add RFC7231 date and time helpers and retry-after handling
Teach lws how to deal with date: and retry-after:

Add quick selftest into apt-test-lws_tokenize

Expand lws_retry_sul_schedule_retry_wsi() to check for retry_after and
increase the backoff if a larger one found.

Finally, change SS h1 protocol to handle 503 + retry-after: as a
failure, and apply any increased backoff from retry-after
automatically.
2020-09-19 14:11:56 +01:00
Andy Green
40f4ce9ffc testapp: extpoll: add back missing EXTERNAL_POLL pieces
EXTERNAL_POLL is not recommended for use for a while, it's a hack to allow
integration of lws with random application poll() loops.

While lws is very happy to do that secondary job for any event lib using the
foreign loop support (for uv, event, glib, and ev), for random roll-your-
own poll() waits there's no api because there's no event lib.  The solution
with a future is upgrade your application to use an event loop.

The test app that supports EXTERNAL_POLL was broken in Apr 2018, so it's
apparently good news nobody has been using it in new implementations
since then.  This patch adds in the missing pieces so we can test it until
it is formally deprecated.
2020-09-18 11:37:21 +01:00
Orgad Shaneh
891126988c cmake: remove dead code
Since 425da070e3 LWS_PTHR_FLAGS is no longer
used, so just remove it.
2020-09-18 11:37:21 +01:00
Orgad Shaneh
aa149e492b cmake: mingw: fix build with default options
afunix.h doesn't exist on mingw.
2020-09-18 11:37:17 +01:00
Orgad Shaneh
471dbf5280 cmake: mingw: fix openssl linkage
ws32 and friends must come after the openssl libs,
and pthread is required for openssl.
2020-09-18 11:37:17 +01:00
Andy Green
9f104efc25 docs: explain context and client lifecycle 2020-09-18 11:37:17 +01:00
Andy Green
33da902ed4 ss: policy: response code mapping
This adds a per-streamtype JSON mapping table in the policy.

In addition to the previous flow, it lets you generate custom
SS state notifications for specific http response codes, eg:

   "http_resp_map": [ { "530": 1530 }, { "531": 1531 } ],

It's not recommended to overload the transport-layer response
code with application layer responses.  It's better to return
a 200 and then in the application protocol inside http, explain
what happened from the application perspective, usually with
JSON.  But this is designed to let you handle existing systems
that do overload the transport layer response code.

SS states for user use start at LWSSSCS_USER_BASE, which is
1000.

You can do a basic test with minimal-secure-streams and --respmap
flag, this will go to httpbin.org and get a 404, and the warmcat.com
policy has the mapping for 404 -> LWSSSCS_USER_BASE (1000).

Since the mapping emits states, these are serialized and handled
like any other state in the proxy case.

The policy2c example / tool is also updated to handle the additional
mapping tables.
2020-09-16 13:10:26 +01:00
Andy Green
101b474217 ss: rx metadata
At the moment you can define and set per-stream metadata at the client,
which will be string-substituted and if configured in the policy, set in
related outgoing protocol specific content like h1 headers.

This patch extends the metadata concept to also check incoming protocol-
specific content like h1 headers and where it matches the binding in the
streamtype's metadata entry, make it available to the client by name, via
a new lws_ss_get_metadata() api.

Currently warmcat.com has additional headers for

server: lwsws                (well-known header name)
test-custom-header: hello    (custom header name)

minimal-secure-streams test is updated to try to recover these both
in direct and -client (via proxy) versions.  The corresponding metadata
part of the "mintest" stream policy from warmcat.com is

                        {
                                "srv": "server:"
                        }, {
                                "test": "test-custom-header:"
                        },

If built direct, or at the proxy, the stream has access to the static
policy metadata definitions and can store the rx metadata in the stream
metadata allocation, with heap-allocated a value.  For client side that
talks to a proxy, only the proxy knows the policy, and it returns rx
metadata inside the serialized link to the client, which stores it on
the heap attached to the stream.

In addition an optimization for mapping static policy metadata definitions
to individual stream handle metadata is changed to match by name.
2020-09-16 13:10:26 +01:00
Andy Green
d41bb16074 docs: force markdown to render correct path 2020-09-16 13:10:23 +01:00
Andy Green
aa539e607b client: awaiting header is only a CCE for ws
In the case http client doesn't get a response and closes, currently
it is confused, it reports it as a CLIENT_CONNECTION_ERROR but then
also a CLOSED_CLIENT_HTTP.

Adapt the logic so we only go that way for ws connection... not getting
the server headers means not reaching ESTABLISHED, which makes it a
CCE not a CLOSE.

Also make sure we never issue a CLOSE type callback if we issued a CCE.
2020-09-16 12:30:46 +01:00
Orgad Shaneh
3ef33627b5 cmake: use -Wuninitialized only for GCC >= 4.4
It doesn't work with 4.3.3
2020-09-16 08:04:44 +01:00
Orgad Shaneh
1ce85e005c smd: fix strict-aliasing warning on gcc 4.4 2020-09-16 08:04:39 +01:00
Orgad Shaneh
0ca76698c1 lws_dir: do not compare enums using the preprocessor
It is invalid on some platforms.

Fixes #2003
2020-09-16 08:04:33 +01:00
Orgad Shaneh
7676313946 core-net: initialize some variables
Amends 286cf4357a.
2020-09-16 07:07:04 +01:00
Sakthi Kannan
1a8979b68c mbedtls: use lws helper for PEM DER import 2020-09-16 07:07:04 +01:00
Orgad Shaneh
2badaef4fc unix plat: avoid strict aliasing complaint from a toolchain
The type of the fields in rtentry is sockaddr, and it is
casted to sockaddr_in. Size-wise it is ok, they should both
be the same size. But casting a pointer breaks build with
optimizations with the following error:

unix-sockets.c:434: error: dereferencing pointer 'addr' does break strict-aliasing rules

Amends commit 3c95483518.
2020-09-16 07:07:04 +01:00
Andy Green
92ed19164c event-libs: update README.md in the main dir for plugin capable flow 2020-09-14 06:58:08 +01:00
Andy Green
b1a084e7be ss: server: make sure failures after adopt invalidate ss copy of wsi
For server, if the adoption of the incoming connection proceeds but then
fails early on, eg, tls alert due to hostname mismatch with cert, the
wsi close happens but it doesn't clean up the invalidated reference to
itself in the server ss object... if it became established, that's handled
by the ss protocol callback.

This patch helps the close path to understand there is a related ss object
and to clean up after itself.
2020-09-13 14:37:15 +01:00
Andy Green
a7c9af5ac5 ss: server: dont allow client request_tx path even if disconnected 2020-09-13 14:37:15 +01:00
Andy Green
6a32db56bc libuv: fix pt derivation from ptpr in callbacks
The per-pt priv for event libs ended up overallocated at the context,
and pointed-to by a single pointer composed into each pt.  That means
we can't do pointer arithmetic on it any more.

Update a couple of stragglers in libuv event lib to use a pointer in
the pt-priv for the event lib back to the pt instead.

Also in foreign case if we start idle, there may not be anything
happening to trigger the initial idle.  So let each pt start with
its idle active.
2020-09-13 14:37:15 +01:00