nfqueue 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nfqueue.rb +18 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4332685b28595e6de8f0af46fab3f4a3e02efc61
|
4
|
+
data.tar.gz: 0095459b9ef2e010e1a2e53403dee6278e6042e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1d11a737d43b094d59aa011c7ca4c181055ea883cc3ece3a404256ac16c483c0a0aececce2991cc582ecc336faabae933533b106d4723b7e774c670dba7c6a5
|
7
|
+
data.tar.gz: 41a56e9825c070496972e92afdac059c2b1a189c8a6af9cc54393c34ab836a7caaea4564b360aedc6b8c664a6c139559ce8dabeb357b32d06bb75ffbb62292b5
|
data/lib/nfqueue.rb
CHANGED
@@ -265,7 +265,24 @@ module Netfilter
|
|
265
265
|
raise QueueError, "nfq_unbind_pf has failed"
|
266
266
|
end
|
267
267
|
|
268
|
-
@
|
268
|
+
@callback = Proc.new {|packet| raise QueueError, "Undefined callback method."}
|
269
|
+
@callback_handler =
|
270
|
+
FFI::Function.new(:int, [:pointer, :pointer, :pointer, :buffer_in]) do |qhandler, nfmsg, nfad, data|
|
271
|
+
packet = Packet.new(self, nfad)
|
272
|
+
verdict = @callback[packet]
|
273
|
+
|
274
|
+
data = packet.data
|
275
|
+
|
276
|
+
Queue.nfq_set_verdict(
|
277
|
+
qhandler,
|
278
|
+
packet.id,
|
279
|
+
verdict,
|
280
|
+
data.size,
|
281
|
+
data
|
282
|
+
)
|
283
|
+
end
|
284
|
+
|
285
|
+
@qhandle = Queue.nfq_create_queue(@conn_handle, qnumber, @callback_handler, nil)
|
269
286
|
if @qhandle.null?
|
270
287
|
close
|
271
288
|
raise QueueError, "nfq_create_queue has failed" if @qhandle.null?
|
@@ -341,21 +358,6 @@ module Netfilter
|
|
341
358
|
|
342
359
|
private
|
343
360
|
|
344
|
-
def callback_handler(qhandler, nfmsg, nfad, data) #:nodoc:
|
345
|
-
packet = Packet.new(self, nfad)
|
346
|
-
verdict = @callback[packet]
|
347
|
-
|
348
|
-
data = packet.data
|
349
|
-
|
350
|
-
Queue.nfq_set_verdict(
|
351
|
-
qhandler,
|
352
|
-
packet.id,
|
353
|
-
verdict,
|
354
|
-
data.size,
|
355
|
-
data
|
356
|
-
)
|
357
|
-
end
|
358
|
-
|
359
361
|
def close #:nodoc:
|
360
362
|
Queue.nfq_close(@conn_handle)
|
361
363
|
end
|