mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-21 01:15:17 -04:00
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.
2 lines
44 B
Text
2 lines
44 B
Text
com.example. example
|
|
com.example.mail. mail
|