Forum Discussion
hooleylist
Dec 27, 2007Cirrostratus
You're using two array entries for each client IP: "$::users(nb,IP)" and "$::users(time,IP)". I think you could combine these to $::users(IP) = "count:timer" to save some memory.
For example, to insert a new client into the array, you could use:
set ::users($clientip) "1:$now"
To check if the client exists in the array, you could use:
if { [info exists ::users($clientip)] } {
To get the count, you could use:
getfield $::users($clientip) : 1
To increment the count, you could use:
set ::users($clientip) [incr [getfield $::users($clientip) : 1]]:$now
And to get the timeout, you could use:
if { [expr { $now - [getfield $::users($clientip) : 2] } ] > $::blocktime } {
Aaron