summaryrefslogtreecommitdiff
path: root/src/mod_wstunnel.c
Commit message (Collapse)AuthorAgeFilesLines
* [build] _WIN32 __declspec(dllexport) *_plugin_initGlenn Strauss2023-05-031-0/+1
| | | | _WIN32 __declspec(dllexport) on mod_*_plugin_init()
* [multiple] employ ck_calloc, ck_malloc shared codeGlenn Strauss2022-12-101-5/+3
| | | | | employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
* [mod_wstunnel] store value in tmp before byteswapGlenn Strauss2022-12-101-2/+5
| | | | | correct code for bigendian (if optimizer did not already detect and do the right thing)
* [multiple] mark mod_*_plugin_init() funcs coldGlenn Strauss2022-12-071-0/+2
|
* [mod_wstunnel] fix crash with bad hybivers (fixes #3165)Glenn Strauss2022-08-031-1/+4
| | | | | | | | (thx MichaƂ Dardas) x-ref: "mod_wstunnel null pointer dereference" https://redmine.lighttpd.net/issues/3165
* [multiple] immed connect to backend for streamingGlenn Strauss2022-03-251-1/+1
| | | | | | connect to backend (mod_cgi, mod_proxy, mod_sockproxy, mod_wstunnel) for streaming request body without waiting for initial data in request body. Useful for things like websockets when data starts on server-side
* [multiple] WebSockets over HTTP/2 (fixes #3151)Glenn Strauss2022-03-251-4/+14
| | | | | | | | | | | | | | | | | Add support for WebSockets over HTTP/2 to lighttpd core and to mod_cgi w/ config: cgi.upgrade = "enable" mod_proxy w/ config: proxy.header += ("upgrade" => "enable") mod_wstunnel HTTP/2 CONNECT extension defined in RFC8441 is translated to HTTP/1.1 'Upgrade: websocket' requests to mod_cgi or mod_proxy, and is handled directly in mod_wstunnel. x-ref: WebSockets over HTTP/2 https://redmine.lighttpd.net/issues/3151 Bootstrapping WebSockets with HTTP/2 https://datatracker.ietf.org/doc/html/rfc8441
* [core] remove connection_list_append()Glenn Strauss2021-09-081-1/+0
| | | | | | | | | | | | merge connection_list_append() into connection_fdwaitqueue_append() (not converted to singly-linked-list since fdwaitqueue is not expected to be used during normal operation (except extreme overload condition), so use allocated list of pointers (allocated when needed) instead of adding ptr member to (every) allocated struct connection) remove connections-glue.c remove inclusion of connections.h by non-base files
* [core] change srv->conns to doubly-linked-listGlenn Strauss2021-09-081-2/+1
| | | | avoids separate memory allocation for list of pointers
* [core] chunkqueue_append_buffer always clears bufGlenn Strauss2021-09-081-2/+2
| | | | | chunkqueue_append_buffer() always clears buffer (instead of relying on caller to do so after the call)
* [multiple] Y2038 32-bit signed time_t mitigationsGlenn Strauss2021-09-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most OS platforms have already provided solutions to Y2038 32-bit signed time_t 5 - 10 years ago (or more!) Notable exceptions are Linux i686 and FreeBSD i386. Since 32-bit systems tend to be embedded systems, and since many distros take years to pick up new software, this commit aims to provide Y2038 mitigations for lighttpd running on 32-bit systems with Y2038-unsafe 32-bit signed time_t * Y2038: lighttpd 1.4.60 and later report Y2038 safety $ lighttpd -V + Y2038 support # Y2038-SAFE $ lighttpd -V - Y2038 support (unsafe 32-bit signed time_t) # Y2038-UNSAFE * Y2038: general platform info * Y2038-SAFE: lighttpd 64-bit builds on platforms using 64-bit time_t - all major 64-bit platforms (known to this author) use 64-bit time_t * Y2038-SAFE: lighttpd 32-bit builds on platforms using 64-bit time_t - Linux x32 ABI (different from i686) - FreeBSD all 32-bit and 64-bit architectures *except* 32-bit i386 - NetBSD 6.0 (released Oct 2012) all 32-bit and 64-bit architectures - OpenBSD 5.5 (released May 2014) all 32-bit and 64-bit architectures - Microsoft Windows XP and Visual Studio 2005 (? unsure ?) Another reference suggests Visual Studio 2015 defaults to 64-bit time_t - MacOS 10.15 Catalina (released 2019) drops support for 32-bit apps * Y2038-SAFE: lighttpd 32-bit builds on platforms using 32-bit unsigned time_t - e.g. OpenVMS (unknown if lighttpd builds on this platform) * Y2038-UNSAFE: lighttpd 32-bit builds on platforms using 32-bit signed time_t - Linux 32-bit (including i686) - glibc 32-bit library support not yet available for 64-bit time_t - https://sourceware.org/glibc/wiki/Y2038ProofnessDesign - Linux kernel 5.6 on 32-bit platforms does support 64-bit time_t https://itsubuntu.com/linux-kernel-5-6-to-fix-the-year-2038-issue-unix-y2k/ - https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html "Note: at this point, 64-bit time support in dual-time configurations is work-in-progress, so for these configurations, the public API only makes the 32-bit time support available. In a later change, the public API will allow user code to choose the time size for a given compilation unit." - compiling with -D_TIME_BITS=64 currently has no effect - glibc recent (Jul 2021) mailing list discussion - https://public-inbox.org/bug-gnulib/878s2ozq70.fsf@oldenburg.str.redhat.com/T/ - FreeBSD i386 - DragonFlyBSD 32-bit * Y2038 mitigations attempted on Y2038-UNSAFE platforms (32-bit signed time_t) * lighttpd prefers system monotonic clock instead of realtime clock in places where realtime clock is not required * lighttpd treats negative time_t values as after 19 Jan 2038 03:14:07 GMT * (lighttpd presumes that lighttpd will not encounter dates before 1970 during normal operation.) * lighttpd casts struct stat st.st_mtime (and st.st_*time) through uint64_t to convert negative timestamps for comparisions with 64-bit timestamps (treating negative timestamp values as after 19 Jan 2038 03:14:07 GMT) * lighttpd provides unix_time64_t (int64_t) and * lighttpd provides struct unix_timespec64 (unix_timespec64_t) (struct timespec equivalent using unix_time64_t tv_sec member) * lighttpd provides gmtime64_r() and localtime64_r() wrappers for platforms 32-bit platforms using 32-bit time_t and lighttpd temporarily shifts the year in order to use gmtime_r() and localtime_r() (or gmtime() and localtime()) from standard libraries, before readjusting year and passing struct tm to formatting functions such as strftime() * lighttpd provides TIME64_CAST() macro to cast signed 32-bit time_t to unsigned 32-bit and then to unix_time64_t * Note: while lighttpd tries handle times past 19 Jan 2038 03:14:07 GMT on 32-bit platforms using 32-bit signed time_t, underlying libraries and underlying filesystems might not behave properly after 32-bit signed time_t overflows (19 Jan 2038 03:14:08 GMT). If a given 32-bit OS does not work properly using negative time_t values, then lighttpd likely will not work properly on that system. * Other references and blogs - https://en.wikipedia.org/wiki/Year_2038_problem - https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs - http://www.lieberbiber.de/2017/03/14/a-look-at-the-year-20362038-problems-and-time-proofness-in-various-systems/
* [multiple] use <algo>_iov() digest funcsGlenn Strauss2021-08-271-4/+2
| | | | | | | | | | | | reduce code duplication make it easier to add new algos mod_authn_file: - leverage r->tmp_buf instead of temporary allocating buffer_init() - mod_authn_file_htpasswd_basic() - compare binary SHA1 (shorter) rather than base64 (longer) - split crypt() from mod_authn_file_htpasswd_basic() to separate func - apr_md5_encode() modifications for slightly better performance
* [multiple] reduce redundant NULL buffer checksGlenn Strauss2021-08-271-23/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is a large set of code changes and results in removal of hundreds, perhaps thousands, of CPU instructions, a portion of which are on hot code paths. Most (buffer *) used by lighttpd are not NULL, especially since buffers were inlined into numerous larger structs such as request_st and chunk. In the small number of instances where that is not the case, a NULL check is often performed earlier in a function where that buffer is later used with a buffer_* func. In the handful of cases that remained, a NULL check was added, e.g. with r->http_host and r->conf.server_tag. - check for empty strings at config time and set value to NULL if blank string will be ignored at runtime; at runtime, simple pointer check for NULL can be used to check for a value that has been set and is not blank ("") - use buffer_is_blank() instead of buffer_string_is_empty(), and use buffer_is_unset() instead of buffer_is_empty(), where buffer is known not to be NULL so that NULL check can be skipped - use buffer_clen() instead of buffer_string_length() when buffer is known not to be NULL (to avoid NULL check at runtime) - use buffer_truncate() instead of buffer_string_set_length() to truncate string, and use buffer_extend() to extend Examples where buffer known not to be NULL: - cpv->v.b from config_plugin_values_init is not NULL if T_CONFIG_BOOL (though we might set it to NULL if buffer_is_blank(cpv->v.b)) - address of buffer is arg (&foo) (compiler optimizer detects this in most, but not all, cases) - buffer is checked for NULL earlier in func - buffer is accessed in same scope without a NULL check (e.g. b->ptr) internal behavior change: callers must not pass a NULL buffer to some funcs. - buffer_init_buffer() requires non-null args - buffer_copy_buffer() requires non-null args - buffer_append_string_buffer() requires non-null args - buffer_string_space() requires non-null arg
* [core] remove buffer_is_equal_right_len()Glenn Strauss2021-05-071-1/+1
| | | | (not widely used or widely useful)
* [multiple] http_header APIs to reduce str copiesGlenn Strauss2021-03-261-9/+6
|
* [multiple] prefer monotonic time for internal useGlenn Strauss2021-03-111-2/+2
| | | | | | | | Note: monotonic time does not change while VM is suspended Continue to use real time where required by HTTP protocol, for logging and for other user-visible instances, such as mod_status, as well as for external databases and caches.
* [multiple] inline chunkqueue where always alloc'dGlenn Strauss2020-10-111-12/+12
| | | | | | inline struct chunkqueue where always allocated in other structs (memory locality)
* [multiple] code reuse chunkqueue_peek_data()Glenn Strauss2020-10-111-16/+4
| | | | code reuse of chunkqueue_peek_data() and chunkqueue_read_data()
* [multiple] rename connection_reset hook to requestGlenn Strauss2020-08-021-3/+3
| | | | rename connection_reset to handle_request_reset
* [core] sys-crypto-md.h w/ inline message digest fnGlenn Strauss2020-07-081-4/+4
| | | | sys-crypto-md.h w/ inline message digest functions; shared code
* [core] stricter parse of numerical digitsGlenn Strauss2020-07-081-2/+4
| | | | | | | stricter parse of numerical digits for http status code, port num, and a few other places. (stricter parse than that of strtol()) content ranges are still parsed more loosely at points of use
* [multiple] fix some cc warnings in 32-bit, powerpcGlenn Strauss2020-07-081-14/+14
|
* [multiple] split con, request (very large change)Glenn Strauss2020-07-081-102/+101
| | | | | | | | | | | | | | | | NB: r->tmp_buf == srv->tmp_buf (pointer is copied for quicker access) NB: request read and write chunkqueues currently point to connection chunkqueues; per-request and per-connection chunkqueues are not distinct from one another con->read_queue == r->read_queue con->write_queue == r->write_queue NB: in the future, a separate connection config may be needed for connection-level module hooks. Similarly, might need to have per-request chunkqueues separate from per-connection chunkqueues. Should probably also have a request_reset() which is distinct from connection_reset().
* [core] store subrequest_handler instead of modeGlenn Strauss2020-07-081-3/+3
| | | | store pointer to module in handler_module instead of con->mode id
* [core] move plugin_ctx into (request_st *)Glenn Strauss2020-07-081-2/+2
| | | | | NB: in the future, a separate plugin_ctx may be needed for connection-level plugins to keep state across multiple requests
* [core] move addtl request-specific struct membersGlenn Strauss2020-07-081-8/+8
|
* [core] rename content_length to reqbody_lengthGlenn Strauss2020-07-081-1/+1
| | | | | | rename content_length to reqbody_length in request, to more easily differentiate request body length from response content_length
* [multiple] omit passing srv to fdevent_handlerGlenn Strauss2020-07-081-2/+2
|
* [multiple] generic config array type checkingGlenn Strauss2020-07-081-18/+3
|
* [multiple] extern log_epoch_secsGlenn Strauss2020-07-081-2/+2
| | | | replace srv->cur_ts
* [multiple] connection hooks no longer get (srv *)Glenn Strauss2020-07-081-11/+11
| | | | (explicit (server *) not passed; available in con->srv)
* [multiple] prefer (connection *) to (srv *)Glenn Strauss2020-07-081-16/+13
| | | | | | | | convert all log_error_write() to log_error() and pass (log_error_st *) use con->errh in preference to srv->errh (even though currently same) avoid passing (server *) when previously used only for logging (errh)
* [core] gw_exts_clear_check_local()Glenn Strauss2020-07-081-6/+1
|
* [mod_wstunnel] change DEBUG_LOG to use log_error()Glenn Strauss2020-07-081-103/+92
|
* [multiple] gw_backends config_plugin_values_init()Glenn Strauss2020-07-081-152/+163
|
* [core] const char *name in struct pluginGlenn Strauss2020-05-231-2/+1
| | | | | | | | put void *data (always used) as first member of struct plugin add int nconfig member to PLUGIN_DATA calloc() inits p->data to NULL
* [core] simpler config_check_cond()Glenn Strauss2020-05-231-4/+2
| | | | | | | optimize for common case where condition has been evaluated for the request and a cached result exists (also: begin isolating data_config)
* [core] add const to callers of http_header_*_get()Glenn Strauss2020-02-241-8/+8
| | | | (The few places where value is modified in-place were not made const)
* [core] inline buffer as part of data_string valueGlenn Strauss2020-02-241-2/+2
| | | | (instead of value being (buffer *))
* [core] inline buffer key for *_patch_connection()Glenn Strauss2020-02-241-7/+7
| | | | | handle buffer key as part of DATA_UNSET in *_patch_connection() (instead of key being (buffer *))
* [core] differentiate array_get_* for ro and rwGlenn Strauss2020-02-241-3/+3
| | | | | | array_get_element_klen() is now intended for read-only access array_get_data_unset() is used by config processing for r/w access array_get_buf_ptr() is used for r/w access to ds->value (string buffer)
* [core] prefer uint32_t to size_t in base.hGlenn Strauss2020-02-241-3/+3
| | | | | | | even 2 billion is way larger than even extreme operating values expected for the members in base.h include some structs directly in struct server, rather than by ptr
* [core] http_header_str_contains_token()Glenn Strauss2020-02-241-15/+2
|
* [core] use buffer_eq_icase_ssn funcGlenn Strauss2019-06-061-3/+3
| | | | | | | | | specialized buffer_eq_icase_ssn func replace strncasecmp() in cases where string lengths are not known to be at least as large as the len being compared case-insensitively. (Separate commit in case any future changes modify the implementation to be unsafe for shorter strings, where strncasecmp() would stop at '\0' in either string)
* [multiple] cleaner calloc use in SETDEFAULTS_FUNCMohammed Sadiq2019-04-201-1/+1
| | | | | | | | github: closes #99 x-ref: "cleaner calloc use in SETDEFAULTS_FUNC" https://github.com/lighttpd/lighttpd1.4/pull/99
* [mod_wstunnel] fix ping-interval for big-endian (fixes #2944)Glenn Strauss2019-04-101-1/+1
| | | | | | | | | | fix wstunnel.ping-interval for big-endian architectures (thx ste_p_james) x-ref: "[patch] wstunnel.ping-interval ineffective" https://redmine.lighttpd.net/issues/2944
* [multiple] minor: remove duplicated conditionsGlenn Strauss2019-02-101-1/+1
| | | | | | | x-ref: "PVS-Studio Analysis Results" https://redmine.lighttpd.net/boards/3/topics/8459 http://www.fly-server.ru/pvs-studio/lighttpd/
* [multiple] calloc match ptr type (clang --analyze)Glenn Strauss2019-01-211-1/+1
|
* [mod_wstunnel] use buffer_string_length()Glenn Strauss2018-11-251-1/+1
| | | | use buffer_string_length() abstraction instead of b->used
* [core] perf: simple, quick buffer_clear()Glenn Strauss2018-11-231-8/+8
| | | | | | | | | quickly clear buffer instead of buffer_string_set_length(b, 0) or buffer_reset(b). Avoids free() of large buffers about to be reused, or buffers that are module-scoped, persistent, and reused. (buffer_reset() should still be used with buffers in connection *con when the data in the buffers is supplied by external, untrusted source)