Forum Discussion
jrmorris_151361
Aug 07, 2015Nimbostratus
Thanks Patrik,
I applied the metatableentry to the connection limit irule, and added the new irule you sent in a separate VS. The page is getting a connection reset. And I see the following error in the logs.
TCL error: /Common/TEST_View_Tables_2 - can't read "key": no such variable while executing "foreach $key [table keys -subtable $tablename] { set value [table lookup -notouch -subtable $key] set response "$response
..." ("foreach" body line 3) invoked from within "foreach tablename [table keys -subtable "metatable"] { foreach $key [table keys -subtable $tablename] { set value [table lookup -..."
Here are my iRules:
when CLIENT_ACCEPTED {
set tbl "connlimit:[IP::client_addr]"
set key "[TCP::client_port]"
table set -subtable metatable "connlimit:[IP::client_addr]" 1
table set -subtable $tbl $key "ignored" 180
if { [table keys -subtable $tbl -count] > 5000 } {
table delete -subtable $tbl $key
event CLIENT_CLOSED disable
reject
} else {
set timer [after 60000 -periodic { table lookup -subtable $tbl $key }]
}
}
when CLIENT_CLOSED {
after cancel $timer
table delete -subtable $tbl $key
}
when HTTP_REQUEST {
set response ""
foreach tablename [table keys -subtable "metatable"] {
foreach $key [table keys -subtable $tablename] {
set value [table lookup -notouch -subtable $key]
set response "$response
$key = $value"
}
}
HTTP::respond 200 content $response
}