1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
util = require('awall.util')
json = require('cjson')
res = {}
function add(limit_type, filter)
for _, high_rate in ipairs{false, true} do
local function add_limit(limit)
for _, log in ipairs{false, true, 'none'} do
for _, action in ipairs{false, 'pass'} do
if not (high_rate and log and action) then
table.insert(
res,
util.update(
{
[limit_type..'-limit']=util.copy(limit),
log=log or nil,
action=action or nil
},
filter or {}
)
)
end
end
end
end
local count = high_rate and 150 or nil
add_limit(count or 1)
for _, interval in ipairs{false, 5} do
for _, log in ipairs{true, false, 'none'} do
local limit = {count=count, interval=interval or nil}
if log ~= true then limit.log = log end
add_limit(limit)
if not high_rate then
limit.name = 'A'
for _, addr in ipairs{false, 'dest'} do
limit.addr = addr or nil
limit.update = nil
add_limit(limit)
limit.update = false
add_limit(limit)
end
end
end
end
end
end
add('conn', {out='B'})
add('flow')
add('flow', {['in']='A', out='_fw', ['no-track']=true})
table.insert(res, {['update-limit']='A'})
for _, measure in ipairs{'conn', 'flow'} do
for _, addr in ipairs{'src', 'dest'} do
table.insert(
res, {['update-limit']={name='A', measure=measure, addr=addr}}
)
end
end
print(json.encode{filter=res})
|