iRule to drop or allow base on cookie value and date
I need to put together an iRule that either allows or drops traffic based on a cookie value and the day of the month. So if cookie value ends in 0,2,4,6,8 and day of the month is 2-30 (all even numbered days) then allow, else if cookie value ends in 1,3,5,7,9 and day of the month is 1-31 (all odd numbered days) then allow, else drop.
What we are doing is dropping or allowing based on a cookie value (well the last digit) and the date. Think gas rationing...
I have created iRules in the past that would allow or drop, the complexity of the logic with this is above my head.
1. Would using a datagroup would make sense based on what I read but I have never used one and am not sure where to start... Would it be a string or interger? and what would the string/interger and value be?
2. How do I reference the datagroup in the iRule? based on what I've done in the past I would write something like what is below, but that is a single value not a list of them.
when HTTP_REQUEST {
if { [HTTP::cookie exists "Cookie"] and [HTTP::cookie value "logininfo"] ends_with "X"} { and date ends_with "X"
use pool X
else drop
}
}