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

58 commits

Author SHA1 Message Date
Andy Green
0c8dbadc1f examples-lowlevel: ws-server: pvo for WITH_PLUGINS 2021-11-02 07:25:05 +00:00
Andy Green
ee15b82b6e cmake: unbreak LWS_WITH_SYS_STATE disabled build 2021-10-05 07:40:17 +01:00
Andy Green
0fda90c40a ws-server-threads-smp: modernize 2021-10-05 07:40:03 +01:00
Andy Green
fabe78d222 Wextra
Add -Wextra (with -Wno-unused-parameter) to unix builds in addition to
-Wall -Werror.

This can successfully build everything in Sai without warnings / errors.
2021-07-04 10:29:54 +01:00
Andy Green
f22f7d91a2 minimal-ws-raw-proxy 2021-03-04 21:26:03 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
1d8be99cff cmake: latest cmake shows dep warnings for scripts < 2.8.12 2020-12-06 19:44:54 +00:00
Mykola Stryebkov
a03181301d smp: minimal client with several active connections 2020-11-28 10:58:38 +00:00
Mykola Stryebkov
89f4b739e1 minimal: smp + foreign: libuv foreign loops
AG: various fixes and adaptation of test protocol to use ring lock
to protect global wsi list against modifications from other threads
while in use
2020-10-05 08:39:05 +01:00
Andy Green
d98101d1e3 plugins: generalize and provide public api
Move the common plugin scanning dir stuff to be based on lws_dir, which
already builds for windows.  Previously this was done via dirent for unix
and libuv for windows.

Reduce the dl plat stuff to just wrap instantiation and destruction of
dynlibs, establish common code in lib/misc/dir.c for plugin scanning
itself.

Migrate the libuv windows dl stuff to windows-plugins.c, so that he's
available even if later libuv loop support becomes and event lib plugin.

Remove the existing api exports scheme for plugins, just export a const struct
now which has a fixed header type but then whatever you want afterwards depending
on the class / purpose of the plugin.  Place a "class" string in the header so
there can be different kinds of plugins implying different types exported.

Make the plugin apis public and add support for filter by class string, and
per instantation / destruction callbacks so the subclassed header type can
do its thing for the plugin class.  The user provides a linked-list base
for his class of plugins, so he can manage them completely separately and
in user code / user export types.

Rip out some last hangers-on from generic sessions / tables.

This is all aimed at making the plugins support general enough so it can
provide event lib plugins later.
2020-08-31 16:51:37 +01:00
Andy Green
1ebe27e38f cmake: mark all the subprojects as explicitly C
We don't need a C++ compiler but if we don't spell it out, cmake
assumes it C + C++ compiler needed.
2020-08-31 16:51:36 +01:00
Andy Green
6747ab830e content_info: make members conditional 2020-06-18 08:29:43 +01:00
Andy Green
b324f0e43b cmake: provide LIBWEBSOCKETS_DEP_LIBS in CONFIG 2020-06-16 19:45:35 +01:00
Andy Green
286cf4357a sul: multiple timer domains
Adapt the pt sul owner list to be an array, and define two different lists,
one that acts like before and is the default for existing users, and another
that has the ability to cooperate with systemwide suspend to restrict the
interval spent suspended so that it will wake in time for the earliest
thing on this wake-suspend sul list.

Clean the api a bit and add lws_sul_cancel() that only needs the sul as the
argument.

Add a flag for client creation info to indicate that this client connection
is important enough that, eg, validity checking it to detect silently dead
connections should go on the wake-suspend sul list.  That flag is exposed in
secure streams policy so it can be added to a streamtype with
"swake_validity": true

Deprecate out the old vhost timer stuff that predates sul.  Add a flag
LWS_WITH_DEPRECATED_THINGS in cmake so users can get it back temporarily
before it will be removed in a v4.2.

Adapt all remaining in-tree users of it to use explicit suls.
2020-06-02 08:37:10 +01:00
Andy Green
b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
Andy Green
280c81278d ws: remove now unused ws_ping_pong_interval
https://github.com/warmcat/libwebsockets/issues/1915
2020-05-27 08:40:12 +01:00
Andy Green
d3308df40f windows: pthreads
Add support for external pthreads lib on windows and some docs about how to do.

It can build with LWS_WITH_THREADPOOL and LWS_WITH_MINIMAL_EXAMPLES including the
pthreads-dependent ones without warnings or errors on windows platform as well with this.

pthreads_t can be anything, including a struct - not a pointer-to-a-struct
but the struct itself.  These can't be cast to a void * for printing as they can
on linux, where the base type is a pointer.

Let's fix all the usage of those to determine their own thread index in terms
of the meaning to the program rather than as a tid.
2020-04-07 14:05:21 +01:00
Andy Green
954fcf2bc3 windows: clean LWS_WITH_MINIMAL_EXAMPLES warnings
Fix pthreads detection in the minimal examples and add it where needed.
Fix unistd.h include to be conditional on not WIN32

With this, -DLWS_WITH_MINIMAL_EXAMPLES=1 is happy and warning-free
on windows.
2020-04-07 10:09:51 +01:00
Andy Green
fb3fd499e3 threadpool: allow multiple threadpool tasks to bind to same wsi 2020-04-04 10:47:11 +01:00
Andy Green
4f6143fff0 lws logo: update minimal examples 2020-03-06 04:46:39 +00:00
Andy Green
d88d41090e cleaning: windows 2020-03-04 12:17:49 +00:00
Andy Green
5055096e47 clean: codacy 2020-01-14 10:06:26 +00:00
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +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
6a6f365ce7 semmle: fix warnings
They're all cosmetic or minor js stuff.

Add related shield.io icons to README.
2019-09-22 09:35:07 -07:00
Andy Green
f9f6bb66fe lws_validity: unified connection validity tracking
Refactor everything around ping / pong handling in ws and h2, so there
is instead a protocol-independent validity lws_sul tracking how long it
has been since the last exchange that confirms the operation of the
network connection in both directions.

Clean out periodic role callback and replace the last two role users
with discrete lws_sul for each pt.
2019-09-22 09:35:07 -07: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
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
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
7ca8b77f2c pmd: split ebufs to track in and out 2019-05-06 07:31:32 +01:00
Andy Green
f7149e90c2 cc0: align dedication to CC0 FAQ recommended format
https://libwebsockets.org/pipermail/libwebsockets/2019-April/007937.html

thanks to Bruce Perens for noting it.

This doesn't change the intention or status of the CC0 files, they were
pure CC0 before (ie, public domain) and they are pure CC0 now.  It just
gets rid of the (C) part at the top of the dedication which may be read
to be a bit contradictory since the purpose is to make it public domain.
2019-05-02 09:29:01 +01:00
Andy Green
bb0e7d986d rx flow: handle partial flow buffer consumption
https://github.com/warmcat/libwebsockets/issues/1550

rx flow control needs to handle the situation that it is draining from
a previous rx flow control period, and the user code reasserts rx flow
control partway through that.

The accounting for the used rx then boils down to only trimming the
rxflow buflist we were "replaying" to consume however much we managed
to deliver of that this time before the rx flow control came again.

"Normal" rx consumption is wrong in this case, since we accounted for
it entirely in the rxflow cache buflist.

The patch recognizes this situation, does the accounting in the cache
buflist, and then lies to the caller that there was no rx consumption
to be accounted for at his level.
2019-04-21 19:35:18 +01:00
Andy Green
f8cd973f85 mingw: windows: make minimal examples build 2019-03-10 08:02:02 +08:00
Andy Green
9c7a0f28c0 minimal examples: ws-server-threads-smp 2019-01-28 07:02:33 +08:00
Andy Green
a1b642f4fe pmd: do not inflate 0 input length
It generates repeated byte alignments plus EOT sequences
2018-11-21 19:58:34 +08:00
Andy Green
8f2edbe822 minimal-example-pmd-corner: pmd corner case exerciser 2018-11-21 17:03:29 +08:00
Andy Green
d9f982a055 minimal examples: update for CSP best practices
1) update the logos to svg

2) add svg icon for strict security policy where used

3) define new vhost option flag to enforce sending CSP headers
   with the result code

4) add vhost option flag to minimal examples to
   enforce sending CSP where applicable

5) Go through all the affecting examples confirming they
   still work

6) add LWS_RECOMMENDED_MIN_HEADER_SPACE constant (currently
   2048) to clarify when we need a buffer to hold headers...
   with CSP the headers have become potentially a lot
   larger.
2018-11-21 17:03:29 +08:00
Andy Green
f6ae0edf8d strict host check vhost flag
https://github.com/warmcat/libwebsockets/issues/1423

If you vhost->options has the flag LWS_SERVER_OPTION_VHOST_UPG_STRICT_HOST_CHECK,
then if the server is sent an upgrade request, the content of the Host: header is
required to match the vhost name + port.  The port is set to the well-known values
of 80 and 443 if no :port on the host: value, depending on tls or not on the
connection.

minimal-ws-server can now take a -h flag to set this.  lejp-conf (eg, lwsws) can now take
a flag strict-host-check on the vhost to enable it as well.
2018-11-13 09:55:06 +08:00
Andy Green
33a6034875 codacy: minor fixes 2018-10-13 08:16:27 +08:00
Andy Green
ebed5e74cb threadpool 2018-09-11 18:27:59 +08:00
Andy Green
23e433ac1b minimal: adapt for ping test over https 2018-08-20 07:44:20 +08:00
Andy Green
d461f46a97 libwebsockets.h: clean out some boilerplate better put in core/private.h
https://github.com/warmcat/libwebsockets/issues/1370
2018-08-16 19:10:32 +08:00
chrisplusplus
2b9c69b55f Update protocol_lws_minimal_server_echo.c
This plugin will not compile as a plugin without changing
LWS_PLUGIN_PROTOCOL_MINIMAL_server_echo to
LWS_PLUGIN_PROTOCOL_MINIMAL_SERVER_ECHO
2018-07-11 15:31:22 +08:00
Andy Green
95e31cb126 minimal ring: keep coverity happy for NULL pointer possibility 2018-06-03 17:09:27 +08:00
Andy Green
412ff64be9 lws_ring: implement lagging client culling 2018-05-06 07:36:31 +08:00
Andy Green
ac6c48d98f refactor: most preparation for -DLWS_ROLE_H1=0 2018-04-27 19:16:50 +08:00
Andy Green
5d06f610a9 travis: h2spec integration 2018-04-26 15:27:02 +08:00
Andy Green
27e86e2641 cmake: allow setting LWS_ROLE_WS
You can build lws without support for ws, with -DLWS_ROLE_WS=0.

This is thanks to the role ops isolating all the ws-specific business
in the ws role.

Also retire more test apps replaced by minmal-examples.
2018-04-25 08:42:18 +08:00
Andy Green
7b227eb333 autobahn fixes
This replaces the old test-app for echo with separate client and server
minimal versions.

The autobahn test script is made more autonomous and tests both
client and server.
2018-04-22 06:45:46 +08:00
Andy Green
f0048acbee minimal: add switches and exit results 2018-04-19 16:16:48 +08:00