Skip to main content

Composition and Constant Matchers

These matchers combine other expressions or provide always-true and always-false conditions.

any_match

Purpose

Composes multiple matcher expressions and returns true when any one of them matches.

Example Configuration

- tag: any_policy_hit
type: any_match
args:
- "$lan_clients"
- "qtype AAAA"
- "!$blocked_qname"

Configuration Details

any_match uses an array[string] args list.

  • Type: array[string]; Required: yes; Default: none
  • Supported entries:
    • matcher tag references (for example "$match_tag")
    • quick-setup matcher expressions (for example "qname domain:example.com")
    • negated matcher expressions (for example "!has_resp" or "!$blocked_qname")
  • Runtime impact:
    • Evaluates entries in order and short-circuits on the first matched entry.
    • Returns false only when all entries fail.

Typical Uses

  • Reuse one logical OR matcher across multiple sequence rules.
  • Keep complex branching readable by moving OR conditions into one matcher.

string_exp

Purpose

Matches using a string expression over request and response context.

Example Configuration

- tag: match_http_path
type: string_exp
args: "url_path prefix /dns-"

It also supports a string array:

args:
- "client_ip"
- "prefix"
- "192.168."

Configuration Details

  • string_exp args can be a string or a string array.

  • Type: string or array

  • Required: yes

  • Default: none

  • Purpose: Defines the complete string expression.

  • Expression parts:

    • data source source
    • matching operator op
    • one or more arguments
  • Runtime impact:

    • Reads values from the context according to the expression and performs string matching.

Expression Format

<source> <op> <arg...>

Supported source values:

  • qname
  • qtype
  • qclass
  • rcode
  • resp_ip
  • mark
  • client_ip
  • server_name
  • url_path
  • $ENV_KEY

Supported op values:

  • eq
  • prefix
  • suffix
  • contains
  • regexp
  • zl
Notes
  • zl means zero length and is used to determine whether a string is empty.
  • regexp supports one or more regex arguments.

quick setup

- matches: "string_exp server_name suffix .example.net"

Typical Uses

  • Perform flexible matching on DoH paths, SNI, mark sets, and response IP strings.
Notes
  • In scenarios where a dedicated matcher can be used, prefer the dedicated matcher.
  • string_exp provides greater flexibility, but the readability and maintainability of the expression are usually lower than those of dedicated plugins.

_true

Purpose

Always returns true.

Example Configuration

- tag: always_true
type: _true

Configuration Details

No standalone configuration fields.

quick setup

- matches: "_true"

Typical Uses

  • Fallback match condition.
  • Testing rule order in a sequence.

_false

Purpose

Always returns false.

Example Configuration

- tag: always_false
type: _false

Configuration Details

No standalone configuration fields.

quick setup

- matches: "_false"

Typical Uses

  • Temporarily disable a branch.