relay_core_lib/rule/engine/
compiled.rs1use ipnetwork::IpNetwork;
2use regex::Regex;
3use glob::Pattern;
4use crate::rule::Rule;
5
6#[derive(Debug)]
7pub struct CompiledRule {
8 pub original: Rule,
9 pub filter: CompiledFilter,
10}
11
12#[derive(Debug, Clone)]
13pub enum CompiledFilter {
14 All,
15 SrcIp(IpNetwork),
16 DstPort(u16),
17 Protocol(String),
18 TransparentMode(bool),
19 Url(CompiledStringMatcher),
20 Host(CompiledStringMatcher),
21 Path(CompiledStringMatcher),
22 Method(CompiledStringMatcher),
23 RequestHeader { name: String, value: Option<CompiledStringMatcher> },
24 ResponseHeader { name: String, value: Option<CompiledStringMatcher> },
25 StatusCode(u16),
26 ResponseBody(CompiledStringMatcher),
27 WebSocketMessage(CompiledStringMatcher),
28 And(Vec<CompiledFilter>),
29 Or(Vec<CompiledFilter>),
30 Not(Box<CompiledFilter>),
31 Invalid, }
33
34#[derive(Debug, Clone)]
35pub enum CompiledStringMatcher {
36 Exact(String),
37 Contains(String),
38 Prefix(String),
39 Suffix(String),
40 Regex(Regex),
41 Glob(Pattern),
42 Invalid,
43}