* src/config.c (backend_parse_servername): Don't require HTTPS.
ServerName can be used with plain HTTP backends as well.
* src/svc.c (need_rewrite): Rewrite from scratch.
* tests/poundharness.pl (http_redirect): Send original location in
X-Orig-Location header.
* tests/rewriteloc.at: Rewrite.
* tests/rewriteloc_https.at: New test.
* tests/testsuite.at: Include new test.
* tests/Makefile.am: Add new test.
* doc/pound.texi: Document changes.
Instead of being fixed at compile time, the regex flavour to use can
be selected in configuration file. Two mechanisms are provided:
the RegexType statement sets the regex type globally, for all statements
that follow it, and special matching options -posix, -pcre (or -perl),
change it for the given statement only.
New matching flag is implemented: -contain. This flag enables substring
match.
Instead of being translated to regular expressions, the -exact, -beg,
and -end flags are implemented as special matchers. Translation to
POSIX regex is needed only in case of "Host" statement, which implies
prefixing the pattern with "Host:[[:space:]]*".
* configure.ac (COND_REGEX): Remove variable.
* src/pound.h: Introduce "generic pattern" concept.
(GENPAT): New data type.
(genpat_compile): Rename to genpat_compile.
(genpat_match,genpat_free,genpat_error,genpat_nsub): New protos.
* src/config.c: New global statement: RegexType.
New matching flags: -posix, -pcre, -perl, -contain.
* src/regex_std.c: Remove.
* src/genpat.c: New source.
* src/regex_pcre.c: Rewrite as a genpat module.
* src/regex_pcre2.c: Likewise.
* tests/atlocal.in (PCRE_AVAILABLE): New variable, defined depending on
the value of COND_PCRE and COND_PCRE2 conditionals.
* tests/testsuite.at (PT_PREREQ_PCRE): New macro.
Include pcre.at and regextype.at.
* tests/Makefile.am: Add new files.
* tests/pcre.at: New test.
* tests/regextype.at: New test.
* tests/host.at: Test regexp translation depending on the flags given
(host_prefix_regex function).
* tests/poundharness.pl (preproc): Treat argument to "Host -end" as
"exact".
* tests/url.at: Test the -contain flag.
* src/extern.h (syslog_tag): New extern.
* src/pound.c (syslog_tag): New variable.
(main): Use syslog_tag, if set, and progname otherwise.
* src/config.c: New global statement: LogTag.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* configure.ac: Version 4.12.90
* doc/pound.8: Document changes.
* doc/pound.texi: Likewise.
* src/config.c: Reword the IgnoreCase deprecation message.
* src/http.c (http_status): Define the HTTP_STATUS_METHOD_NOT_ALLOWED
status.
(parse_http_request): Return HTTP_STATUS_METHOD_NOT_ALLOWED if the
method is forbidden by configuration settings.
* src/pound.h (HTTP_STATUS_METHOD_NOT_ALLOWED): New code.
* tests/err501.at: Rename to tests/err503.at. Rewrite test logic.
* tests/errfile.at: Use 405 status instead of 501.
* tests/warndep.at: Update.
* tests/xhttp.at: Expect 405 instead of 501.
New listener configuration directive MaxURI sets the maximum allowed
length of an URI.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* src/config.c (http_parsetab, https_parsetab): New statement: MaxURI.
* src/pound.h (max_req): Rename to max_req_size. All uses changed.
New field: max_uri_length.
* src/http.c (do_http): Optionally check if URI length is OK.
* tests/maxuri.at: New testcase.
* tests/Makefile.am: Add new testcase.
* tests/testsuite.at: Add new testcase.
* src/extern.h (FEATURE_DEPRECATION): New constant.
* src/config.c (PARSER_TABLE): New fields: deprecation and full_message.
(parse_statement): Warn if a deprecated statement is encountered and
the FEATURE_DEPRECATION feature is set.
Mark all deprecated statements as such.
(feature): Define the FEATURE_DEPRECATION feature.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/pound.texi: Likewise.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* src/config.c (openssl_error_at_locus_range): Change signature.
Take filename as arguent.
(conf_openssl_error): Likewise. All uses changed.
(load_cert): New function.
(https_parse_cert): Load all files from the directory.
* src/mem.c (stringbuf_truncate): New function.
* src/pound.h: New prototype.
* src/ht.h: New file.
* src/pound.h (H_APPEND): New header insertion mode.
(combinable_header_add): New proto.
Use ht.h to generate service hash tables.
Remove long unused CTRL_ definitions.
* src/Makefile.am: Add ht.h
* src/config.c: New statement CombineHeaders.
Use ht.h to generate backend hash tables.
* src/http.c (combinable_header_add, is_combinable_header): New functions.
(cs_locate_token): New function.
(http_header_list_append): Handle H_APPEND.
(http_request_read): For headers from multival_header list, coalesce
multiple headers into a single comma-separated one.
(add_forwarded_headers): Append X-Forwarded-For to the existing header,
if any.
(backend_response): Use cs_locate_token to look for values in multi-value
headers.
(do_http): Likewise. Bail out on multiple Transfer-Encoding headers.
* tests/poundharness.pl (parse_headers): Support multiple headers.
* tests/optorder.at: Fix expectation.
* tests/chunked2.at: New file.
* tests/multival.at: New file.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
* src/pound.h (be_regular): New field: servername.
* src/config.c (disable_proto): Fix improper dereferencing of call_data.
(backend_parse_servername): New function.
(backend_parsetab): New statement: ServerName.
* src/http.c (send_to_backend): Rewrite Host: header if servername is
set in the backend.
(open_backend): Set SNI if servername is set.
* doc/pound.8: Document changes.
* configure.ac: Check if struct stat has st_mtim member.
* src/bauth.c (basic_auth_internal): Use cached file content.
Re-read it if file's mtime changed.
* src/pound.h (user_pass): New struct.
(USER_PASS_HEAD): New data type.
(pass_file): New fields: mtim, head.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/bauth.c (basic_auth_internal)
(basic_auth): Get pointer to struct pass_file as argument.
* src/config.c (parse_cond_basic_auth): Initialize
cond->pwfile.
(parse_config_file): If RootJail is requested, open directories
for each struct pass_file used in conditionals.
* src/pound.h (locus_point, locus_range): New struct definitions
(from config.c)
(struct pass_file): New struct.
(SERVICE_COND): Change type of pwfile to struct pass_file.
* src/svc.c (foreach_listener, foreach_service): New functions.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/config.c (NAMED_BACKEND, NAMED_BACKEND_TABLE): New types.
(POUND_DEFAULTS): New field: named_backend_table.
(parse_backend_internal): Take start locus as additional argument.
(parse_backend): Support a form with one string label.
(service_parsetab): New statement: UseBackend.
(top_level_parsetab): New statement: Backend.
(parse_config_file): Initialize named_backend_table. Use it on
successful parse termination to resolve references to globally
defined backends and free afterwards.
* src/pound.h (BE_BACKEND_REF): New intermediate backend type.
(BACKEND): New field: v.be_name.
(foreach_backend): New proto.
* src/svc.c (foreach_backend): New function.
* tests/nb.at: New test file.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Include new test.
This introduces new service configuration statement SuppressLog, which
suppresses HTTP logging for particular classes of response status codes,
introduces new log format conversion specifier %{OBJ}L, which is expanded
to the location of the object OBJ (listener, service, or backend) in the
configuration file, and replaces specifiers %L, %R, and %S with
${listener}N, ${backend}N, and %{service}N, correspondingly.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/config.c (parse_backend_internal)
(parse_redirect_backend,parse_error_backend)
(parse_service,parse_acme,
(parse_listen_http,parse_listen_https)
(parse_control): Initialize locus field.
(canned_log_format): Change format definitions.
(parse_log_suppress): New function.
(service_parsetab): New statement: LogSuppress.
* src/log.c: Support for new specifier.
(http_log): Use log_suppress_mask to decide whether to suppress
log message.
* src/pound.c (main): Check return from listen.
* src/pound.h (BACKEND, SERVICE, LISTENER): New field: locus.
(SERVICE): New field: log_suppress_mask.
(STATUS_MASK): New define.
* tests/logsup.at: New test.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Likewise.
* tests/logfmt.at: Update formats.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* src/config.c (service_parsetab)
(http_parsetab,https_parsetab): New statements: ForwardedHeader and
TrustedIP.
* src/extern.h (forwarded_header,trusted_ips): New externs.
* src/http.c (do_http): Stash away the forwarded header before calling
the backend (which may modify it).
* src/log.c (i_forwarded_ip): New function. Try to obtain originator
IP from the forwarded header.
(http_log_spec): Use i_forwarded_ip to handle '%a'.
* src/pound.c (forwarded_header, trusted_ips): New variables.
(pound_http_destroy): Free orig_forwarded_header.
* src/pound.h (SERVICE, LISTENER): New fields: forwarded_header,
trusted_ips.
(POUND_HTTP): New field: orig_forwarded_header.
The Control statement in block form allows the user to specify socket
file mode and change its ownership.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* src/config.c (push_input): Fix diagnostic message.
(listener_alloc): Initialize mode.
(parse_control_socket,parse_control): New functions. Support
inline and block forms of the Control statement.
* src/pound.c (main): Optionally set socket mode and ownership.
* src/pound.h (LISTENER): New fields: mode and chowner.
Content of files supplied with Error statements is read at startup.
PID file and control socket are properly removed on exit even
after chroot.
* NEWS: Document changes.
* README.md: Likewise.
* doc/pound.8: Likewise.
* src/config.c (parse_error_backend): Read the file here and store
its content in error.text.
(parse_control_global): Use unlink_at_exit.
* src/http.c (error_response): Send error.text instead of opening
the file and reading it.
* src/pound.c (unlink_at_exit): New function. Arrange for the file to
be removed even in jail mode.
(pidfile_create): Use unlink_at_exit.
* src/pound.h (be_error): Replace file (file name) with text (file
content).
(unlink_file): Remove proto.
(unlink_at_exit): New proto.
* src/svc.c (str_be, backend_serialize): Reflect the changes.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/config.c (parse_statement, parse_acl): Allow for an "Include".
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Include new test.
* tests/inclscope.at: New test.
The -file option instructs the directive to treat its argument as
the name of a file to read patterns from.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* src/config.c (open_include_dir, close_include_dir)
(fopen_include): New functions.
(input_open): Use fopen_include.
(push_input): Use fstatat.
(parse_match_mode): Support the -file option.
(parse_cond_matcher): Rewrite taking into account eventual -file option
and other subtleties. All uses changed.
(top_level_parsetab): New statement: IncludeDir.
(feature): New feature: include-dir.
(pound_settings): Add include directory.
(config_parse): Use SYSCONFDIR as include directory by default.
* src/extern.h (FEATURE_INCLUDE_DIR): New feature.
* tests/fromfile.at: New test.
* tests/include.at: New test.
* tests/incldir.at: New test.
* tests/inclnest.at: New test.
* tests/Makefile.am: Add new files.
* tests/testsuite.at: Include new tests.
(PT_CONF): Pass the -W[no-]include-dir option to pound.
* tests/poundharness.pl: New options: --preproc and --include-dir.
(runner): Pass the -W[no-]include-dir option to pound.
* NEWS: Document changes.
* doc/pound.8: Document changes.
* src/config.c (parse_service): Bail out if multiple special backends
are used. Emit a warning if multiple Redirect backends are used or if
one or more redirects is mixed with regular backends.
* tests/bemix.at: New test.
* tests/Makefile.am: Add new test.
* tests/testsuite.at: Include new test.
* tests/balancing.at: Fix typo.
* src/config.c (POUND_DEFAULTS): New field: balancer.
(parse_service): Initialize balancer.
(service_parsetab,top_level_parsetab): New keyword: Balancer.
* src/pound.h (BALANCER): New type.
(SERVICE): New fields: max_pri, balancer, iwrr_round,
iwrr_cur.
(service_balancer_init): New proto.
* src/svc.c (service_lb_init)
(service_lb_select_backend): New functions.
Use service_lb_select_backend instead of rand_backend everywhere.
* tests/balancing.at: Use IWRR during testing.
* tests/prio.at: Likewise.
* tests/poundharness.pl: Used with stats request, index=N parameter
requests the percentage of requests handleb by Nth backend.
* NEWS: Document new features.
* doc/pound.8: Likewise.
* src/config.c (parse_listen_http)
(parse_listen_https): Handle optional listener name. Make sure it
is unique.
(parse_service): Make sure service name is unique.
* src/pound.h (LISTENER): New field: name.
* src/poundctl.tmpl: Show listener name, if available.
* svc.c (get_nth_listener, get_nth_service)
(get_nth_backend,ctl_getnum): Remove.
(IDENT): New data type.
(ctl_getident,locate_listener,locate_service)
(locate_backend): New functions.
(service_serialize): Represent NULL service name as null.
(listener_serialize): Add listener name.
(ctl_service,ctl_listener): Identify objects by their ids or numbers.
* NEWS: Document changes.
* doc/pound.8: Likewise.
* doc/poundctl.8: Likewise.
Mandatory percent decoding creates more problems than it solves. It
can perhaps be used optionally in request matching, but that is left
for further consideration.
* doc/pound.8: Document changes.
* src/http.c: Don't urldecode request parts.
(expand_string_to_buffer): Return -1 if invalid barckreferences or
accessors are encountered.
Don't bail out on percent-encodings.
(expand_string): Handle error return from expand_string_to_buffer.
* src/pound.h (http_request): Remove storage for decoded values.
* tests/poundharness.pl (getline): Handle undefined return gratiously.
(ParseRequest): Terminate thread on EOF.
* tests/backref.at: Update expected values.
* tests/experr.at: Likewise.
* tests/lstset.at: Likewise.
* tests/redirect.at: Likewise.
* tests/reqacc.at: Likewise.
* tests/set.at: Likewise.
Remove fragment handling: let's not meddle in the affairs of clients.
* NEWS: Reflect changes.
* doc/pound.8: Likewise.
* src/pound.h (http_request): Remove frag_raw and frag.
New field path_raw.
* src/http.c (expand_string_to_buffer): Don't allow subject
indexes after compatibility references (%N).
(urlencode): Take additional argument indicating whether the
string being encoded is a path.
(http_request_rebuild_url): Use path_raw.
(http_request_get_path): Decode path if necessary.
(http_request_free): Free path_raw.
* src/config.c: Remove fragment directives.
* tests/backref.at: Expect encoded URI.
* tests/experr.at: Likewise.
* tests/lstset.at: Remove fragment tests.
* tests/reqacc.at: Likewise.
* tests/set.at: Likewise.
Implement request accessors. Test rewrite rules.
Keep a cyclic queue of submatches
Up to 8 recent matches can be referenced in arguments to request
modification directives. The notation $N refers to the Nth sub-
expression of the most recent match. The notation $N(M) refers
to the Nth subexpression of the Mth recent match (match indexes
are 0-based). For compatibility with versions 4.4-4.5, %N is
taken to mean $N(1).
* src/http.c: Rewrite http_request support.
(match_cond): Move from svc.c. Add support for new condition types.
(rewrite_apply): New function.
(send_to_backend): Call rewrite_apply.
(expand_string_to_buffer,expand_string): New function.
(expand_url): Rewrite using expand_string_to_buffer.
(urldecode,urlencode): New functions.
(submatch_reset,submatch_queue_init)
(submatch_queue_get,submatch_queue_push)
(submatch_queue_free): New functions.
(expand_string_to_buffer): Rewrite using submatch_queue. All
uses changed.
Implement request accessors.
Fix dead loop occurring when invalid percent sequence is encountered.
(match_cond): Change signature. Use submatch_queue_push to
get new submatch slot each time it is needed.
(rewrite_rule_check, rewrite_op_apply): Change signature. All uses
changed.
(expand_string_to_buffer): Support ${N} notation
along with $N. Count accessor expansions in the return value.
(send_to_backend): Apply listener's rewrite rules.
(http_request_rebuild): Replace with three functions, invoked when
needed: http_request_rebuild_line, http_request_rebuild_url, and
http_request_rebuild_query.
(http_header_list_filter): Bugfix: revert condition.
* src/pound.c (pound_http_enqueue): Add explanatory comment.
(pound_http_destroy): Call submatch_queue_free.
* src/pound.h (query_param,QUERY_HEAD): New aggregate types.
(http_request): New fields: path, query_raw, query, frag_raw,
frag, orig_request_line, flags.
(be_redirect): Rename append_uri to has_uri, to avoid confusion.
(COND_PATH,COND_QUERY,COND_QUERY_PARAM,COND_FRAG): New cond types.
(query_param_match): New aggregate type.
(SERVICE_COND): New union member: qp.
(REWRITE_OP,REWRITE_OP_HEAD)
(REWRITE_RULE_HEAD,REWRITE_RULE): New aggregate types.
(SERVICE): New field: rewrite.
(struct submatch): Subject is allocated, so remove the const
qualifier.
(get_service): Simplify signature.
(match_cond): New proto.
(SMQ_SIZE): New constant.
(submatch_queue): New struct.
(submatch_free): Remove proto.
(submatch_queue_free): New proto.
(POUND_HTTP): Remove field sm.
New field smq.
(get_service): Change signature.
(LISTENER): Remove head_off and add_header. New field: rewrite.
(http_request): Replace "flags" field with "split".
HRF_* constants removed as well.
* src/svc.c (match_service,get_service): Change signature.
* src/config.c (input): Remove field: ready. New fields: putback
and putback_index.
(input_gettkn, input_putback): Rewrite putback handling.
New block statement: Rewrite ... [Else ...] End
New statements: Path, Query, QueryParam, Fragment,
SetHeader, DeleteHeader, SetURL, SetPath, SetQuery,
SetQueryParam, SetFragment.
Remove "AND" and "OR" block statements (these were undocumented
shortcuts for "Match AND" and "Match OR").
(parse_header_remove): New function. Handles
HeaderRemove (HeadRemove) keywords.
HeaderAdd, and AddHeader are handled as synonims of SetHeader.
LISTENERs rewrite field.
Fix formation of regular expression for matchers.
Allow for "set" statements without enclosing Rewrite block.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Likewise.
* tests/chgvis.at: New file.
* tests/reqacc.at: New file.
* tests/rwchain.at: New file.
* tests/set.at: New file.
* tests/headrem.at: Rewrite test to catch eventual bugs in
http_header_list_filter.
* NEWS: Document changes.
* doc/pound.8: Likewise.