Dave_24664
Dec 11, 2007Nimbostratus
problem with Eduardo Saito irule_limit_num_connections_googlebot
I am new.
I tried just cutting and pasting Eduardo Saito's winning iRule into my 6400, but I get an error:
Code is:
when RULE_INIT {
array set ::active_clients { }
}
when CLIENT_ACCEPTED {
switch -glob [string tolower [HTTP::header "User-Agent"]] {
"*googlebot*" {
set client_ip [IP::remote_addr]
if { [info exists ::active_clients($client_ip)] } {
if {$::active_clients($client_ip) > 10 } {
reject
log local0. "Reject GOOGLEBOT IP $client_ip ($::active_clients($client_ip))"
return
} else {
incr ::active_clients($client_ip)
}
} else {
set ::active_clients($client_ip) 1
}
}
}
}
when CLIENT_CLOSED {
switch -glob [string tolower [HTTP::header "User-Agent"]] {
"*googlebot*" {
set client_ip [IP::remote_addr]
if { [info exists ::active_clients($client_ip)] } {
incr ::active_clients($client_ip) -1
if { $::active_clients($client_ip) <= 0 } {
unset ::active_clients($client_ip)
}
}
}
}
}
error I get is:
01070151:3: Rule [googlebot] error: line 6: [command is not valid in current event context CLIENT_ACCEPTED] [HTTP::header User-Agent] line 25: [command is not valid in current event context CLIENT_CLOSED] [HTTP::header User-Agent]
What am I doing wrong?