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

488 commits

Author SHA1 Message Date
Andy Green
c83afc66e6 refactor: subdirs for source in lib
Split out some optional code into own sources to
shrink down libwebsockets.c and server.c a bit
2017-10-16 17:28:37 +08:00
Andy Green
904a9c0920 http2: make usable
HTTP/2 support is now able to serve the test server, complete with
websockets, from a single vhost.

 - This works the same with both OpenSSL and mbedTLS.

 - POST is now wired up and works (also for file upload).

 - CGI is wired up and works.

 - Redirect is adapted and works

 - lwsws works.

 - URI urldecode, sanitation and argument parsing wired up for :path

valgrind clean (aside from openssl-style false uninit data usage in mbedtls send occasionally)

h2spec reports:

$ h2spec  -h 127.0.0.1 -p 7681 -t -k -o 1
...
145 tests, 145 passed, 0 skipped, 0 failed"

Incorporates:

 - "https://github.com/warmcat/libwebsockets/pull/1039
	Fixes issue with -Werror=unused-variable flag

 - 2c843a1395
	ssl: fix infinite loop on client cert verification failure

Signed-off-by: Petar Paradzik <petar.paradzik@sartura.hr>"

Caused and fixes Coverity 184887 - 184892
2017-10-16 17:13:49 +08:00
Andy Green
e67ae24d41 doxygen cleanup 2017-10-16 17:13:49 +08:00
Andy Green
46b04f4ba4 wrapper: make SSL_accept nonblocking
The mbedTLS / OpenSSL wrapper spins for the duration of the
handshake, which is a slow 31ms on my x86_64 box (by comparison
it's ~1ms on actual OpenSSL on the same box).

This doesn't change the 31ms but it stops us spinning during the
accept and has us retry on POLLIN instead like OpenSSL.

Note this also fixes the endemic mismatches in returncode
between mbedTLS and OpenSSL semantics...
2017-10-16 17:13:49 +08:00
Andy Green
4f99ccd6a8 heap instrumentation 2017-10-16 17:13:49 +08:00
Andy Green
7cff6b0cf9 add 100 Continue
https://github.com/warmcat/libwebsockets/issues/1041
2017-10-16 17:13:49 +08:00
Andy Green
fc995df480 CMake: convert all LWS_USE_... to LWS_WITH_...
Almost all the CMake options begin with LWS_WITH_..., but many of the
symbols passed to lws are LWS_USE_... , this causes neededless confusion,
compounded by the fact that a few CMake options also begin with
LWS_USE_.

This patch globally converts all LWS_USE_... to LWS_WITH_..., so there
is only one prefix to remember in both CMake and the code.

The affected public CMake options are

LWS_USE_BORINGSSL     ->  LWS_WITH_BORINGSSL
LWS_USE_CYASSL        ->  LWS_WITH_CYASSL
LWS_USE_WOLFSSL       ->  LWS_WITH_WOLFSSL
LWS_USE_MBEDTLS       ->  LWS_WITH_MBEDTLS
LWS_USE_BUNDLED_ZLIB  ->  LWS_WITH_BUNDLED_ZLIB
2017-10-16 17:13:48 +08:00
Andy Green
7597ac3766 Plugins: add ssh-base ssh server plugin 2017-10-16 16:59:57 +08:00
Andy Green
66a402cc96 cgi: also allow for generic spawn 2017-09-27 08:24:04 +08:00
Andy Green
4a0db7fbf1 LWS_CALLBACK_ADD_HEADERS: also on upgrade headers
https://github.com/warmcat/libwebsockets/issues/1028
2017-09-27 08:24:04 +08:00
Andy Green
12adb39542 lws_ring: introduce generic flexible ringbuffer abstraction 2017-09-21 08:45:56 +08:00
Andy Green
69e4433f4e add PENDING_TIMEOUT_USER_REASON_BASE 2017-09-21 08:45:56 +08:00
Andy Green
6750365393 lwsl_hexdump: always export even if debug level disabled 2017-09-21 08:45:56 +08:00
Andy Green
98df6722ea LWS_WITH_PEER_LIMITS
Introduces an optional, settable restriction on the number of
simultaneous wsi connections and ah that a single peer IP can
obtain.

The default is disabled for build, and if enabled, unlimited.

However when enabled at CMake, setting info.ip_limit_ah and / or
info.ip_limit_wsi at context creation time will enforce the limits.

Connections past the info.ip_limit_wsi limit are dropped, and
connections needing an ah are forced to stay in the ah waiting list
even when ah are available, while the peer is at the number of
ah in info.ip_limit_ah.
2017-09-19 12:09:17 +08:00
Andy Green
9b484ff507 docs: clarify difference between client and server ssl members in creation_info struct
Update test-client from the deprecated server ssl members that still work for
backwards compatibility to the preferred client-specific ones.

Remove .client_ssl_... member dependency on OPENSSL

https://github.com/warmcat/libwebsockets/issues/1022
2017-09-19 12:09:17 +08:00
Andy Green
b4673d871b docs: fix typo in lws_vhost_destroy docs 2017-09-19 12:08:31 +08:00
Andy Green
0186490fad lws-genhash
This gives you a thin api on top of your TLS library digest functions
which abstracts away whether you are using mbedtls apis or openssl
ones.  Using lws_genhash... apis the same code works either way and
the dependencies on which TLS lib is hidden.
2017-09-10 14:44:12 +08:00
Andy Green
138c8523f9 docs: add missing description of tsi on lws_service_tsi
Fixes https://github.com/warmcat/libwebsockets/issues/1017
2017-09-08 20:56:04 +08:00
Andy Green
cad115bf6b docs: add mising CALLBACK docs and some extra info
https://github.com/warmcat/libwebsockets/issues/1015
2017-09-07 09:29:09 +08:00
Andy Green
f5058fa9b7 server TLS: allow user to provide cert without using filepaths
This is a rewrite of the patch from HarishSRIB here:

https://github.com/warmcat/libwebsockets/pull/1013
2017-09-06 16:31:53 +08:00
Andy Green
d6e8459c07 vhost: allow user pointer to be attached at creation time
https://github.com/warmcat/libwebsockets/issues/1008
2017-08-29 15:37:16 +08:00
Juraj Vijtiuk
41909eac97 mbedtls: Add mbedTLS backend support 2017-08-28 20:22:20 +08:00
Andy Green
2e5110e731 cgi: provide constants for reason_bf 2017-08-26 12:15:40 +08:00
Andy Green
872e8d7e9d docs: swap _all_protocol_vhost cut and paste
https://github.com/warmcat/libwebsockets/issues/989
2017-08-16 15:21:22 +08:00
Andy Green
219a367a4c esp32: allow return of default vhost at init time 2017-08-06 06:53:38 +08:00
Andy Green
93a5b586a3 lws_callback_all_protocol_vhost_args 2017-08-05 10:38:59 +08:00
Andy Green
ba45f7cf9f ah: allow configurable ah hold timeout 2017-07-26 11:49:41 +08:00
Andy Green
09f3947b4c lws_intptr_t: fix ordering
https://github.com/warmcat/libwebsockets/issues/973
2017-07-21 19:25:41 +08:00
Andy Green
6f11c1361a lws-meta 2017-07-19 08:59:42 +08:00
Andy Green
3b0066cb3f close: make close notification go through writable
Until now we took the approach if just writing the close notification
broke something, we didn't care because we were closing the connection
anyway.

But with lws_meta, breaking stuff in the parent connection would be a
sticky problem outliving the closing child connection.

So this adds a new wsi state LWSS_WAITING_TO_SEND_CLOSE_NOTIFICATION
and makes the send go via the writable callback mechanism.
2017-07-19 08:55:57 +08:00
Andy Green
faa1526b39 lws-vhost-destroy
Adds a new api lws_vhost_destroy(struct lws_vhost *) which allows dynamic removal of vhosts.

The external api calls two parts of internal helpers that get reused for context destroy.

The second part is called deferred by 5s... this is to ensure that event library objects
composed into structs owned by the vhost all have a chance to complete their close
asynchronously.  That should happen immediately, but it requires us to return to the
event loop first.

The vhost being removed is deleted from the context vhost list by the first part, and does
not block further removals or creation during the delay for the deferred freeing of the
vhost memory.

Part 1:

 - if the vhost owned a listen socket needed by other vhosts listening on same iface + port, the listen
   socket is first handed off to another vhost so it stays alive

 - all wsi still open on the vhost are forcibly closed (including any listen socket still attached)

 - inform all active protocols on the vhost they should destroy themselves

 - remove vhost from context vhost list (can no longer be found by incoming connections)

 - add to a "being destroyed" context list and schedule the second part to be called in 5s

Part 2:

 - remove us from the being destroyed list

 - free all allocations owned by the vhost

 - zero down the vhost and free the vhost itself


In libwebsockets-test-server, you can send it a SIGUSR1 to have it toggle the creation and destruction of
a second vhost on port + 1.
2017-07-19 08:51:43 +08:00
Andy Green
632a0acc99 clean: fixes for appveyor warnings 2017-07-19 04:25:20 +08:00
Andy Green
a15007269e libuv: add helper for clean valgrind with foreign loop 2017-07-19 04:10:07 +08:00
Andy Green
e2a926de2f linkedlist helpers 2017-07-09 10:11:59 +08:00
Andy Green
7262e14dc1 lws_intptr_t 2017-07-07 08:32:04 +08:00
Andy Green
abc2a5cd2e windows: SO_EXCLUSIVEADDRUSE
https://github.com/warmcat/libwebsockets/issues/942
2017-06-26 08:36:49 +08:00
Andy Green
3ff720ff66 support openssl info callback
https://github.com/warmcat/libwebsockets/issues/936
2017-06-20 11:46:49 +08:00
Andy Green
581b86efd0 HTTP_PROXY: make usable 2017-06-14 09:53:09 +08:00
Andy Green
449eec9b54 client: add iface in connection info, dont use vhost iface 2017-06-14 09:45:30 +08:00
WebsocketUser
0be9e98aae win32: enable 64-bit file lengths
https://github.com/warmcat/libwebsockets/issues/916

AG added more appveyor warning cleaning and stitched in cmake tests
2017-06-09 20:20:42 +08:00
Andy Green
37053b3a9c content-length api: unsigned long to lws_filepos_t 2017-06-07 08:13:11 +08:00
Leonardo Maccari Rufino
393b38aed9 Subject: Support to bind accepted socket to device on Linux
AG: move new member to end of info,
    allow info member even on nonsupporting platform,
    document requires root,
    apply only to listen skt before we drop root,
    add -k to test server to allow testing
2017-06-07 08:13:11 +08:00
Andy Green
156363f3de capabilities support 2017-06-07 06:49:20 +08:00
Andy Ning
ce2e74e5e3 Subject: lws_stats: fix compile error on VS2013
Use LWS_INLINE instead of inline in libwebsockets.h to
make it compatible on both Linux and Windows.

Signed-off-by: Andy Ning <andy.ning@windriver.com>
2017-05-31 07:44:08 +08:00
emptyVoid
348887ea53 Subject: Direct extension confirmation to the negotiated protocol's callback
Fixes #897

Notice this means if you want to globally ban an extension, you should
no longer include the extension at context creation time.
2017-05-29 08:30:26 +08:00
Andy Green
c28f436098 esp32: led network state helper 2017-05-21 07:33:09 +08:00
Andy Green
de12c860db cgi: allow time travelling headers to decide response code
https://github.com/warmcat/libwebsockets/issues/899
2017-05-18 21:19:57 +08:00
Andy Ning
ed92b6dfe7 client: added socks5 proxy support
AG:

 - move creation info members to end of struct
 - add LWS_WITH_SOCKS5 CMake var, defaults to OFF
 - cast away some warnings about signed / unsigned in strncpy

Signed-off-by: Andy Ning <andy.ning@windriver.com>
2017-05-17 06:18:45 +08:00
Andy Green
3cf570ec52 esp32: group tracking 2017-05-16 19:35:55 +08:00
Andy Green
b778cc54ca esp32: group mdns 2017-05-14 14:55:15 +08:00