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

3150 commits

Author SHA1 Message Date
Andy Green
6a88483f02 lejp: integrate error strings and api to core lejp
lejp-conf isn't the only user that needs to generate human-readable
JSON parsing error stacks.

Build it in with lejp and introduce an error code -> string api
2019-03-12 11:57:43 +08:00
Andy Green
4ed522eb9c minimal-http-client-custom-headers 2019-03-12 11:57:43 +08:00
Andy Green
3b65f9885b old openssl: dont build with membuffer apis 2019-03-12 11:57:43 +08:00
Andy Green
c3f30bf1fa vhost info: add memory buffer cert support 2019-03-12 11:57:43 +08:00
Andy Green
0079099f10 vhost: add pprotocols to vhost info
info.protocols works okay, but it has an annoying problem... you have to know
the type for each protocol's pss at the top level of the code, so you can set
the struct lws_protocols user_data size for it.

Lws already rewrites the protocol tables for a vhost in the case of runtime
protocol plugins... this adapts that already-existing code slightly to give
a new optional way to declare the protocol array.

Everything works as before by default, but now info.protocols may be NULL and
info.pprotocols defined instead (if that's also NULL, as it will be if you
just ignore it after memsetting to 0, then it continues to fall back to the
dummy protocol handler as before).

info.pprotocols is a NULL-termined array of pointers to lws_protocol
structs.  This can be composed at the top level of your code without knowing
anything except the name of the externally-defined lws_protocol struct(s).

The minimal example http-server-dynamic is changed to use the new scheme as
an example.
2019-03-10 08:02:02 +08:00
Akira Tsukamoto
28fc564182 optee: supporting sockaddr* variants and cleanup
Without this patch, the build will break with gcc 8.2 as bellow.
optee_os/lib/libwebsockets/libwebsockets/lib/core-net/network.c: In function ‘lws_socket_bind’:
optee_os/lib/libwebsockets/libwebsockets/lib/core-net/network.c:347:4: error: ‘memcpy’ forming offset [5, 16] is out of the bounds [0, 4] of object ‘sin’ with type ‘struct sockaddr_storage’ [-Werror=array-bounds]
    memcpy(&sain, &sin, sizeof(sain));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/akirat/dev/otrp/aist-tb/optee_os/lib/libwebsockets/libwebsockets/lib/core-net/network.c:224:26: note: ‘sin’ declared here
  struct sockaddr_storage sin;
                          ^~~
cc1: all warnings being treated as errors

Signed-off-by: Akira Tsukamoto <akira.tsukamoto@gmail.com>
2019-03-10 08:02:02 +08:00
Andy Green
f8cd973f85 mingw: windows: make minimal examples build 2019-03-10 08:02:02 +08:00
Andy Green
09fe212432 bzero: replace all with memset
lws_explicit_bzero() is available if the goal is to have volatile zeroing.
2019-03-10 08:02:02 +08:00
Andy Green
b31ab02786 ipv6: force ipv4 if iface bind uses ipv4 address 2019-03-10 08:02:02 +08:00
Andy Green
529b59cf6f xenial: fix missing stdio.h errors in minimal examples 2019-03-10 08:02:02 +08:00
Andy Green
2cb6732629 minimal-ws-client-echo: add -i iface option to allow control of client iface bind 2019-03-10 08:02:02 +08:00
Andy Green
1e00d1d05a ipv6: support [ipv6]:port in client proxy
https://libwebsockets.org/pipermail/libwebsockets/2019-March/007840.html
2019-03-10 08:02:02 +08:00
Andy Green
c741f71465 adopt: force incoming fd to nonblocking
Incoming fds muct be nonblocking for any event loop... add a platform
api to do that and call it during adopt.
2019-03-10 08:02:02 +08:00
Andy Green
cdf6dc35f4 cmake cross: non-bash doesn't deal with quoted options correctly
Although it works find on Fedora / bash, the extra quotes are snipped
on Ubuntu / dash.  Removing the quotes works OK on both.
2019-03-10 08:02:02 +08:00
Andy Green
b50e9fb31b cmake: override build system release optimization policy
The cmake config on the build system actually decides the release build optimization policy.
On Fedora, it's -O2.  On Ubuntu, it's -O3.

Anything given in CMakeLists.txt is overridden by the build system policy since it goes at
the end of the compiler commandline.

When you are building cross, the build system's opinion of your cross binary optimization
level is irrelevant, and at worst destructive.  Some versions of gcc contain broken optimizations
that are applied only at -O3.

This patch removes any doomed attempt to set -O in CMakeLists.txt, which has
no effect since the build system policy is still added at the end, but
removes confusion; and adds code to all the cross build files to forcibly
override release optimization level to -O2, removing the build system's
opinion of how your cross build should look.
2019-03-10 08:02:02 +08:00
Andy Green
986bb37c88 ah: custom headers for h1
Until now lws only parses headers it knows at build-time from its
prebuilt lexical analyzer.

This adds an on-by-default cmake option and a couple of apis
to also store and query "custom", ie, unknown-to-lws headers.

A minimal example is also provided.

At the moment it only works on h1, h2 support needs improvements
to the hpack implementation.

Since it bloats ah memory usage compared to without it if custom
headers are present, the related code and ah footprint can be
disabled with the cmake option LWS_WITH_CUSTOM_HEADERS, but it's
on by default normally.  ESP32 platform disables it.

https://github.com/warmcat/libwebsockets/pull/1499
2019-03-10 08:02:02 +08:00
Andy Green
e56ccb7757 libuv: account for pipe close only once 2019-03-10 08:02:02 +08:00
Andy Green
c289ee3199 ipv6: migrate header includes to private.h 2019-03-10 08:02:02 +08:00
Andy Green
ddebc52325 uv: ensure watcher exists before operating on it
This seen in the wild...

==20578== Invalid read of size 1
==20578==    at 0x4D2E018: uv_poll_stop (poll.c:112)
==20578==    by 0x48BC159: elops_io_uv (libuv.c:684)
==20578==    by 0x4872F55: __remove_wsi_socket_from_fds (pollfd.c:326)
==20578==    by 0x486EF1B: __lws_close_free_wsi (close.c:425)
==20578==    by 0x486F3E2: lws_close_free_wsi (close.c:518)
==20578==    by 0x487564C: lws_service_fd_tsi (service.c:1033)
==20578==    by 0x48BAEA9: lws_io_cb (libuv.c:117)
==20578==    by 0x4D3606F: uv__io_poll (linux-core.c:379)
==20578==    by 0x4D27714: uv_run (core.c:361)
==20578==    by 0x48BC347: elops_run_pt_uv (libuv.c:735)
==20578==    by 0x4875746: lws_service (service.c:1080)
==20578==    by 0x401A51: main (main.c:309)
==20578==  Address 0x58 is not stack'd, malloc'd or (recently) free'd
2019-03-10 08:02:02 +08:00
Andy Green
562dcbaf9f smp: take pt lock in poll foreign thread detection 2019-03-10 08:02:02 +08:00
Adam Duskett
e7df97c309 libuv.c: set m to 0 by default
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Setting m to 0 by default will prevent "error: ‘m’ may be used uninitialized in this function"
while compiling with the option -DLWS_WITH_LIBUV=ON.
2019-03-10 08:02:02 +08:00
Andy Green
a57d13cb1b smp: adopt: deal with load balancing init window
With SMP as soon as we add the new sockfd to the fds table, in the
case we load-balanced the fd on to a different pt, service on it
becomes live immediately and concurrently.  This can lead to the
unexpected situation that while we think we're still initing the
new wsi from our thread, it can have lived out its whole life
concurrently from another service thread.

Add a volatile flag to inform the owning pt that if it wants to
service the wsi during this init window, it must wait and retry
next time around the event loop.
2019-03-10 08:02:02 +08:00
Andy Green
3a31c47fcd ws: setting default protocol index to an illegal index disables default ws binding
On lwsws, incoming ws connections to the default vhost
are not rejected by the dummy protocol handler and not
really serviced either, leading to bots connecting to it to
get immortal, idle ws connections with no timeout (since it's an
established ws connection).

Rejecting these connections by default by adding a handler
for ESTABLISHED in the dummy handler will solve it nicely,
but it will break an unknown number of dumb. protocol-less
user implementations that rely on this behaviour by using
break; from their own ESTABLISHED handler and calling
through to the currently NOP dummy handler one.

Add support to assertively disable the default protocol
index used for subprotocol-less ws connections instead.
2019-03-10 08:02:02 +08:00
Andy Green
30d992dbe2 clean: LWS_SSL_ENABLED use vh as the macro arg name to clarify what should be given 2019-03-10 08:02:02 +08:00
Andy Green
572ffb4a7c http: log ws upgrades 2019-03-10 08:02:02 +08:00
JoonCheol Park
281d2a7fc2 socks5: fix remain dst buffer length when calls lws_strncpy 2019-03-10 08:02:02 +08:00
Andy Green
fb90b04e97 server-status: add proc statm and switch to vhost protocol timer 2019-03-10 08:02:02 +08:00
Andy Green
f74326e6e1 cgi: fix stdin cgiwsi leak when closed early 2019-03-10 08:02:02 +08:00
Andy Green
93d23efc2c raw-proxy: avoid one char read too far with tokenizer 2019-03-10 08:02:02 +08:00
Andy Green
d41e0f8f7c sshd: explicitly transfer free responsibility when adopting last_alloc 2019-03-10 08:02:02 +08:00
Andy Green
f17c2da2bf libevent: idle timer should not be EV_PERSIST 2019-03-10 08:02:02 +08:00
fanc
32cb5e1466 client: confirm sin_zero actual size for platform
in some platform, the size of sa46.sa4.sin_zero is not 8, but 6, so use 8 will cause coredump.
2019-03-10 08:02:02 +08:00
Andy Green
2d086db6e8 codacy: fixes for warnings 2019-03-10 08:02:02 +08:00
Andy Green
e4a65c948e windows: treat syscall and errno 0 as WANT_READ
https://libwebsockets.org/pipermail/libwebsockets/2019-February/007800.html
2019-02-07 06:24:14 +08:00
Andy Green
419f02ef67 optee: avoid using gai_strerror in udp 2019-02-07 06:22:03 +08:00
Andy Green
1d466f332e lws_http_mark_sse
https://github.com/warmcat/libwebsockets/issues/1486
2019-01-30 20:59:56 +08:00
Andy Green
0b3c32c086 sse: drop the ah when the sse connection starts 2019-01-30 14:38:11 +08:00
Andy Green
c0b0c0ed72 rsa-aes-gcm: only strip padding when required 2019-01-30 08:08:16 +08:00
Andy Green
e7aacc8510 jwk: openssl: fix key parameter ordering for older OpenSSL 2019-01-30 07:19:38 +08:00
Andy Green
658afbc658 crypto: openssl: use EVP hmac objects directly 2 2019-01-29 15:28:56 +08:00
Andy Green
849b20e594 crypto: openssl: use EVP hmac objects directly 2019-01-29 13:11:17 +08:00
Andy Green
9123ca6bef cgi: fix stdout close to http close
On h1, cgi stdout close doesn't prompt the http close, instead it
times out.  Fix that so we also close on h1, and make the close
action itself on http timeout less drastic.

As it was, GnuTLS actually marks the close as a fatal TLS error.
2019-01-29 12:25:20 +08:00
Andy Green
e0a6979082 appveyor: disable bintray
We gradually filled up the free allocation, and they don't provide any
method to delete the oldest automatically.  You literally have to sit
there deleting one artifact at a time (we create 7 per commit) using
their webui.  I'm not going to do that.

While it's full, appveyor builds will just break.

So disable it.
2019-01-28 07:38:44 +08:00
Andy Green
9c7a0f28c0 minimal examples: ws-server-threads-smp 2019-01-28 07:02:33 +08:00
Andy Green
63ad616941 gencrypto: mbedtls: manual rsa padding removal only needed on old mbedtls in optee 2019-01-27 19:38:59 +08:00
Andy Green
aada7348ea openssl: jwk: rsa: also import p and q 2019-01-27 19:21:47 +08:00
Andy Green
075b59ecaa x509: crypto tool: add alg 2019-01-27 16:25:07 +08:00
Andy Green
ed4db457c9 jwk: crypto tool: add --alg commandline arg 2019-01-27 16:08:34 +08:00
Andy Green
bedc358dde deaddrop: extend timeout as data comes in 2019-01-24 10:59:47 +08:00
Andy Green
e63b3a6348 daemonize: use pid_t
After report from Vitaly Shevtsov

https://libwebsockets.org/pipermail/libwebsockets/2019-January/007787.html
2019-01-23 18:06:32 +08:00