Class GuardPredicateFactory
java.lang.Object
org.frontcache.guard.GuardPredicateFactory
Parses a single predicate expression from guard-rules.conf into a
GuardPredicate.
Grammar (see docs/guard-getting-started.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>
[!] cookie-hmac:<name> (a valid, unexpired evidence cookie - see EvidenceCookies)
[!] header:<name>[~<regex>]
[!] request-type:<toplevel|include|include-async>
[!] edge-token (carries this node's front-cache.edge-token; guard-rules.conf only)
[!] ext:<name>[:<argument>] (a started plugin's predicate - see ExtPredicate)
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) static GuardPredicateparse(String expression, GuardPredicateFactory.Scope scope, VisitorTypes visitorTypes)
-
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
-
parse
public static GuardPredicate parse(String expression, GuardPredicateFactory.Scope scope, VisitorTypes visitorTypes) - Parameters:
visitorTypes- the vocabularyclient-type:is checked against - the node's loaded one, or, for a validator with no node (the portal), the declarations of the bots.conf beside the rules
-