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

381 commits

Author SHA1 Message Date
Andy Green
5c3e8b2e41 client: iterate connection attempts through addrinfo list 2019-09-22 03:06:59 -07:00
Andy Green
c591e1adfc asynchronous dns for ipv4 and ipv6
This adds the option to have lws do its own dns resolution on
the event loop, without blocking.  Existing implementations get
the name resolution done by the libc, which is blocking.  In
the case you are opening client connections but need to carefully
manage latency, another connection opening and doing the name
resolution becomes a big problem.

Currently it supports

 - ipv4 / A records
 - ipv6 / AAAA records
 - ipv4-over-ipv6 ::ffff:1.2.3.4 A record promotion for ipv6
 - only one server supported over UDP :53
 - nameserver discovery on linux, windows, freertos

It also has some nice advantages

 - lws-style paranoid response parsing
 - random unique tid generation to increase difficulty of poisoning
 - it's really integrated with the lws event loop, it does not spawn
   threads or use the libc resolver, and of course no blocking at all
 - platform-specific server address capturing (from /etc/resolv.conf
   on linux, windows apis on windows)
 - it has LRU caching
 - piggybacking (multiple requests before the first completes go on
   a list on the first request, not spawn multiple requests)
 - observes TTL in cache
 - TTL and timeout use lws_sul timers on the event loop
 - ipv6 pieces only built if cmake LWS_IPV6 enabled
2019-09-19 06:54:53 +01:00
Sviatoslav Grebenchucov
976d804f1a socks: Fix compilation error 2019-09-06 15:30:51 +01:00
Andy Green
0fa5563d18 freertos: rename esp32 plat to freertos 2019-08-26 09:58:57 +01:00
Andy Green
ae69bfbd10 debloat: remove things from being built by default that should be conditional 2019-08-26 09:58:57 +01:00
Andy Green
c36a1e8ed0 clean: internally use LWS_WITH_CLIENT and _SERVER
Remove some more things in LWS_WITH_SERVER=0 case
2019-08-26 09:58:57 +01:00
Andy Green
f8afcd0e5c client: make external http proxying optional
Add LWS_CLIENT_HTTP_PROXYING on by default.  Removing it saves a few
hundred bytes of code and 128 bytes per vhost in heap.
2019-08-26 09:58:57 +01:00
Andy Green
c099e7be92 client: do client stash in a single alloc
Improve the code around stash, getting rid of the strdups for a net
code reduction.  Remove the special destroy helper for stash since
it becomes a one-liner.

Trade several stack allocs in the client reset function for a single
sized brief heap alloc to reduce peak stack alloc by around 700 bytes.
2019-08-19 10:12:20 +01:00
Andy Green
72b482ee15 Coverity fixes 2019-08-19 10:12:20 +01:00
Andy Green
2a98642cff c++: establish a single place for opaque forward references 2019-08-18 05:40:56 +01:00
Andy Green
d7f0521aeb private.h: rename to contain dir
Having unique private header names is a requirement of a particular
platform build system it's desirable to work with
2019-08-15 10:49:52 +01:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
7b517eac87 lws_inform_client_conn_fail
There are many places where we have the same code to inform about client
connection failure... consolidate it
2019-08-12 12:44:36 +01:00
Andy Green
2fc35ef6bd stats: move to pt and improve presentation 2019-08-12 06:18:04 +01:00
Andy Green
498a4e2bd7 sul: all timed objects use a single pt sul list
wsi timeout, wsi hrtimer, sequencer timeout and vh-protocol timer
all now participate on a single sorted us list.

The whole idea of polling wakes is thrown out, poll waits ignore the
timeout field and always use infinite timeouts.

Introduce a public api that can schedule its own callback from the event
loop with us resolution (usually ms is all the platform can do).

Upgrade timeouts and sequencer timeouts to also be able to use us resolution.

Introduce a prepared fakewsi in the pt, so we don't have to allocate
one on the heap when we need it.

Directly handle vh-protocol timer if LWS_MAX_SMP == 1
2019-08-09 10:12:09 +01:00
Andy Green
3c12fd72e8 unify us sorted waits
There are quite a few linked-lists of things that want events after
some period.  This introduces a type binding an lws_dll2 for the
list and a lws_usec_t for the duration.

The wsi timeouts, the hrtimer and the sequencer timeouts are converted
to use these, also in the common event wait calculation.
2019-08-08 22:39:47 +01:00
Andy Green
45ec3ce369 lws_dll: upgrade all instances to lws_dll2
lws_dll2 removes the downsides of lws_dll and adds new features like a
running member count and explicit owner type... it's cleaner and more
robust (eg, nodes know their owner, so they can casually switch between
list owners and remove themselves without the code knowing the owner).

This deprecates lws_dll, but since it's public it allows it to continue
to be built for 4.0 release if you give cmake LWS_WITH_DEPRECATED_LWS_DLL.

All remaining internal users of lws_dll are migrated to lws_dll2.
2019-08-08 16:58:55 +01:00
Andy Green
6dd65e2d75 COVA10117: help coverity see uri is always set
The _WSI_TOKEN_CLIENT_URI private header was always
set to something by the client api before this.  Help
Coverity understand it's OK.
2019-08-08 09:45:09 +01:00
Andy Green
7f6afa6985 COVA11626: explicitly check there is a protocol set 2019-08-08 09:45:09 +01:00
hjfbswb
15ce3d03b9 solve complilation errors on vs2008
replace snprintf with lws_snprintf
2019-08-01 18:05:38 +01:00
Andy Green
a60e60bc29 http: server: support HEAD via mount
Until now we parse HEAD requests but don't properly fulfil them.

This adds enough that if the request pointed to a valid mount,
it will send the headers and complete the transaction without
sending the body.

Test with

$ (echo -n -e "GET / HTTP/1.0\r\nHost: default\r\n\r\n"; sleep 2) | nc  127.0.0.1 7681
2019-08-01 12:56:29 +01:00
Andy Green
00923627c0 client: add more descriptive string cases 2019-07-24 16:48:24 -07:00
Andy Green
2c143ed224 COVA10117: help Coverity understand the address cannot be NULL 2019-07-16 10:02:54 -07:00
Andy Green
bc394b0680 ws: http: most of the world can't handle close,upgrade on connection
It's legal and does something important, if the upgrade fails and stays in http,
it describes how the connection should be handled after sending the error code.

But most ws servers can't cope with it...
2019-07-14 15:45:32 -07:00
Andy Green
a67efe80f1 http: make lws_http_get_uri_and_method public 2019-07-14 12:08:51 -07:00
Leonard Ricci
1ac744a314 build: change AMAZON_NOART to AMAZON_LINUX 2019-07-13 14:50:58 -07:00
Andy Green
fc5defdd2a COVA10299: check lws_change_pollfd 2019-07-13 13:39:50 -07:00
Andy Green
e3f895a71d COVA11626: pwsi is not allowed to be NULL 2019-07-13 13:28:54 -07:00
Andy Green
cd56a4b97f COVA12046: make it clear the strdup target cannot be NULL 2019-07-13 13:28:54 -07:00
Andy Green
d14dcff076 COVA11197: source indentation confused 2019-07-13 13:28:54 -07:00
Andy Green
93df14454c COVA10821: check lws_change_pollfd 2019-07-13 13:28:54 -07:00
Andy Green
cbd58fa458 http: body: make sure to consume body before transaction complete
https://github.com/warmcat/libwebsockets/issues/1625

"dead bodies" that were sent but not processed by lws as server
will clog up and destroy transaction tracking if repeated POSTs
with keepalive are sent to nonexistant paths.

This patch introduces a DISCARD_BODY state that follows BODY
except the payload is not signalled to the protocol callback.
Calling transaction_completed() with pending body makes lws
enter DISCARD_BODY and retry transaction completed only after
the pending body is exhausted.
2019-07-05 07:31:38 +01:00
Andy Green
d727c89d79 cmake: miniz: add as option 2019-07-03 19:46:23 +01:00
Andy Green
e4ec282987 coverity: 2019.03 fixes 2019-07-01 06:39:55 +01:00
Ilan Pegoraro
0123b4381f vhost: bind: make failure to bind optionally fatal
When creating a vhost and the port is already bound to another process
this flag would allow the user code to choose to have the
lws_create_vhost function to fail and return a null pointer.
2019-06-29 21:08:36 +01:00
Andy Green
b3d6e28bc7 lws_sequencer 2019-06-25 12:10:18 +01:00
Andy Green
4692c1a7ee rtos: clean warnings where uint32_t is an unsigned long 2019-06-07 11:11:46 +01:00
Chen Xi
892cde2c71 rtos: add support for AMAZON_RTOS 2019-06-05 05:04:17 +01:00
Orgad Shaneh
19049d2f28 Change some struct members to unsigned char
Enables removal of superfluous casts, and fixes strict-aliasing warnings with
GCC 4.1.
2019-05-30 08:21:33 +08:00
Orgad Shaneh
93c35b9712 http: Initialize local variable
GCC 4.1 warns about potential access to uninitialized variable, although
this can't really happen.

Silence it by initializing the variable.
2019-05-30 06:06:41 +08:00
Andy Green
8b8849e8cc client: modernize socks5 fixing heap overflow
https://github.com/warmcat/libwebsockets/issues/1583
2019-05-22 15:54:46 +01:00
Andy Green
752e19391d no h2: fix unused var warning
https://github.com/warmcat/libwebsockets/issues/1579
2019-05-17 01:24:52 +01:00
Andy Green
173943a405 h2: align h1 upgrade to work same as alpn upgrade
https://github.com/warmcat/libwebsockets/issues/1571

Although the code exists for non-tls h1 upgrade to h2, it hasn't been looked
after since all expected uses for h2 are going to be via h2 / alpn.

This patch aligns its upgrade actions with alpn upgrade path so it works OK
via

$ curl --http2 http://localhost:7681/ -v -w "\n"

ie, without tls.  Operation via tls is unaffected.

To use the non-tls upgrade path, you have to be listening without tls, ie with the
test server without -s.  If you're listening in a way that requires tls, this
can't be used to bypass that (or, eg, client certs) in itself, since you have to be
able to talk to it in h1 in the first place to attempt the upgrade to h2.

The common h2 path has some code to dropping the ah unconditionally it looks
like after the first service... this is too aggressive since the first thing
coming on the upgrade path is WINDOW_UPDATE.  It looks wrong anyway, transaction /
stream completion will drop the ah and should be enough.
2019-05-12 08:01:50 +01:00
Andy Green
f89aa401cc generic-sessions update
Generic sessions has been overdue some love to align it with
the progress in the rest of lws.

1) Strict Content Security Policy
2) http2 compatibility
3) fixes and additions for use in a separate process via unix domain socket
4) work on ws and http proxying in lws
5) add minimal example
2019-05-06 10:24:51 +01:00
Andy Green
8d473ad78c smtp: make abstract 2019-05-04 08:28:31 +01:00
Andy Green
359aeb1093 client http rx: check correct binding state 2019-04-20 09:28:15 +01:00
pavelxdd
575b96e32e http: refactor and fixes in lws_get_mimetype
- prioritize user-defined mimetypes over predefined server mimetypes.
- fix accessing memory out of string bounds.
- prefer case-insensitive comparison for extension matching.
- other minor fixes and improvements.
2019-04-09 16:21:55 +01:00
Andy Green
6d45e6c5b1 spa: add info args and stride
This is aimed at allowing a stride to optionally be
given for the parameter name array... this will allow
use of lws_struct metadata as the parameter name
array.


Also introduce the option to put all allocations in
an lwsac instead of via lws_mallocs.
2019-04-06 07:34:36 +08:00
pavelxdd
0bfb172a9e http: basic auth: fix delay on Firefox
Firefox sends HTTP requests with "Connection: keep-alive" header.
When LWS responds with 401 and WWW-Authenticate header, Firefox
doesn't show an authentication dialog until connection is closed.
Adding "Content-Length: 0" solves the problem.
2019-04-03 17:00:15 +08:00
Andy Green
1062370f07 unix skt: allow control over skt user:group
If you're providing a unix socket service that will be proxied / served by another
process on the same machine, the unix fd permissions on the listening unix socket fd
have to be managed so only something running under the server credentials
can open the listening unix socket.
2019-03-26 14:54:49 +08:00