-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnfct-events
More file actions
executable file
·42 lines (31 loc) · 816 Bytes
/
nfct-events
File metadata and controls
executable file
·42 lines (31 loc) · 816 Bytes
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
#!/usr/bin/env lua5.1
--[[
Print events from netfilter's conntrack subsystem.
Unlike the conntrack utility's -E mode, it can print events from conntrack and
expect at the same time.
]]
require"nfct"
io.stdout:setvbuf"line"
arg[1] = arg[1] or "both"
arg[2] = arg[2] or "all"
cthandle = assert(nfct.open(unpack(arg)))
function cbct(cttype, ct)
print("ct", nfct.tostring(ct, cttype))
end
function cbexp(cttype, exp)
print("exp", nfct.exp_tostring(exp, cttype))
end
register = {
both = function()
register.conntrack()
register.expect()
end,
conntrack = function()
assert(nfct.ct_callback_register(cthandle, cbct))
end,
expect = function()
assert(nfct.exp_callback_register(cthandle, cbexp))
end
}
register[arg[1]]()
assert(nfct.catch(cthandle))