1
0
mirror of https://github.com/graygnuorg/pound.git synced 2026-10-23 22:28:53 +03:00

733 Commits

Author SHA1 Message Date
Sergey Poznyakoff
7e0cd61630 Version 4.23.98 2026-10-20 13:54:57 +03:00
Sergey Poznyakoff
2614d4aed3 Optional argument for the "query" accessor
* NEWS: Document changes.
* doc/pound.texi: Likewise.
* src/http.c (accessor_query): If argument is given, prefix
it to the expansion, if the query part is present.
(accessors): Change declaration of "query".
(find_accessor): Handle optional and mandatory arguments.
Return textual error description along with the NULL return.
All callers changed.
* tests/reqacc.at: Test expansion of "%[query ?]".
2026-10-20 13:30:08 +03:00
Sergey Poznyakoff
1eefb3eec1 Improvements in Emacs pound mode.
* src/pound-mode.el: Fix context recognition in corner cases.
Account for leading whitespace.
2026-10-15 10:22:01 +03:00
Sergey Poznyakoff
933ff0260f New functions for returning protocol (http/https) of objects.
* src/pound.h (backend_is_https): Argument is const *.
(backend_proto, listener_proto, pound_http_proto): New functions.
* src/http.c: Use new functions instead of inline conditionals.
* src/log.c (i_protocol): Likewise.
* src/svc.c: Likewise.
2026-10-14 17:41:46 +03:00
Sergey Poznyakoff
4c5a515612 Bugfix
* src/http.c (field_segment_len): Fix arguments to field_string_len.
* THANKS: Add John Jean.
2026-10-13 15:57:44 +03:00
Sergey Poznyakoff
3db079a961 Minor change in src/pound-mode.el. 2026-09-23 20:48:43 +03:00
Sergey Poznyakoff
7672e0f7de Raise patchlevel (4.23.97) 2026-09-22 15:28:44 +03:00
Sergey Poznyakoff
7de8081705 Fix listener blocking.
In rare cases, when the input queue had been filled up and a worker
became available after disabling the listeners, the same code could have
been run again, thus effectively unblocking them. When the actual unblock
request would arrive, the pollfd descriptors would be flipped again,
leaving the listeners blocked while the state variable indicated otherwise.

* src/pound.c (pollfd_toggle): New function.
(thr_dispatch): Remove TOGGLE_FD and SET_STATE macros.
Change state only on command received via control channel.
Treat DSP_ACCEPT and DSP_BLOCK as advisory commands, checking
actual queue state to decide whether any change is needed.
Fix handling of disabled listeners.
2026-09-22 13:01:20 +03:00
Sergey Poznyakoff
e149204100 ACME: respond with content-type: application/octet-stream
This conforms to RFC 8555, section 8.3.
2026-09-13 15:44:06 +03:00
Sergey Poznyakoff
96c6152916 Test preprocessing the included files.
* tests/ppinc.at: New file.
* tests/Makefile.am: Add new file.
* tests/testsuite.at: Likewise.
2026-09-11 11:59:03 +03:00
Sergey Poznyakoff
2154874613 Improve the docs 2026-09-11 11:54:10 +03:00
Sergey Poznyakoff
63302d502c New pragma: tab-width
* src/cfg-lex.l (tab_width): New variable.
(locus_advance): Use tab_width instead of the hardcoded value.
(parse_pragma): Handle pragma tab-width.
* NEWS: Document changes.
* doc/pound.texi: Document changes.
2026-09-11 10:18:53 +03:00
Sergey Poznyakoff
6e70b37324 Raise patchlevel (4.23.96) 2026-09-10 10:55:40 +03:00
Sergey Poznyakoff
eeae62d78e Improve the docs (Tracing chapter) 2026-09-10 09:00:13 +03:00
Sergey Poznyakoff
e23a875f16 Change representation of COND_REF in trace output. 2026-09-10 07:20:56 +03:00
Sergey Poznyakoff
d737069f62 Improve trace log format; Bugixes.
* src/http.c (match_cond): Identify conditionals by the corresponding
configuration keywords, where possible.  Fix NULL dereferences.
* src/pound.h (COND_HOST): Remove unused constant.
* doc/pound.texi: Update.
* tests/Makefile.am: Add new file.
* tests/testsuite.at: Likewise.
* tests/tracefmt.at: New file.
* tests/tracelog.at: Change expected output.
2026-09-09 18:08:30 +03:00
Sergey Poznyakoff
1e23df0d6e Bugfixes.
* src/svc.c (select_term_service): Call dumpreq only if the service
is traceable.
* src/tmpl.c (func_and, func_or): Make sure NULL is never returned.
2026-09-09 12:00:13 +03:00
Sergey Poznyakoff
fd37cbf03d Minor fixes.
* src/cfg-lex.l (parse_includedir): Initialize rc.
* src/poundctl.c (read_response_line): Ensure predictable return value
in case of error.
(read_response): Don't duplicate error message.
* src/tmpl.c (func_and, func_or): Simplify.
(json_cast_to_integer, json_cast_to_string, func_len): Abort on
unhandled input.
2026-09-08 18:32:22 +03:00
Sergey Poznyakoff
1ed8a66263 Raise patchlevel (version 4.23.95) 2026-09-08 15:42:49 +03:00
Sergey Poznyakoff
b8af053723 Fix formatting in poundctl.tmpl 2026-09-08 14:01:09 +03:00
Sergey Poznyakoff
9d0c25bb0b Document tracing.
* NEWS: Document changes.
* doc/pound.texi: Likewise.
* doc/poundctl.8: Likewise.
* src/config.c (rewrite_branch_prepare): Fix up location of the
first rewrite block.
* src/poundctl.c (command_trace): Treat missing argument as "/".
2026-09-08 13:47:54 +03:00
Sergey Poznyakoff
ef57a73c31 Improve poundctl templates for traces.
* src/poundctl.tmpl (default.print_trace,xml.print_trace): Print both
numeric and symbolic (when available) paths.
* src/svc.c: Consistently use listener_index to refer to the listener
ordinal number. Same for service_index.
* tests/ctl-trace.at: Update expected output.
2026-09-07 13:30:26 +03:00
Sergey Poznyakoff
7f344fa426 Improve trace output.
* src/http.c (match_cond): Take pointer to the trace message as
the 6th argument. All useses changed.
* src/pound.c (vlogmsg): New argument: pfx. Points to an optional
prefix to output before locus.
(tracemsg): New argument: msg.
All uses changed.
* src/pound.h (tracemsg, match_cond): Change prototypes.
* tests/tracelog.at: Change expected output.
2026-09-04 11:50:43 +03:00
Sergey Poznyakoff
0106de808f Requesting /trace operates on trace settings in all services.
* src/http.c (match_cond): Log implicit operations as well.
* src/svc.c [OBJ_TOP]: New constant.
(ctl_listener): Mark requests to / as OBJ_TOP.
(list_handler,disable_handler)
(session_remove_handler,session_add_handler)
(trace_handler): Handle OBJ_TOP.
(service_has_control,listener_has_control): Accept NULL argument.
(struct traceinfo): New field: enable.
(serialize_next): Set trace if enable is not NULL.
(trace_all_serialize): Take a pointer to the new trace value as
argument. Can be NULL to just list current settings.
(control_get_trace): Just call ctl_listener.
2026-09-04 09:43:59 +03:00
Sergey Poznyakoff
715f33e090 Bugfix
* src/pound.c (pound_http_dequeue): Don't issue unblock diagnostics
here.
(thr_dispatch): Issue unblock diagnostics after listeners have actually
been unblocked.
2026-09-04 09:32:04 +03:00
Sergey Poznyakoff
6c53f3092e Tracing of service selection and request modiification statements.
* src/pound.h (struct http_request): New field: changed.
(http_request_header_filter,http_request_header_append): New protos.
(SERVICE,REWRITE_RULE): New field: locus.
(SERVICE): New field: trace.
(LISTENER): New field: tracecnt.
(pound_http_trace): New function.
(tracemsg, dumpreq): New protos.
(rewrite_apply_rules, match_cond): Change signature.
* src/config.c (service_cond_alloc): Take pointer to locus_range as
second argument. Assign it to SERVICE_COND->locus. All uses changed.
(service_cond_append): Likewise.
(rewrite_rule_alloc,rewrite_rule_last_uncond): Likewise.
* src/http.c (http_header_list_filter): Return number of removals
performed.
(http_request_header_filter,http_request_header_append): New functions.
(http_request_rebuild_line,parse_http_request): Set changed field to 1.
(match_cond): Take trace flag as additional argument. If set, output
additional diagnostics about comparisons performed.
(add_forwarded_headers,send_to_backend): Use http_request_header_append
instead of http_header_list_append.

* src/cfg-lex.l (parse_line_directive): Fix condition.

* tests/ctl-listener.at: Update expected output.
* tests/ctl-service.at: Likewise.
* tests/ctl-trace.at: New file.
* tests/tracelog.at: New file.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Likewise.
2026-09-02 21:44:23 +03:00
Sergey Poznyakoff
c75c72c8c5 Fix in poundctl
* src/poundctl.c (read_config,scan_pound_cfg): Set include_wd
appropriately.
2026-09-01 13:31:00 +03:00
Sergey Poznyakoff
13fcf3c47b Update the testsuite 2026-09-01 13:20:22 +03:00
Sergey Poznyakoff
41c05755fc Emit syncline at the start of each config file in -E mode. 2026-09-01 13:17:21 +03:00
Sergey Poznyakoff
1d2ac1c12d Rework preprocessing support
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* doc/poundctl.8: Likewise.
* src/cfg-gram.y (T_INCLUDE, T_INCLUDEDIR): Remove terminals.
(includedir): Remove nonterminal.
(include,includedir): Remove rules.
(cfg_parse_tree): Remove useless dir argument.
All uses changed.
* src/cfg-lex.l (preproc_argv, preproc_argc): Now static.
(pragma_preproc_suppress): New static.
(skip_prefix): New function.
(parse_line_directive): Rewrite using it.
(parse_include,parse_includedir): New funtions.
(HEADERS,PP): New lexer states.
Handle "Include" and "IncludeDir" directives directly in the scanner.
Start in HEADER state.

(cfg_lex_init,cfg_open_input): Remove useless argument.
All uses changed.
(cfg_lex_preproc): Switch to the PP state.
(preproc_setup): New function.
(parse_pragma): New function.
* src/cfgdef.c: Remove the "preprocess" feature.
* src/cfgdef.h (include_dir, include_wd): New externs.
Moved from extern.h
(cfg_lex_init, cfg_lex_preproc_run, cfg_parse_tree): Update protos.
(preproc_argv, preproc_argc): Remove.
* src/config.c (feature): Remove "preprocess".
Remove handlers for "Include" and "IncludeDir".
* src/poundctl.c (read_config, scan_pound_cfg): Set up include_wd
prior to calling cfg_parse_tree.

* tests/poundharness.pl: New option --header.
* tests/syncline.at: New file.
* tests/syncline.at: New file.
* tests/preproc.at: New file.
* tests/eopt.at: New file.
* tests/eoptpp.at: New file.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Include new files.
2026-09-01 12:23:18 +03:00
Sergey Poznyakoff
e36f6fd4a7 Minor improvement in rewrite parser
* src/config.c (rw_defn): Add an entry for "early".
* src/cfg-gram.y (rewrite_begin): Remove special case.
2026-08-26 09:40:51 +03:00
Sergey Poznyakoff
6d23280d99 Support for rewrite early in poundctl. 2026-08-26 09:40:19 +03:00
Sergey Poznyakoff
72938fc64d Version 4.23.94 2026-08-25 12:52:37 +03:00
Sergey Poznyakoff
f550b0a8ac Fix recovery after unexpected end of file. Various fixes in poundctl.
* src/cfg-lex.l (input_close): Call yy_delete_buffer to reset
YY_CURRENT_BUFFER to NULL. This way the parser can safely be called
several times (see inctx_push), as it is in poundctl.
(skip_eol): Return 0 if safe to continue, and 1 if no more input
available.
* src/cfg-gram.y (skip_eol): New rule. Use it in all rules instead
of direct call to skip_eol. This makes sure yylex won't be called with
NULL buffer.
* src/cfgdef.c (enable_preproc_feature, set_include_dir): Functions
moved here from config.c
* src/cfgdef.h (enable_preproc_feature, set_include_dir): New protos.
* src/poundctl.c: Add include-dir and preprocess features.

* doc/pound.texi: Document the -W option to poundctl.
* doc/poundctl.8: Likewise.
2026-08-25 12:48:50 +03:00
Sergey Poznyakoff
00625f865c Fix logging of unnamed UNIX addresses.
* src/pound.c (thr_dispatch): Replace unnamed UNIX addresses with the
listener address.
* src/svc.c (addr2str): Fix handling of unnamed UNIX addresses.
2026-08-24 11:47:44 +03:00
Sergey Poznyakoff
fc3c976a59 Invalidate cached conditions after fall-through sections and early rewrites.
Re-implement nested rewrites.

* doc/pound.texi: Explicitly mention that rewrite sections can be
nested.
* src/cfg-gram.y (find_rewrite_defn): Return NULL on failure.
(rewrite_begin): Determine default target from the data field
of the CFG_DEFN structure.
* src/config.c (http_request_eval_reset): New function.
(rw_req_defn, rw_resp_defn): Allow for nested Rewrite sections.
(svc_defn, http_common): Store the default rewrite target in the
date field.

* src/http.c (rewrite_apply_rules): Invalidate cached evaluations after
processing early rewrites.
* src/pound.h (http_request_eval_reset): New proto.
* src/svc.c (select_term_service): Invalidate cached evaluations.

* tests/Makefile.am: Add new tests.
* tests/resprwnest.at: Likewise.
* tests/rwchain.at: New test.
* tests/rwearly.at: New test.
* tests/rwnest.at: New test.
2026-08-22 16:23:15 +03:00
Sergey Poznyakoff
93e07b5912 Early rewrites
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.

* src/pound.h (REWRITE_EARLY, REWRITE_MAX): New constants.
(struct _service, struct _listener): Change rewrite array
dimensions.
(rewrite_apply_rules): New proto.
* src/cfg-gram.y (rewrite_begin): Handle the "early" modifier.
* src/config.c (listener_alloc): Initialize all rewrites.
(service_rewrite_prepare): Handle REWRITE_EARLY.
* src/http.c (rewrite_apply_rules): Change to extern.
(http_process_request): Apply early listener rewrites.
* src/svc.c (select_term_service): Apply per-service early rewrites.
* src/pound-mode.el: Expect "early" after "Rewrite".
2026-08-21 13:25:27 +03:00
Sergey Poznyakoff
5430a224b0 Fix typos 2026-08-21 11:15:42 +03:00
Sergey Poznyakoff
6646ef3ea2 Version 4.23.93 2026-08-14 16:03:14 +03:00
Sergey Poznyakoff
93e2e7c4bc Improve logging of durations
* src/pound.h (timespec_is_null): New function.
(POUND_HTTP): Replace individual timespecs with an array of such.
* src/http.c (phttp_gettime): New function. Use it instead of
clock_gettime when necessary.
(http_process_request): Save TS_SELECT time.
(do_http): Set arg->ts immediately before reading the request.
Set TS_REQ_END afterwards.  Set TS_RESP_END when finished sending
the response.
* src/log.c: Print "-" if one of the timestamps involved in %{}D or
%{}T output is null.
(p_process_time): New prefix: reqend.
(p_duration): New prefixes: header, resp.

* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
2026-08-14 11:42:25 +03:00
Sergey Poznyakoff
edc945ab14 Fix previous commit: take into account tls.
* src/http.c (set_callback): Return pointer to the callbacke argument.
(open_backend, do_http): Restore arg->ts after handshake.
2026-08-14 01:13:50 +03:00
Sergey Poznyakoff
cad1bc0a99 Optional prefixes in %T and %D log conversions.
The prefix in T indicates start of the time interval: %{init:}T,
%{req:}T, or %{be:}T. That of %D conversion specifies the stage
of request processing whose duration is required.

* src/pound.h (POUND_HTTP): New field: start_init.
* src/http.c (BIO_ARG): New fields: ts and cmd.
(bio_callback): Initialize ts upon receiving or sending the
first byte, depending on the value of cmd.
(set_callback): Take two additional arguments: pointer to
the timespec and callback command value. All uses changed.
(do_tunnel): Initialize timespecs properly.
(do_http): Likewise.
* src/log.c (struct http_log_instr): New field: off.
(add_instr): Take additional argument (the value of off). All
uses changed.
(select_prefix2, select_prefix): New functions.
(i_process_time_ms, i_process_time_us)
(i_process_time_s, i_process_time_f): Get start time from the
instruction argument.
(p_process_time): Accept prefixes.
(p_duration): New function.
(http_log_spec): Use p_duration to parse the D conversion.

* tests/logfmt.at: Add new tests.

* configure.ac: Raise version patchlevel number.
* NEWS: Document changes. Raise version patchlevel number.
* doc/pound.texi: Document changes.
* doc/pound.8: Likewise.
2026-08-13 23:49:34 +03:00
Sergey Poznyakoff
2509fa2329 Intoduce "beacon" conditions.
A "beacon" is a named boolean variable that can be inspected in
conditionals. Beacons can be set and cleared at runtime via the
pound control interface.  They provide a mechanism for altering
pound behavior without the need to reconfigure it.

* src/Makefile.am: Add new source.
* src/beacon.c: New file.
* src/config.c (DeclareBeacon): New global statement.
(Beacon): New conditional statement.
* src/http.c (match_cond): Handle COND_BEACON.
* src/pound-mode.el: Add new keywords.
* src/pound.h (COND_BEACON): New condition code.
(_service_cond): New field: "beacon".
(pound_beacon_declare, pound_beacon_get)
(pound_beacon_set, pound_beacon_serialize): New protos.
* src/poundctl.c: New subcommand: "beacon".
* src/poundctl.tmpl: New templates: "default.beacon" and "xml.beacon".
* src/svc.c: New endpoint: "/beacon".

* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* doc/poundctl.8: Likewise.
* doc/poundctl.tmpl.5: Likewise.

* tests/beacon.at: New test.
* tests/Makefile.am: Add new file.
* tests/testsuite.at: Include new test.
2026-08-12 18:08:52 +03:00
Sergey Poznyakoff
4cd554bb1e Raise version number to 4.23.91 2026-08-11 19:36:51 +03:00
Sergey Poznyakoff
ab3a9bff5a Metrics: allow for null backend arrays.
This is necessary for fall-through services (see 191c765c).

* src/metrics.c (json_object_get_type): Treat json_null as compatible
with json_array or json_object.
(exposition_iterate,gen_backends_count)
(gen_backend_stats): Return 0 immediately if given json_null.
* src/json.c: Treat json_null as a valid json_array or json_object.
This is not strictly necessary for purposes of this commit, it is
rather done for future use.
(json_array_insert, json_array_append, json_array_set): Promote
json_null to json_array as necessary.
(json_array_get): Return ENOENT if jv is of json_null type.
(json_object_set): Promote json_null to json_object as necessary.
(json_object_get): Return ENOENT if obj is of json_null type.
(json_object_filter): Return 0 immediately if given json_null.

* doc/pound.texi: Fix definition descriptor.
2026-08-11 19:29:49 +03:00
Sergey Poznyakoff
1d39a6dd9d Fixes in pound-mode
* src/pound-mode.el (service-top, control-top)
(backend-top, default-top): Restore initial position and return t
if no specific matches found (i.e. at top level).
(pound-mode): Use define-derived-mode instead of plain defun.
2026-08-10 11:06:25 +03:00
Sergey Poznyakoff
5aa6fb59de Bugfix
* src/cfg-lex.l (locate_defn): Accept NULL tables.
2026-08-01 10:16:13 +03:00
Sergey Poznyakoff
b96424f23a Implement optional configuration file preprocessing.
* src/cfg-lex.l (preproc_argv, preproc_pid): New globals.
(yylex): Handle line directives.
(struct inctx): New field: pid.
(inctx_push,inctx_pop): Save and restore preproc_pid.
(input_close): Special handling for preprocessing mode.
(cfg_open_input): Use preprocessor, if defined.
(cfg_lex_preproc): New function.
* src/watcher.c (filename_catn): Move to src/cfgdef.c
* src/cfgdef.c (popen_include): New function.
* src/cfgdef.h (cfg_lex_preproc): New proto.
(CFG_DEBUG_PREPROC): New constant.
(preproc_argc,preproc_argv): New extern.
* src/config.c (feature): New feature preprocess="cmdline" defines the
command to use for config file preprocessing.
(config_parse): New option: -E. Runs the preprocessor and prints its
output.
(print_help): Document the -E option.
* src/pound.h (popen_include,filename_catn): New proto.

* doc/pound.8: Document changes.
* doc/pound.texi: Likewise.
* NEWS: Likewise.
2026-07-10 14:18:21 +03:00
Sergey Poznyakoff
8efcf6cdb5 Minor fix 2026-07-09 14:25:35 +03:00
Sergey Poznyakoff
cc42c3d1e3 Fix description of backend.port statement in the docs. 2026-07-09 11:59:02 +03:00