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

3779 commits

Author SHA1 Message Date
Andy Green
6975847e62 lws_getaddrinfov46: make sure to set ai_socktype for ipv6 2019-11-13 09:15:36 +00:00
Andy Green
2d04b40770 cov263976: paranoid check is dead code to coverity 2019-11-12 10:29:02 +00:00
Andy Green
b2a112568c cov263975: help coverity see false positive 2019-11-12 10:28:53 +00:00
Andy Green
4f6fdd41b9 h2 client: no point resetting ah
Resetting the ah and waiting a bit is the right strategy at the end of
http/1.1 client transaction.  But it's wrong for h2... drop the ah
instead if it's the end of a client transaction on h2.
2019-11-08 08:46:57 +00:00
Andy Green
5b19db1850 lws_system: auth: update 2019-11-08 08:46:57 +00:00
Andy Green
c8de9bbc2d ah: drop on LONG_POLL and allow dropping client ah early 2019-11-06 21:34:14 +00:00
Zhiwen Zheng
34eca205e5 acme: add wildcard support to CSR 2019-11-06 16:02:36 +00:00
Andy Green
2bc0b97b45 acme: mbedtls: update genrsa apis 2019-11-06 16:02:33 +00:00
Andy Green
6b4b2f28be alpn: move out of tls-server so it can be used if server disabled 2019-11-06 06:39:28 +00:00
Andy Green
37c198d40b format strings: fixes for when toolchain has uint32_t as unsigned long 2019-11-05 21:00:45 +00:00
Andy Green
f01e2e1321 immortal: allow ASYNC_KILL timeout even if immortal 2019-11-05 20:34:29 +00:00
Andy Green
38e43bb51e ws-over-h2: disable validity checking on encapsulated wsi
The h2 nwsi is subject to its own validity checking PINGs,
we don't need to also do them to encapsulated ws-over-h2
2019-11-05 04:53:09 +00:00
Andy Green
6786ce9e33 ws-over-h2: wrong sid on rst_stream
rst_stream is almost always called from the h2 parser... in the case
a ws-over-h2 is closing though, it can't reference the h2n parser sid
context to get the sid to send... it's unrelated at that time.

https://bugzilla.mozilla.org/show_bug.cgi?id=1590299
https://github.com/warmcat/libwebsockets/issues/1752
2019-11-04 21:19:53 +00:00
Andy Green
d3cda2b1d7 humanize: explicitly do decimal rendering
Work around some toolchains with PRIu64 but bugged rendering
2019-11-04 14:21:11 +00:00
Andy Green
0ab4a707fb format strings: ban %.*s as some platforms lack it
The %.*s is very handy to print strings where you have a length, but
there is no NUL termination.  It's quite widely supported but at least
one vendor RTOS toolchain doesn't have it.

Since there aren't that many uses of it yet, audit all uses and
convert to a new helper lws_strnncpy() which uses the smaller of
two lengths.
2019-11-04 13:49:14 +00:00
Zhiwen Zheng
3299c54130 illumos: fix build errors 2019-11-04 13:49:13 +00:00
Andy Green
e1cf534775 jwk: add export option to suppress final CRLF
https://github.com/warmcat/libwebsockets/issues/1746

Adding the final CRLF is a NOP at JSON level, but can disrupt hashing the
JSON if it isn't expecting it.

Add flags to the jwk export so it can be controlled... operation remains
unchanged for old values 0 and 1 but a second flag can be OR-ed to control
issue of final CRLF.
2019-11-04 13:49:13 +00:00
Andy Green
ef14f00f64 osx: needs sys/dirent.h 2019-11-04 13:49:13 +00:00
Andy Green
ce55c5dfe4 lwsac: fix header split optimization 2019-11-02 18:34:05 +00:00
Andy Green
08fac7a1f7 unix: sul schedule rename internal api and call regardless of existing timeout
Pre-sul, checking for interval to next pending scheduled event was expensive and
iterative, so the service avoided it if the wait was already 0.

With sul though, the internal "check" function also services ripe events and
removes them, and finding the interval to the next one is really cheap.

Rename the "check" function to __lws_sul_service_ripe() to make it clear it's
not just about returning the interval to the next pending one.  And call it
regardless of if we already decided we are not going to wait in the poll.

After https://github.com/warmcat/libwebsockets/pull/1745
2019-11-01 07:07:33 +00:00
Kristján Valur Jónsson
7e150b2188 windows: service: do sul check and service regardless of service timeout 2019-11-01 06:45:51 +00:00
Andy Green
f3b2205679 clean: warning where uint32_t is long 2019-10-31 11:01:39 +00:00
Sun Dro
10bb008dd4 lws_get_tsi
Get thread service index wsi belong to
2019-10-29 09:14:42 +00:00
Zhiwen Zheng
1d618e8793 wsproxy: decrement client rx buflist size at server side tx
https://github.com/warmcat/libwebsockets/issues/1738
2019-10-28 13:20:45 +00:00
Zhiwen Zheng
6cb9f4eb60 wsproxy: send buffered data from head not tail
https://github.com/warmcat/libwebsockets/issues/1737
2019-10-28 13:20:44 +00:00
Kristján Valur Jónsson
9ef5cbee01 Use IPPROTO_TCP if getprotobyname("tcp") fails. 2019-10-28 13:20:43 +00:00
Kristján Valur Jónsson
c50479d021 Improve logging when setting sock opts on windows 2019-10-27 16:38:02 +00:00
Kristján Valur Jónsson
4c224eb64b fix integer conversions from 64 bit 2019-10-27 16:29:04 +00:00
Andy Green
2f4316527b sul: more paranoid casting vs libc header types
As it is, if time_t is 32-bit on the platform it might lead to
arithmetic overflow, so force it to lws_usec_t (uint64_t) even
though it works OK here on x86_64.

Add a minimal example aimed at testing the wsi hrtimer stability
consistently across platforms.

Add and disable by default hrtimer dump code (this is too expensive
and specific to internal testing to leave in for debug mode even if
it's not printed).  If you hack it enabled, it will dump the sul
list for the pt and assert if the list is disordered.
2019-10-27 06:22:13 +00:00
Andy Green
186888ed39 ws proxy: ensure upgrade request url starts with slash
In the case rpath is set to //, any urlargs will be added
right at the start.  Add a check to keep the initial / if so.

https://github.com/warmcat/libwebsockets/issues/1733
2019-10-26 05:31:01 +01:00
Kristján Valur Jónsson
f5ccdd1825 windows: clean warnings around int usage
Change all plat instances of lws_plat_setnonblocking() to use lws_sockfd_type
2019-10-23 06:39:35 +01:00
Kristján Valur Jónsson
1b51301c8d lejp: fix warnings on windows 2019-10-23 06:36:11 +01:00
Kristján Valur Jónsson
afb7b30f0d windows: LWS_EXTERN must be 'extern' if not building DLL
if it is simply empty, header declarations of externally defined arrays will fail.
2019-10-23 06:33:22 +01:00
Andy Green
6f7051920a cgi: call init_destroy even though not on available roles list
cgi is a role, but it's not an externally-selectable role... it's only
used when the mount indicates it should be.

That means it's not in the list of EVERY_AVAILABLE_ROLE... make sure
its zombie child reaping timer is started at context creation and
stopped at destruction.
2019-10-20 07:13:09 +01:00
Andy Green
da2d585583 rtos: h2 in toolchain with long uint32_t 2019-10-17 11:08:47 +01:00
Andy Green
08e008ac3d h2 client: deal correctly with zero length DATA with END_STREAM 2019-10-17 09:19:57 +01:00
Andy Green
ebdc0ad084 lwsac-backfill
Optimizations for memory-tight systems.

Check all previous gaps first for any usage, so gaps we created when
faced with perhaps a relatively large allocation that left a lot of
the last chunk on the table can be backfilled with smaller things as
it goes on.

Separate the members that only live in the head object out of the
buffer management object, reducing the cost of new chunks.  Allocate
the head object members as the first thing in the first chunk, and
adjust all the code to look there for them.
2019-10-17 09:19:57 +01:00
Andy Green
c776ac50d6 lwsac: add blob deduplication helper
Add lwsac helper api to allow user code to perform constant string folding
easily within an lwsac.  After isolating a string or blob that it wants to store in
the lwsac and point to, it can check if the string or blob already exists earlier
in the lwsac first, and if so just point to that without copying it in again.

For some formats with repeated strings like JSON, the saving can add up to
something useful.
2019-10-17 09:19:57 +01:00
Andy Green
fe1d3def00 lws_spa: also support multipart/related 2019-10-14 12:22:46 +01:00
Andy Green
0ff633eb35 lws_sul: always iterate from head of list
The sul callback is allowed to do anything to the sul list, it's
not possible to safely iterate it inbetween calls.

Luckily because it's sorted, we only ever care about the current
head, so switch to iterating it like that.
2019-10-14 10:53:28 +01:00
Andy Green
667f9d1fb3 validity: encapsulated ws must report validity on parent h2 conn 2019-10-14 10:53:28 +01:00
Andy Green
938f692c48 adopt: improve logging of server adopt fail
This is usually something that either couldn't negotate tls at all
or compatible tls parameters.

Log the vhost it came in on and the IP.
2019-10-14 07:08:57 +01:00
Andy Green
efc35fe1e1 async dns: recursion
Handle the situation that we are told to use a CNAME, but the CNAME is not resolved
by the remote server... adapt the query to resolve the CNAME and restart it, while
retaining the original query name for the cache entry generation.

"Recursion" doesn't mean function-calling-a-function type recursion, it remains
completely asynchronous on the event loop.
2019-10-13 11:55:59 +01:00
Andy Green
1c09e6e822 buflist: overallocate by 1
We overallocate at the start by LWS_PRE so we can use
buflist content directly with lws_write, this has us also
overallocate by 1 at the end.  There's a corner case with
cgi where it's receiving bulk POST data to pass on to cgi
stdin and wants to make sure there's a NUL just past the
end... this makes sure we have space for it.
2019-10-13 07:17:03 +01:00
Andy Green
da8995bb61 h2: tolerate unexpected server behaviour
Make sure we only do one SETTINGS ack handling

Fix corner case of ignored header with 0 data being the last in the HEADERS
2019-10-12 12:41:14 +01:00
Andy Green
300e22c815 lws_system: auth token handling using buflist 2019-10-12 12:41:14 +01:00
Andy Green
f9e9977534 lws_buflist: extra apis for in-place use 2019-10-12 12:41:14 +01:00
Andy Green
37ac955fc4 wsi flags: extra encodings 2019-10-12 12:41:14 +01:00
Andy Green
d0fa39af7f lws_system: dhcpclient
Generic lws_system IPv4 DHCP client

 - netif and route control via lib/plat apis
 - linux plat pieces implemented
 - Uses raw ip socket for UDP broadcast and rx
 - security-aware
 - usual stuff plus up to 4 x dns server

If it's enabled for build, it holds the system
state at DHCP until at least one registered interface
has acquired a set of IP / mask / router / DNS server

It uses PF_PACKET which is Linux-only atm.  But those
areas are isolated into plat code.

TODOs

 - lease timing and reacquire
 - plat pieces for other than Linux
2019-10-12 12:41:14 +01:00
Andy Green
127e53cf98 client: multipart mime generation helpers
lws has been able to generate client multipart mime as shown
in minimal-http-client-post, but it requires a lot of user
boilerplate to handle the boundary, related transaction header,
and multipart headers.

This patch adds a client creation flag to indicate it will
carry multipart mime, which autocreates the boundary string
and applies the transaction header with it, and an api to
form the boundary headers between the different mime parts
and the terminating boundary.
2019-10-12 12:41:14 +01:00