filter-limit.lua 1006 Bytes
Newer Older
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
util = require('awall.util')
json = require('cjson')

res = {}

function add(limit_type, base)
   for _, count in ipairs{1, 30} do
     for _, limit in ipairs{
        count, {count=count, log=false}, {count=count, log='none'}
     } do
        for _, log in ipairs{false, true, 'none'} do
           for _, action in ipairs{false, 'pass'} do
	      if not (count == 30 and log and action) then
	         table.insert(
	            res,
		    util.update(
		       util.copy(base or {}),
		       {
		          [limit_type..'-limit']=limit,
		          log=log or nil,
		          action=action or nil
		       }
		    )
                 )
             end
	   end
	 end
      end
   end
end

add('conn')
add('flow')
add('flow', {['in']='A', out='_fw', ['no-track']=true})

Kaarle Ritvanen's avatar
Kaarle Ritvanen committed
36 37 38 39 40 41 42 43
for _, measure in ipairs{'conn', 'flow'} do
   for _, addr in ipairs{'src', 'dest'} do
      table.insert(
         res, {['update-limit']={name='foo', measure=measure, addr=addr}}
      )
   end
end

44
print(json.encode{filter=res})