Forum Discussion
Stanislas_Piro2
Cumulonimbus
May 01, 2016You can try something like that:
when RULE_INIT {
array set static::timerange {
1 {"05:30" "13:00"}
2 {"05:30" "13:00"}
3 {"05:30" "13:00"}
4 {"05:30" "13:00"}
5 {"00:00" "00:00"}
6 {"00:00" "00:00"}
7 {"05:30" "13:00"}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
set now [clock seconds]
set current_day [clock format $now -format {%u}]
lassign $static::timerange($current_day) start end
if {($now >= [clock scan $start]) && ($now < [clock scan $end])} {
set denied 0
} else {set denied 1}
} else {set denied 0}
if { $denied } {
HTTP::respond 200 content "Not Authorised! Contact AdministratorNot Authorised! Contact Administrator..."
} else {pool POOL_443}
}
you can also use day name instead of number in array...
- Ashu_AggarwalOct 18, 2020
Cirrus
: Hi, I have a similar requirement & when trying the above i-rule it looks like it blocks the access but it doesn't pick/sync with the system clock. It just keep denying the requests. Can you please suggest?
Rgds/Ashu
- Stan_PIRON_F5Oct 19, 2020
Employee
I don't remember if this code used GMT or local timezone..
The comment I wrote above says lassign is not supported... try the code above.