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

134 commits

Author SHA1 Message Date
Andy Green
93d4e186c2 openssl tls1.3: allow setting ciphersuites at context creation time
https://github.com/warmcat/libwebsockets/issues/1440
2018-10-27 08:05:21 +08:00
Andy Green
d3bc2c3f4f fulltext search 2018-10-26 13:53:28 +08:00
Andy Green
a5b2248e72 lwsac
Introduce an api for efficiently dealing with allocations for
large, unknown amounts of objects.
2018-10-16 05:05:56 +08:00
Andy Green
31dfc4aa12 role: dbus
This adds support for the integrating libdbus into the lws event loop.

Unlike the other roles, lws doesn't completely adopt the fd and libdbus insists
to retain control over the fd lifecycle.  However libdbus provides apis for
foreign code (lws) to provide event loop services to libdbus for the fd.

Accordingly, unlike the other roles rx and writeable are not subsumed into
lws callback messages and the events remain the property of libdbus.

A context struct wrapper is provided that is available in the libdbus
callbacks to bridge between the lws and dbus worlds, along with
a minimal example dbus client and server.
2018-10-13 08:16:27 +08:00
Andy Green
ebed5e74cb threadpool 2018-09-11 18:27:59 +08:00
Andy Green
d58828692e http: compression methods
Add generic http compression layer eanbled at cmake with LWS_WITH_HTTP_STREAM_COMPRESSION.

This is wholly a feature of the HTTP role (used by h1 and h2 roles) and doesn't exist
outside that context.

Currently provides 'deflate' and 'br' compression methods for server side only.

'br' requires also -DLWS_WITH_HTTP_BROTLI=1 at cmake and the brotli libraries (available in
your distro already) and dev package.

Other compression methods can be added nicely using an ops struct.

The built-in file serving stuff will use this is the client says he can handle it, and the
mimetype of the file either starts with "text/" (html and css etc) or is the mimetype of
Javascript.

zlib allocates quite a bit while in use, it seems to be around 256KiB per stream.  So this
is only useful on relatively strong servers with lots of memory.  However for some usecases
where you are serving a lot of css and js assets, it's a nice help.

The patch performs special treatment for http/1.1 pipelining, since the compression is
performed on the fly the compressed content-length is not known until the end.  So for h1
only, chunked transfer-encoding is automatically added so pipelining can continue of the
connection.

For h2 the chunking is neither supported nor required, so it "just works".

User code can also request to add a compression transform before the reply headers were
sent using the new api

LWS_VISIBLE int
lws_http_compression_apply(struct lws *wsi, const char *name,
			   unsigned char **p, unsigned char *end, char decomp);

... this allows transparent compression of dynamically generated HTTP.  The requested
compression (eg, "deflate") is only applied if the client headers indicated it was
supported, otherwise it's a NOP.

Name may be NULL in which case the first compression method in the internal table at
stream.c that is mentioned as acceptable by the client will be used.

NOTE: the compression translation, same as h2 support, relies on the user code using
LWS_WRITE_HTTP and then LWS_WRITE_HTTP_FINAL on the last part written.  The internal
lws fileserving code already does this.
2018-09-02 14:43:05 +08:00
Dominyk Tiller
d2943ff866 CMakeLists: add check for new libuv header 2018-06-24 10:54:17 +08:00
Andy Green
d2bdb60a17 cgi: fix for https git server 2018-06-16 09:35:07 +08:00
21ef5f60a4 rpm: do parallel compilation during rpm builds 2018-05-26 09:20:20 +08:00
Andy Green
0b52d92d12 refactor: remove more test apps and replace with minimal-examples 2018-04-30 09:16:04 +08:00
Andy Green
a9390874c7 tcp keepalive: user TCP_USER_TIMEOUT on linux if extant
https://github.com/warmcat/libwebsockets/issues/1223
2018-04-19 16:16:48 +08:00
Andy Green
65f87efca9 pipe2 where possible 2018-04-19 16:15:10 +08:00
Andy Green
126be3ccf3 refactor role ops
This only refactors internal architecture and representations, the user
api is unaffected.
2018-04-11 13:39:42 +08:00
Andy Green
b45956fcb9 client: add alpn processing on mbedtls and openssl
This just supports "http/1.1" alpn and lets the client know it
can use keepalive earlier if it affirmitively negotiated
"http/1.1" on alpn.

mbedTLS wrapper needed a small adaptation to also allow
per-client-ssl control of the alpn negotiation list.
2018-04-06 10:38:03 +08:00
Andy Green
9cf641dece minimal: minimal-raw-adopt-tcp 2018-04-06 10:38:03 +08:00
Andy Green
eedee9c0d3 cmake: remove unused check on inttypes.h 2018-04-06 10:38:03 +08:00
Andy Green
422cbf24bd align private LWS_NO_EXTENSIONS to be same as public LWS_WITHOUT_EXTENSIONS
This is just an internal mass change of LWS_NO_EXTENSIONS to
LWS_WITHOUT_EXTENSIONS to match the public name and eliminate
all instances of LWS_NO_EXTENSIONS.
2018-04-06 10:38:03 +08:00
Andy Green
e4a3e8c4d4 LWS_WITH_MINIMAL_EXAMPLES: default-off build all minimal samples after lws for QA
This adds an lws cmake option that builds all the minimal examples as part of lws,
it's useful for QA.

It adds a macro to examples that depend on a particular lws configuration to understand
they should just null out their project definition in builds where the lws configuration
requirement is not met, and we are building as part of lws.

It also adapts all the example library additions to select the just-built-but-not-yet-installed
library in the case it is built as part of lws.  If built standalone, it now uses the cmake
platform-abstracted way to add the library requirement too.
2018-04-06 10:38:03 +08:00
Andy Green
3de2e9aa8a pthreads: build test server based on pthreads.h availability
... and fix signed / unsigned comparison
2018-03-02 09:01:22 +08:00
Andy Green
1b43ed1cba mbedtls wrapper: check for malloc.h before using
https://github.com/warmcat/libwebsockets/issues/1163
2018-01-26 07:22:35 +08:00
Andy Green
8487279e64 plat: remove esp8266
ESP32 module price is now within range of 8266 price.

ESP32 capability and OS support is hugely better than 8266,
we can support mbedtls tls, http/2 etc with ESP32.

I'm no longer testing on ESP8266... there's no more
user traffic... it's time to go.
2017-12-01 11:37:36 +08:00
Andy Green
5b74d7108b gcov: add in cmake and adapt defaults
1) Introduce LWS_WITH_GCOV to build with gcc / clang coverage instrumentation.

$ cd build
$ make clean && rm -f `find . -name "*.gcno" -o -name "*.gcda"` && make -j16 && sudo make install && sudo /usr/local/bin/libwebsockets-test-server -s
...
$ gcov `find . -name *.c.gcno | grep -v test-apps` -b | sed "/\.h.\$/,/^$/d"

The above are available in two helper scripts

 - scripts/build-gcov.sh
 - scripts/gcov.sh

2)

CMake defaults changed:

 - LWS_WITH_ZIP_FOPS: OFF
 - LWS_WITH_RANGES: OFF
 - LWS_WITHOUT_EXTENSIONS: ON
 - LWS_WITH_ZLIB: OFF

New CMake controls that default-OFF:

 - LWS_WITH_GENHASH
 - LWS_WITH_GENRSA

these are implied by LWS_WITH_JWS (which is implied by LWS_WITH_ACME)

3) rename ./lib/tls/XXX/server.c and client.c to XXX-server.c / XXX-client.c.

This is because gcov dumps its results using the .c filename part only,
the copies overwrite each other if there are different .c files in the tree
with the same filename part.

4) Add onetime test-client mode and test to ./test-apps/attack.sh

5) Add gcov howto in READMEs/README.build.md using attack.sh
2017-12-01 11:37:35 +08:00
Andy Green
00ffebfd24 tls: add x509 query api
This adds a single api on lws that allows querying elements from the
peer certificate on a connection.

The api works the same regardless of the TLS backend.
2017-11-26 19:16:17 +08:00
Andy Green
278e520479 JWK + JWS: JSON Web Keys RFC7517 + Signatures support RFC7515
This adds some optional apis around JSON Web Keys and JSON Web Signatures.

HMAC SHA256/384/512 and RSA + SHA256/384/512 are supported.

This also add a new "LWS_WITH_SELFTESTS" that enables the selftests.
2017-11-26 19:07:12 +08:00
Andy Green
89cb55ea58 tls: split out common, openssl and mbedtls code
- introduce lib/tls/mbedtls lib/tls/openssl
 - move wrapper into lib/tls/mbedtls/wrapper
 - introduce private helpers to hide backend

This patch doesn't replace or remove the wrapper, it moves it
to lib/tls/mbedtls/wrapper.

But it should be now that the ONLY functions directly consuming
wrapper apis are isolated in

  - lib/tls/mbedtls/client.c (180 lines)
  - lib/tls/mbedtls/server.c (317 lines)
  - lib/tls/mbedtls/ssl.c    (325 lines)

In particular there are no uses of openssl or mbedtls-related
constants outside of ./lib/tls any more.
2017-10-25 07:17:29 +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
4f267c515e clean up top level of project 2017-09-27 08:24:05 +08:00
Andy Green
a9e4787aee add missing CMake pieces
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-16 01:52:50 +08:00
Tomas Cejka
f35fd9789a cmake added RPM generation
Signed-off-by: Tomas Cejka <cejkat@cesnet.cz>
2013-04-11 08:38:22 +08:00
Joakim Soderberg
20aedc89c1 Fixed ssl cert generation on Windows. 2013-02-22 09:28:11 +08:00
Joakim Söderberg
6ac9709790 Added "make install" support to the CMake project.
- Does everything as the autoconf script does (I think).
- Generates SSL certs for the test-server
- Installs all test apps.
- Defaults to /usr/local/
- "DESTDIR=/bla make install" works
- Append "libwebsockets" to start of the test-app names like the autoconf stuff does.
- Only tested on OSX so far...
2013-02-19 10:14:37 +08:00
Andy Green
d169bb7de9 add FindGit.cmake
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 18:34:10 +08:00
Joakim Soderberg
4c53123677 CMake support + fixed windows build.
- Finalized CMake support (tested on windows only so far).
  - Uses a generated lws_config.h that is included in
  private-libwebsocket to pass defines, only used if CMAKE_BUILD is set.
  - Support for SSL on Windows.
  - Initial support for CyaSSL replacement of OpenSSL (This has been added
    to my older CMake-fork but haven't been tested on this version yet).
- Fixed windows build (see below for details).
- Fixed at least the 32-bit Debug build for the existing Visual Studio
  Project. (Not to keen fixing all the others when we have CMake support
  anyway (which can generate much better project files)...)
- BUGFIXES:
  - handshake.c
    - used C99 definition of handshake_0405 function
  - libwebsocket.c
    - syslog not available on windows, put in ifdefs.
    - Fixed previous known crash bug on Windows where WSAPoll in
      Ws2_32.dll would not be present, causing the poll function pointer
      being set to NULL.
    - Uninitialized variable context->listen_service_extraseen would
      result in stack overflow because of infinite recursion. Fixed by
      initializing in libwebsocket_create_context
    - SO_REUSADDR means something different on Windows compared to Unix.
    - Setting a socket to nonblocking is done differently on Windows.
      (This should probably broken out into a helper function instead)
    - lwsl_emit_syslog -> lwsl_emit_stderr on Windows.
  - private-libwebsocket.h
    - PATH_MAX is not available on Windows, define as MAX_PATH
    - Always define LWS_NO_DAEMONIZE on windows.
    - Don't define lws_latency as inline that does nothing. inline is not
      support by the Microsoft compiler, replaced with an empty define
      instead. (It's __inline in MSVC)
  - server.c
    - Fixed nonblock call on windows
  - test-ping.c
    - Don't use C99 features (Microsoft compiler does not support it).
    - Move non-win32 headers into ifdefs.
    - Skip use of sighandler on Windows.
  - test-server.c
    - ifdef syslog parts on Windows.
2013-02-06 15:49:12 +09:00