639 Commits (5251109517aa0d294e39bf809600343d8ff29ecb)
 

Author SHA1 Message Date
Nicolas Favre-Felix 5c223e7869
Merge pull request #198 from jessie-murray/websocket-fixes 3 years ago
Jessie Murray 1204f66ec1
Add progress thread w/ custom interval for WS test
* Start progress thread that reports once a second by default
* Customizable rate with [--interval|-i]
* Portable semaphore tested on Linux & macOS
3 years ago
Jessie Murray 69be409b87
PR review: unused code, comment style 3 years ago
Jessie Murray 03ff07252e
Clean up http_response object when write cannot be scheduled
If the client closes the connection before we can even start to respond,
the event_add will fail and we need to clean up the http_response object
since this would have happened only after we've sent the whole response.
3 years ago
Jessie Murray 273e2a918d
Log on WS client error 3 years ago
Jessie Murray 8f70db179f
Send WS handshake using event loop instead of write(2)
ws_handshake_reply was sending its response using a single write(2) call
without error-checking, which could well send only part of it and leave
the client hanging. This change creates an HTTP response object and
schedules it for writing using the event loop.

Tested with Valgrind, no memory is leaked.
3 years ago
Jessie Murray 4c0d3f4032
Refactor websocket.html to remove duplicate HTML 3 years ago
Jessie Murray 05a90b7b7a
Add "PING" button to HTML demo 3 years ago
Nicolas Favre-Felix 4471b71074
Disable pub/sub tests for now, rename curl-tests function 3 years ago
Jessie Murray e45779b303
Change TRACE log level to a value greater than was ever in webdis.json 3 years ago
Jessie Murray 3984fb968f
Validate Sec-WebSocket-Accept in WS test
1. Generate random WS connection key
2. Read headers returned in WS connection (upgrade) response
3. Validate Sec-WebSocket-Accept return value from webdis

Tested by introducing an artificial error in webdis, reported as
expected.
3 years ago
Jessie Murray d5dc3d3ff0
Add more error-checking to WS handshake code 3 years ago
Jessie Murray 657197f737
websocket test: make WS mask configurable 3 years ago
Jessie Murray fd8f0b16e0
websocket test: remove special single-threaded mode 3 years ago
Jessie Murray 9a758c6bcf
websocket test: make client sockets non-blocking 3 years ago
Jessie Murray 8141c00ab7
websocket test: formatting/indentation 3 years ago
Jessie Murray e97056f4cf
Add DEBUG=1 logic in tests/Makefile 3 years ago
Jessie Murray c4ac66f78b
Remove extra trace logs in WS-related code 3 years ago
Jessie Murray a666d52471
Requested changes: logger
* Better log level check
* Add output letter for WEBDIS_TRACE logs
3 years ago
Nicolas Favre-Felix 7cec889947
Allow manual runs of "build" GitHub Action 3 years ago
Nicolas Favre-Felix cf0f77907e
Clean up curl test 3 years ago
Nicolas Favre-Felix 2b69ead0a3
Add pub-sub test in basic.py 3 years ago
Jessie Murray b5b76c9c8f
Reduce default number of websocket messages to test for
2,500 per client with 4 clients: 10,000 total
3 years ago
Jessie Murray 665fc19126
Add max execution time to tests/websocket.c
* Add --max-time in seconds
* Break client loop when elapsed
3 years ago
Jessie Murray 2576a1606d
Websocket test: clean up usage(), exit code
* Better usage() help page
* Do not submit another frame once we've sent all we needed
3 years ago
Jessie Murray a15fb4e28e
Modernize websocket.html web page
* Use pure.css for a basic grid
* Detect disconnections, update UI accordingly
* Make GET/SET commands configurable and interactive
* Add button to clear logs
* Test with current branch
3 years ago
Jessie Murray b46bb8504b
Mark websocket http responses as keep_alive
The keep_alive flag is needed on http_response for websocket
connections. Without it, the server closes the connection as soon as a
reply to the first frame is sent.
3 years ago
Jessie Murray 71a30e9d3a
Lower default verbosity level for webdis.json
In prod config, level is even lower and does not need to change
3 years ago
Jessie Murray 873f1b5902
Add trace logs to websocket code, event loop functions
Mostly adding trace logs to websocket.c, but also some in http.c and
worker.c for events relating to event loop and client requests and
responses. This is useful for debugging websocket issues.
3 years ago
Jessie Murray 5a53c31a27
Logging improvements: add tracing, level check
* Add WEBDIS_TRACE log level for internal operations
* Warn when verbosity config is invalid
* Add slog_enabled to bypass buffer allocations if the level is filtered
3 years ago
Jessie Murray b0740d0c87
Major update of websocket test
1. Switch to evbuffer for correct handling of partial writes
2. Implement WS state machine in each worker
3. Clean up debug logging
4. Add detailed network log messages to help find WS issues
5. Switch to getopt_long
3 years ago
Jessie Murray 0a27fc7e10
More progress on evbuffer-based WS client test 3 years ago
Jessie Murray c46b85ab7a
First attempt at fixing the websocket test 3 years ago
Nicolas Favre-Felix 80139110c5
Add support for debug builds
`make` will produce a release build
`make DEBUG=1` will produce a build with debug symbols
3 years ago
Nicolas Favre-Felix 6163d3e342
Update docker images referenced in the README to the latest version 3 years ago
Nicolas Favre-Felix a0b19bac33
Version bump after release 3 years ago
Nicolas Favre-Felix 649cadcab7
Release 0.1.16
* Only process `Connection: close` header if full request was read
  (#194). This likely fixes the same issue also reported in #145.
* Fix small memory leak when the `type` query string parameter is
  used; the value was not being freed leading to growing memory usage
  of a few bytes per request. Upgrading is recommended if you use this
  feature.
* Fix invalid call to `ioctl`, which did not seem to affect Linux
  systems but could have had an impact on macOS (found in #197).
3 years ago
Nicolas Favre-Felix 950c5153d7
Fix invalid ioctl call
The `request` parameter is unsigned long, not int. This was invalid on
macOS and caused issues when sockets were considered non-blocking. Also
adds an error log if the call fails.

Thanks @likuilin for opening an issue that led to this discovery.
3 years ago
Nicolas Favre-Felix d254a72ae4
Update outdated docker image versions in README 3 years ago
Nicolas Favre-Felix 66ef564b13
Fix memory leak in `?type=...` feature
Passing `?type=foo/bar` in the query string makes Webdis return the
response with a `Content-Type: foo/bar` header (this is useful to serve
files from Webdis, e.g. web page or their dependencies such as CSS,
images, etc). I discovered with Valgrind that the *value* of this query
string parameter was leaked and never freed, which would likely not
cause a huge issue but would still gradually grow the memory usage.

There were 2 different functions taking care of this parameter, the
first calling strdup(3) on it and the second *transferring* pointer
ownership into it (meaning overwriting the just-strdup'd value).

This is now fixed, Webdis no longer leaks this small string, and an
allocation was avoided.
3 years ago
Jessie Murray 6556039e05
Only process `Connection: close` header if full request was read (fixes #194) (#195) 3 years ago
Nicolas Favre-Felix 1e4c6f8b96
Post-release README update 3 years ago
Nicolas Favre-Felix 0e6ef3f7c9
Version bump after release 3 years ago
Nicolas Favre-Felix d988eea778
Release 0.1.15
* Fixed compilation warnings
* Fixed code quality issues found by CodeQL
* Upgraded base image from alpine:3.12.6 to alpine:3.12.7
  See CWE-125 and CVE-2021-30139). This is *not* a security issue if
  you just use the webdis image to run the service, but could be if
  you're building a new Docker image using webdis as a base image.
3 years ago
Nicolas Favre-Felix e6379ada2b
Upgrade base image from alpine:3.12.6 to 3.12.7 3 years ago
Nicolas Favre-Felix c0329d7813
Remove old .gitignore from Jansson
This was causing jansson_config.h to be excluded when the repo was
cloned with certain git pull commands.
3 years ago
Jessie Murray d1f4b831d9
CodeQL fixes (#192)
* CodeQL: overrunning write in jansson/dump.c
* CodeQL: overrunning write in http.c
* CodeQL: redundant condition in websocket.c
* CodeQL: redundant condition in jansson/utf.c
* CodeQL: File created without restricting permissions in server.c
* CodeQL: Futile conditional in pool.c
* CodeQL: Too many arguments in jansson/load.c
* CodeQL: Commented-out code in http.c
* Jansson: disable truncation warning locally in error reporting function
3 years ago
Nicolas Favre-Felix 4b5923f685
Add CodeQL workflow
* Configures code scanning for C
* Adds built-in "security and quality" suite
* Imports more CodeQL queries from GitHub repo
3 years ago
Nicolas Favre-Felix 3c7431a93d
Update ECR links after getting approved for a named account 4 years ago
Nicolas Favre-Felix c8dd4bc1a6
Re-sign Docker image 4 years ago