Commit 9f20f1f7 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Limit: default value for count

parent a4b108a3
...@@ -201,10 +201,10 @@ members of a top-level dictionary but are embedded into other objects. ...@@ -201,10 +201,10 @@ members of a top-level dictionary but are embedded into other objects.
In its simplest form, a limit definition is an integer specifying the In its simplest form, a limit definition is an integer specifying the
maximum number of packets or connections per second. More complex maximum number of packets or connections per second. More complex
limits are defined as objects, where the **count** attribute define limits are defined as objects, where the **count** attribute defines
the maximum during an interval defined by the **interval** the maximum during an interval defined by the **interval**
attribute. The unit of the **interval** attribute is second, and the attribute. The unit of the **interval** attribute is second, and the
default value is 1. default value is 1. The default value for **count** is 1 as well.
The maximum rate defined by a limit may be absolute or specific to The maximum rate defined by a limit may be absolute or specific to
blocks of IP addresses or pairs thereof. The number of most blocks of IP addresses or pairs thereof. The number of most
......
...@@ -784,13 +784,7 @@ end ...@@ -784,13 +784,7 @@ end
M.Limit = M.class(M.Maskable) M.Limit = M.class(M.Maskable)
function M.Limit:init(...) function M.Limit:init(...)
if not self.count then setdefault(self, 'count', self[1] or 1)
if not self[1] then
self:error('Packet count not defined for limit')
end
self.count = self[1]
end
setdefault(self, 'interval', 1) setdefault(self, 'interval', 1)
M.Limit.super(self):init(...) M.Limit.super(self):init(...)
......
...@@ -27,8 +27,8 @@ function add(limit_type, filter) ...@@ -27,8 +27,8 @@ function add(limit_type, filter)
end end
end end
local count = high_rate and 150 or 1 local count = high_rate and 150 or nil
add_limit(count) add_limit(count or 1)
for _, interval in ipairs{false, 5} do for _, interval in ipairs{false, 5} do
for _, log in ipairs{true, false, 'none'} do for _, log in ipairs{true, false, 'none'} do
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment