25
25
try:
26
26
nfqueue.run()
27
27
except KeyboardInterrupt:
28
- print
28
+ print('')
29
29
30
30
nfqueue.unbind()
31
31
@@ -85,7 +85,7 @@ NetfilterQueue objects
85
85
A NetfilterQueue object represents a single queue. Configure your queue with
86
86
a call to ``bind ``, then start receiving packets with a call to ``run ``.
87
87
88
- ``QueueHandler.bind(queue_num, callback[, max_len[, mode[, range]]]) ``
88
+ ``QueueHandler.bind(queue_num, callback[, max_len[, mode[, range, [sock_len] ]]]) ``
89
89
Create and bind to the queue. ``queue_num `` must match the number in your
90
90
iptables rule. ``callback `` is a function or method that takes one
91
91
argument, a Packet object (see below). ``max_len `` sets the largest number
@@ -94,23 +94,28 @@ a call to ``bind``, then start receiving packets with a call to ``run``.
94
94
data is provided to your script. Use the constants above. ``range `` defines
95
95
how many bytes of the packet you want to get. For example, if you only want
96
96
the source and destination IPs of a IPv4 packet, ``range `` could be 20.
97
+ ``sock_len `` sets the receive socket buffer size.
97
98
98
99
``QueueHandler.unbind() ``
99
100
Remove the queue. Packets matched by your iptables rule will be dropped.
100
101
101
- ``QueueHandler.run() ``
102
- Send packets to your callback. This method blocks.
102
+ ``QueueHandler.get_fd() ``
103
+ Get the file descriptor of the queue handler.
104
+
105
+ ``QueueHandler.run([block]) ``
106
+ Send packets to your callback. By default, this method blocks. Set
107
+ block=False to let your thread continue. You can get the
103
108
104
109
Packet objects
105
110
--------------
106
111
107
112
Objects of this type are passed to your callback.
108
113
109
114
``Packet.get_payload() ``
110
- Return the packet's payload as a string.
115
+ Return the packet's payload as a string (Python 2) or bytes (Python 3) .
111
116
112
117
``Packet.set_payload(payload) ``
113
- Set the packet payload. ``payload `` is bytes.
118
+ Set the packet payload. ``payload `` is a bytes.
114
119
115
120
``Packet.get_payload_len() ``
116
121
Return the size of the payload.
0 commit comments