Class GuardPredicateFactory
java.lang.Object
org.frontcache.guard.GuardPredicateFactory
Parses a single predicate expression from guard-rules.conf into a
GuardPredicate.
Grammar (see docs/frontcache-protection-tech-design.md):
[!] host:ip
[!] host~<regex>
[!] ua~<regex>
[!] ua-contains:<literal> (case-insensitive)
[!] client-ip:<cidr|address|@file>
[!] uri~<regex>
[!] query~<regex>
[!] url~<regex>
[!] method:<GET|POST|...>
[!] client-type:<bot|guest>
[!] cookie:<name>
[!] header:<name>[~<regex>]
[!] request-type:<toplevel|include|include-async>
rate:<limit>/<window> [bucket=<name>] [scope=<toplevel|all>] (never negated)
Regexes are compiled once, here, and matched with find() semantics - the same behaviour as
dynamic-urls.conf patterns.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhich config file a predicate is being parsed for. -
Method Summary
Modifier and TypeMethodDescriptionstatic GuardPredicatestatic GuardPredicateparse(String expression, GuardPredicateFactory.Scope scope)
-
Method Details
-
parse
- Parameters:
expression- single predicate as written in the config, e.g. "!cookie:hruc"- Returns:
- compiled predicate
- Throws:
GuardConfigException- on unknown predicate type or invalid regex
-
parse
- Parameters:
expression- single predicate as written in the config, e.g. "!cookie:hruc"scope- which file it came from - seeGuardPredicateFactory.Scope- Returns:
- compiled predicate
- Throws:
GuardConfigException- on unknown predicate type or invalid regex
-