Skip to content

Commit 1f84251

Browse files
committed
Remove nfq.loop(), its not necessary, and wasn't working.
1 parent 5bf9039 commit 1f84251

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

nfq-test

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,26 @@ local function damage(payload)
6767
return "accept", replace
6868
end
6969

70-
local payload
70+
local h = nfq.open()
71+
nfq.unbind_pf(h, "inet")
72+
nfq.bind_pf(h, "inet")
73+
74+
local q = nfq.create_queue(h, 0)
75+
nfq.set_mode(q, copy, 0xffff)
7176

72-
nfq.loop(function (nfqdata)
77+
local payload
78+
nfq.catch(h, function (nfqdata)
7379
print("nfqdata", nfqdata)
7480

7581
local payload = nfq.get_payload(nfqdata)
7682

7783
print(h(payload))
7884

7985
--return setttl(payload)
80-
return damage(payload)
86+
return "accept", damage(payload)
8187
--return "drop"
8288
end)
8389

90+
nfq.destroy_queue(q)
91+
nfq.close(h)
92+

nfq.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ THE POSSIBILITY OF SUCH DAMAGE.
2828
/*-
2929
** nfq - a binding to netfilter's queue subsystem
3030
31+
Example usage:
32+
33+
h = nfq.open()
34+
nfq.unbind_pf(h, "inet")
35+
nfq.bind_pf(h, "inet")
36+
37+
q = nfq.create_queue(h, 0)
38+
nfq.set_mode(q, copy, 0xffff)
39+
40+
nfq.catch(h, function(nfqdata)
41+
print(string.format("%q", nfq.get_payload(nfqdata)))
42+
end)
43+
44+
nfq.destroy_queue(q)
45+
nfq.close(h)
3146
*/
3247

3348
/*

0 commit comments

Comments
 (0)