File tree 5 files changed +32
-9
lines changed
5 files changed +32
-9
lines changed Original file line number Diff line number Diff line change
1
+ from ._impl import (
2
+ COPY_NONE as COPY_NONE ,
3
+ COPY_META as COPY_META ,
4
+ COPY_PACKET as COPY_PACKET ,
5
+ Packet as Packet ,
6
+ NetfilterQueue as NetfilterQueue ,
7
+ PROTOCOLS as PROTOCOLS ,
8
+ )
9
+ from ._version import (
10
+ VERSION as VERSION ,
11
+ __version__ as __version__ ,
12
+ )
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ DEF SockCopySize = MaxCopySize + SockOverhead
23
23
# Socket queue should hold max number of packets of copysize bytes
24
24
DEF SockRcvSize = DEFAULT_MAX_QUEUELEN * SockCopySize // 2
25
25
26
- __package__ = " netfilterqueue"
27
-
28
- from ._version import __version__, VERSION
29
-
30
26
from cpython.exc cimport PyErr_CheckSignals
31
27
28
+ cdef extern from " Python.h" :
29
+ ctypedef struct PyTypeObject:
30
+ const char * tp_name
31
+
32
32
# A negative return value from this callback will stop processing and
33
33
# make nfq_handle_packet return -1, so we use that as the error flag.
34
34
cdef int global_callback(nfq_q_handle * qh, nfgenmsg * nfmsg,
@@ -346,6 +346,17 @@ cdef class NetfilterQueue:
346
346
else :
347
347
nfq_handle_packet(self .h, buf, len (buf))
348
348
349
+ cdef void _fix_names():
350
+ # Avoid ._impl showing up in reprs. This doesn't work on PyPy; there we would
351
+ # need to modify the name before PyType_Ready(), but I can't find any way to
352
+ # write Cython code that would execute at that time.
353
+ cdef PyTypeObject* tp = < PyTypeObject* > Packet
354
+ tp.tp_name = " netfilterqueue.Packet"
355
+ tp = < PyTypeObject* > NetfilterQueue
356
+ tp.tp_name = " netfilterqueue.NetfilterQueue"
357
+
358
+ _fix_names()
359
+
349
360
PROTOCOLS = {
350
361
0 : " HOPOPT" ,
351
362
1 : " ICMP" ,
Original file line number Diff line number Diff line change 10
10
11
11
ext_modules = cythonize (
12
12
Extension (
13
- "netfilterqueue.__init__ " ,
14
- ["netfilterqueue/__init__ .pyx" ],
13
+ "netfilterqueue._impl " ,
14
+ ["netfilterqueue/_impl .pyx" ],
15
15
libraries = ["netfilter_queue" ],
16
16
),
17
17
compiler_directives = {"language_level" : "3str" },
23
23
# setup_requires below.
24
24
setup_requires = ["cython" ]
25
25
elif not os .path .exists (
26
- os .path .join (os .path .dirname (__file__ ), "netfilterqueue/__init__ .c" )
26
+ os .path .join (os .path .dirname (__file__ ), "netfilterqueue/_impl .c" )
27
27
):
28
28
sys .stderr .write (
29
29
"You must have Cython installed (`pip install cython`) to build this "
34
34
sys .exit (1 )
35
35
ext_modules = [
36
36
Extension (
37
- "netfilterqueue.__init__ " ,
38
- ["netfilterqueue/__init__ .c" ],
37
+ "netfilterqueue._impl " ,
38
+ ["netfilterqueue/_impl .c" ],
39
39
libraries = ["netfilter_queue" ],
40
40
)
41
41
]
You can’t perform that action at this time.
0 commit comments