Commit Graph

4631 Commits (0b49e767b906d6861f63d3764001bd73a65265dc)

Author SHA1 Message Date
Glenn Strauss f314d2cbb9 [mod_magnet] r.req_body .collect .get .set .add 2022-05-15 23:33:20 -04:00
Glenn Strauss 3cc1509015 [mod_webdav] If-None-Match: * on non-existent
fix logic for If-None-Match: * test on non-existent entity
(regression in lighttpd 1.4.64)

If-None-Match: * should not fail on a non-existent entity,
as it may be used to make the request conditional on the
origin server having no current representation of the entity.
(see If-None-Match in RFC2616 and RFC7232)

(This logic had been changed in lighttpd 1.4.64 in
 commit 8a535e7e06
 when allowing bogus, non-'*' If-None-Match etags
 for non-existent entities to not-match (and pass the check)
2022-05-14 11:36:42 -04:00
Glenn Strauss 669ae77fb8 [mod_wolfssl] compile fix for OpenWRT 2022-05-12 06:05:44 -04:00
Glenn Strauss 15e1a2d53a [mod_magnet] quiet coverity false positive 2022-05-12 05:18:27 -04:00
Glenn Strauss 58e1b61f5b [core] feature-flag server.metrics-high-precision
server.feature-flags += ("server.metrics-high-precision" => "enable")
(default: "disable")

enables high-resolution timestamps,
currently used for request start time

This is automatically enabled if mod_accesslog log record format uses
high-resolution format specifiers in the template, but this feature
needs to be enabled if that is not the case and a high-resolution
request start time is desired for use in lua scripts run by mod_magnet,
e.g. to measure time-to-first-byte
     https://wiki.lighttpd.net/AbsoLUAtion#Time-to-First-Byte
2022-05-11 23:51:48 -04:00
Glenn Strauss 2a7d3a2751 [multiple] rename status_counter -> plugin_stats 2022-05-11 23:51:48 -04:00
Glenn Strauss 6669846947 [doc] regenerate doc/config/conf.d/mime.conf
(matches preferred syntax for Content-Type from upcoming HTTP spec rev)
2022-05-11 23:51:48 -04:00
Glenn Strauss 85b5988dc7 [multiple] use preferred syntax for Content-Type
use preferred syntax for Content-Type: .../charset=...
(match preferred syntax specified in upcoming HTTP spec revision)
2022-05-11 23:51:48 -04:00
Glenn Strauss dbfee2a299 [mod_status] display HTTP/2 control stream w/ reqs
display HTTP/2 control stream as pseudo-request in request list

HTTP/2 control stream has URI "*" from "PRI *" HTTP/2 connection preface
2022-05-11 23:51:48 -04:00
Glenn Strauss a1c664a5c5 [mod_magnet] backspace-escape encode/decode
lighty.c.bsdec
lighty.c.bsenc
lighty.c.bsenc_json
2022-05-11 23:51:48 -04:00
Glenn Strauss fc32d4c9d3 [core] buffer_append_string_c_escaped ASCII optim 2022-05-11 23:51:48 -04:00
Glenn Strauss d22e88b7d9 [core] buffer_append_bs_escaped()
move accesslog_append_escaped() to buffer_append_bs_escaped()
replace buffer_append_string_encoded_json()
2022-05-11 23:51:48 -04:00
Glenn Strauss 04f2fcf8f0 [mod_magnet] read-only access to r->server_name
read-only access to r->server_name for coverage

setting r.req_attr["uri.authority"] in lua sets both r->uri.authority
and points r->server_name to r->uri.authority, and there is not an
obvious (to me) need to be able to set r->server_name separately.

(r->server_name might be set in lighttpd.conf, or else is the same as
 r->uri.authority, unless modified by mod_simple_vhost default_host)
2022-05-11 23:51:47 -04:00
Glenn Strauss a6d40ce213 [core] remove unused srv->con_* counters 2022-05-11 23:51:47 -04:00
Glenn Strauss 2ad335f0ee [mod_accesslog] reorder fields in switch()
sort enum and switch to popular use, and have switch order match enum

split less popular format options to separate cold func
2022-05-11 23:51:47 -04:00
Glenn Strauss 2adc62e9bb [multiple] simplify bytes_in/bytes_out accounting
encapsulate accounting calculations in
 http_request_stats_bytes_in()
 http_request_stats_bytes_out()

more accurate accounting for HTTP/1.1 bytes_in on keep-alive requests
(affects case where client pipelines HTTP/1.1 requests)

remove con->bytes_read and con->bytes_written
(no longer needed since request_st was split from connection struct
 and request bytes_read_ckpt and bytes_written_ckpt are maintained
 for HTTP/1.x bytes_in and bytes_out accounting.  Also, further back,
 chunkqueue internal accounting was simplified to maintain bytes_in
 and bytes_out to always match chunkqueue length)
2022-05-11 23:51:47 -04:00
Glenn Strauss 36e6431764 [core] fix configparser_simplify_regex() comment 2022-05-11 23:51:47 -04:00
Glenn Strauss b229d028ae [mod_accesslog] remove begin/end tags from %{}t
remove begin/end tags from %{begin:...}t and %{end:...}t
as those should not be part of the strftime format string
2022-05-11 23:51:47 -04:00
Glenn Strauss f2610d23e2 [multiple] use buffer_append_char() 2022-05-11 23:51:47 -04:00
Glenn Strauss 1194e6d24b [mod_accesslog] accesslog.escaping = "json"
option to escape strings using json-compliant \uXXXX escape sequences
  accesslog.escaping = "json"
(default is accesslog.escaping = "default" or anything else for default)

additional mod_accesslog optimizations, code reuse, smaller funcs
2022-05-11 23:51:47 -04:00
Glenn Strauss f70409d2f8 [core] buffer_append_char() convenience func 2022-05-11 23:51:47 -04:00
Glenn Strauss fbefd65197 [mod_magnet] further isolate legacy API result tbl 2022-05-11 23:51:47 -04:00
Glenn Strauss 65b4997d7c [mod_magnet] adjust p->conf.stage checks 2022-05-11 23:51:47 -04:00
Glenn Strauss 404b3816a2 [mod_magnet] format multiline err traceback 2022-05-11 23:51:47 -04:00
Glenn Strauss b5490082fa [mod_magnet] lighty.c.stat high precision time
lighty.c.stat returns high precision timestamps, when available
2022-05-11 23:51:47 -04:00
Glenn Strauss c46aaa48a6 [mod_magnet] separate funcs for uri_path_raw
separate funcs to get/set uri_path_raw in target (r->target)
without modifying the query-string part of the target (r->target)
2022-05-11 23:51:47 -04:00
Glenn Strauss 3e70494df6 [mod_magnet] deprecate r.req_attr["response.*]
deprecate lighty.r.req_attr["response.*] which returned strings
These experimental interfaces were added in lighttpd 1.4.56
along with addition of config magnet.attract-response-start-to = "...",
so this only affects new users of experimental interfaces in a new hook

deprecated experimental interfaces will be removed in next lighttpd rel

replacements:
r.req_attr["response.http-status"] -> r.req_item.http_status -- (int)
r.req_attr["response.body-length"] -> r.resp_body.len        -- (int)
r.req_attr["response.body"]        -> r.resp_body.get        -- (str)
2022-05-11 23:51:47 -04:00
Glenn Strauss 4188dc2fbe [mod_magnet] lighty.r.resp_body.get
(replacement for lighty.r.req_attr["response.body"])
2022-05-11 23:51:47 -04:00
Glenn Strauss 2a71478252 [mod_magnet] lighty.c.hrtime high-resolution time 2022-05-11 23:51:47 -04:00
Glenn Strauss 360dc73f33 [mod_magnet] expose r->keep_alive to lua scripts
lighty.r.req_item.keep_alive

Allow lua scripts to set to 0 or -1.  Setting to -1 might be used when
rejecting authentication, and this value will cause lighttpd to delay
the 401 Unauthorized response if the server feature is enabled (default)
  server.feature-flags += ("auth.delay-invalid-creds" => "enable")
2022-05-11 23:51:47 -04:00
Glenn Strauss 2e04e3b109 [mod_magnet] lighty.r.req_item[] accessors
access (request_st *) struct members and statistics more directly,
e.g. integers values, as compared to lighty.r.req_attr[] strings
2022-05-11 23:51:47 -04:00
Glenn Strauss 2f233900be [mod_magnet] tighten magnet_env_set()
split remote addr and remote port out into magnet_env_set_raddr_by_id()
2022-05-11 23:51:47 -04:00
Glenn Strauss 81cd2f36b6 [mod_magnet] expose r->state to lua scripts
lighty.r.req_attr["request.stage"]  ("stage", not "state")
2022-05-11 23:51:47 -04:00
Glenn Strauss 5e0d82dc8f [core] reusable code for r->state strings
convenience macros/functions for display purposes

(historical labels from mod_status are preserved for compatibility)
2022-05-11 23:51:47 -04:00
Glenn Strauss 5471a4ba55 [mod_status] reusable code for r->state strings 2022-05-10 00:44:29 -04:00
Glenn Strauss beac48541d [mod_magnet] tighten magnet_env_get_buffer_by_id()
split server addr and server port out into magnet_env_get_laddr_by_id()
2022-05-10 00:44:29 -04:00
Glenn Strauss 5447bd5ff7 [mod_magnet] reduce magnet_env_get_id() scanning 2022-05-10 00:44:29 -04:00
Glenn Strauss 14ddf19c97 [mod_accesslog] do not double-count hdr len in %I
do not double-count HTTP/2 stream request header len in %I

(overlooked and should have been adjusted in 8fc8ab89)
2022-05-10 00:44:29 -04:00
Glenn Strauss beb029d6e2 [mod_magnet] lighty.server.* table w/ new function
(experimental)

(new interfaces are unstable and may change)
2022-05-10 00:44:29 -04:00
Glenn Strauss 1118a8af61 [mod_magnet] magnet_script_setup_global_state() fn 2022-05-07 04:02:38 -04:00
Glenn Strauss b65a7d7642 [mod_magnet] magnet_plugin_stats_table() fn 2022-05-07 04:02:38 -04:00
Glenn Strauss 14bfa016f1 [core] sketch support for abstract sockets
(experimental; untested)

Note: abstract sockets do not require filesystem access and can not be
protected using filesystem permissions; abstract sockets are accessible
by any process in the same network namespace on the same machine.

Abstract sockets can be passed to lighttpd via systemd socket activation
mechanism, via xinetd, or any other process which creates an abstract
socket and passes it to lighttpd.  Abstract sockets can also be
configured in lighttpd.conf using a backslash-escaped double-quoted
string, where CTL and chars with high bit set are backslash-escaped into
"\\xFF", with "\\x" followed by two-byte hex encoding (e.g. "FF") for
each escaped char, e.g. "\\x00abstract-socket"
2022-05-07 04:02:38 -04:00
Glenn Strauss 609f9209c8 [mod_extforward] unix domain socket pedantic chks
unix domain socket pedantic checks when received via HAProxy PROXY
protocol (and should already be enabled only from trusted upstreams)

UNIX_PATH_MAX might be different sizes in some OS, and might not be
defined.  It is 108 on Linux, but might be 104 on BSD, MacOS, so be
a bit more pendantic about checking structure sizes and assigning
the path to the sock_addr.
2022-05-07 04:02:38 -04:00
Glenn Strauss 2bde52475a [mod_magnet] no local server port on unix domain
no local server port on unix domain socket
2022-05-07 04:02:38 -04:00
Glenn Strauss 9aeed2a4b8 [mod_status] fix counting of HTTP/2 bytes written
remove usused accounting
simplify to use (64-bit) off_t for counting, but preserve doubles for
  pretty-printing numbers with decimal point and size suffix
2022-05-07 04:02:37 -04:00
Glenn Strauss ddb7f5640d [core] remove func decls duplicated in plugin.h 2022-05-06 14:03:22 -04:00
Glenn Strauss 083f42b999 [mod_setenv] cleanup user-provided hdr sloppiness
cleanup user-provided request and response headers
- remove leading and trailing whitespace from value
- replace with ' ' line ends following ',' in value
- warn if header value contains '\r' or '\n'
2022-05-06 14:03:22 -04:00
Glenn Strauss f1b6dc3f54 [mod_status] con->h2 instead of r->http_version
check con->h2 instead of r->http_version

(additional safeguard for #3152)

x-ref:
  "Random Segfaults with version 1.4.64 w/ mod_sockproxy and ALPN h2"
  https://redmine.lighttpd.net/issues/3152
2022-05-06 14:03:22 -04:00
Glenn Strauss 7e4a3215a3 [mod_magnet] rewrite lighty.r as table of userdata
rewrite lighty.r as table of methods implemented as userdata
(enable lua r table to potentially be reusable with other requests,
 instead of relying on global table to obtain (request_st *)r)

various optimizations to reduce instruction memory use
2022-05-06 14:03:19 -04:00
Glenn Strauss 570612afa6 [mod_magnet] set script env in func first upvalue
set script env in first upvalue (_ENV upvalue) for func once,
upon script init, since script-env table is preserved and reused
(and script-env is cleared between script invocations)
2022-05-05 13:35:18 -04:00