]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sample: add a reverse_dom converter
authorManu Nicolas <e.nicolas@criteo.com>
Mon, 27 Apr 2026 14:59:01 +0000 (14:59 +0000)
committerWilly Tarreau <w@1wt.eu>
Wed, 13 May 2026 14:49:53 +0000 (16:49 +0200)
commitf4edcdf4de0369abd8d85434064722416d8c9be2
tree174d8ffacb952ac1d35dd4ed6a4fce534e21b1b8
parentf3fc68e3a20507fb4ce999ff9ff44b2bcf8e7a4c
MINOR: sample: add a reverse_dom converter

In domain-based routing and policy rules, suffix matching on hostnames is
often easier to express as a prefix match on reversed labels. A dedicated
converter makes this convenient with existing fetches and matchers.

This also has a performance benefit for large maps. Prefix string matches use
the prefix-tree index (PAT_MATCH_BEG with pat_idx_tree_pfx), while end matches
use the string-list index (PAT_MATCH_END with pat_idx_list_str), so
reversed-label lookups can avoid linear suffix scans.

This patch adds "reverse_dom", a string converter that reverses domain labels,
ignores one optional trailing dot on input, and rejects empty labels. It
intentionally leaves trailing-dot handling to the caller so configurations can
choose between exact matches, subdomain-only matches, or an explicit dotted
form built with "concat(.)" for prefix lookups.

Examples:
  example.com      -> com.example
  mail.example.com -> com.example.mail

The documentation is updated and a reg-test covers the converter itself, the
explicit dotted form for "map_beg()", and the subdomain-only "-m beg" case.
doc/configuration.txt
reg-tests/converter/reverse_dom.map [new file with mode: 0644]
reg-tests/converter/reverse_dom.vtc [new file with mode: 0644]
src/sample.c