3using System.Threading.Tasks;
62 string Endpoint = State.
Request.RemoteEndPoint.RemovePortNumber();
64 if (!IPAddress.TryParse(Endpoint, out IPAddress Address))
67 string Value = await this.value.EvaluateAsync(State.
Variables,
string.Empty);
68 string Key = Endpoint +
"|IP|" + Value;
70 if (!State.TryGetCachedObject(Key, out
bool IsMatch))
72 IsMatch = CheckMatch(Address, Value);
79 private static bool CheckMatch(IPAddress Value,
string List)
81 string[] Items = List.Split(
',', StringSplitOptions.RemoveEmptyEntries);
83 foreach (
string Item
in Items)
85 string s = Item.Trim();
92 else if (IPAddress.TryParse(s, out IPAddress Addr))
94 if (Addr.Equals(Value))
IP Address Rangee, expressed using CIDR format.
static bool TryParse(string s, out IpCidr Parsed)
Tries to parse an IP Range in CIDR format. (An IP Address alone is considered implicitly having a mas...
Checks if the requests come from a specific IP or IPs using a comma-separated list of CIDR ranges.
override async Task< WafResult?> Review(ProcessingState State)
Reviews the processing state, and returns a WAF result, if any.
override WafAction Create(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Creates a WAF action from its XML definition.
FromIp()
Checks if the requests come from a specific IP or IPs using a comma-separated list of CIDR ranges.
FromIp(XmlElement Xml, WafAction Parent, WebApplicationFirewall Document)
Checks if the requests come from a specific IP or IPs using a comma-separated list of CIDR ranges.
override string LocalName
XML Local Name for the XML element defining the action.
Abstract base class for Web Application Firewall comparisons.
Contains the current state of a review process.
Variables Variables
Set of variables.
void AddToCache(string Key, object Value)
Adds a value to the cache.
HttpRequest Request
Current HTTP Request
Abstract base class for Web Application Firewall actions.
WebApplicationFirewall Document
Web Application Firewall document.
static readonly TimeSpan fiveMinutes
Five minutes time span.
async Task< WafResult?> ReviewChildren(ProcessingState State)
Reviews the processing state, and returns a WAF result, if any.
Web Application Firewall for HttpServer.