Forum Discussion
Stanislas_Piro2
Cumulonimbus
May 03, 2016Hi,
In the first irule I provided, there was an issue ...
if executing clock scan in RULE_INIT, the date will stay the day the irule was last modified or service restarted.
Try this irule :
when RULE_INIT {
array set static::timerange {
Sunday {"05:30" "16:00"}
Monday {"05:30" "16:00"}
Tuesday {"05:30" "16:00"}
Wednesday {"05:30" "16:00"}
Thursday {"05:30" "16:00"}
Friday {}
Saturday {}
}
}
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] contains "/contractor/") } {
if {!([class match [IP::remote_addr] equals clntip])} {set denied 1}
set now [clock seconds]
set current_day [clock format $now -format {%A}]
set start [lindex $static::timerange($current_day) 0]
set end [lindex $static::timerange($current_day) 1]
if {($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end])} {
set denied 0
} else {set denied 1}
unset start end
} else {set denied 0}
if { $denied } {
HTTP::respond 200 content "Not Authorised! Contact AdministratorNot Authorised! Contact Administrator..."
} else {pool POOL_443}
unset denied
}