Skip to main content

Fast python library encapsulating the nfqueue netlink interface.

Project description

fnfqueue

Build Status Python Versions PyPI - License

Fast netfilter nfqueue python and C interface. Gets the speed from

  • avoiding memory allocation
  • batching reads (uses recv_mmsg)

It also does not use the callback-like interface of libnetfilter-queue and provides a more python like iterator interface. Additionally, it doesn't assume anything and therefore doesn't automatically set verdicts on packets (unlike python-nfqueue in debian which accepts everything after you return from the callback...)

It can handle ping -f (even iperf if the moon is in the right spot) to localhost from within python.

Focus is on a python like interface.

Short example for mangling packets:

iptables -A OUTPUT <filter here> -j NFQUEUE --queue-num 1
import fnfqueue

queue = 1
conn = fnfqueue.Connection()

try:
    q = conn.bind(queue)
    q.set_mode(0xffff, fnfqueue.COPY_PACKET)
except PermissionError:
    print("Access denied; Do I have root rights or the needed capabilities?")
    sys.exit(-1)

while True:
    try:
        for packet in conn:
            packet.payload = packet.payload # modify the packet here
            packet.mangle()
    except fnfqueue.BufferOverflowException:
        print("buffer error")
        pass

conn.close() # this can be called concurrently to cancel the above for loop

Help is provided as python docs.

No C libraries are needed. Needs cffi for building. Kernel and libc must be recent enough to support nfqueue and recvmmsg (linux 2.6.33, glibc 2.12 - more recent kernels provide better performance).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fnfqueue-1.1.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distributions

fnfqueue-1.1.2-pp39-pypy39_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (16.4 kB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (16.3 kB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (16.5 kB view details)

Uploaded PyPy manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

fnfqueue-1.1.2-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl (46.6 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64 manylinux: glibc 2.28+ x86-64

File details

Details for the file fnfqueue-1.1.2.tar.gz.

File metadata

  • Download URL: fnfqueue-1.1.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for fnfqueue-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e4aa1843058fc6b4e3e7537d980f01163d4605f9e4a829f23098e5c6979b61a8
MD5 64302f0633e3ef86937ca13e9b7fbfba
BLAKE2b-256 e08456aaa9de8eddaf78f48c82de0db5b1463c10dd7bb596367a09ed8f82bf0f

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-pp39-pypy39_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-pp39-pypy39_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a444e8202f0f67c6ff35e861ae27132742c45794df546b61f27182c3b2d7069
MD5 b6436fc3f4c13d497a1588d39095a84d
BLAKE2b-256 a76e3e9e229fad36637d94b328c2f78a88a5aa69eb65e07dd231cdbbfa0e15d4

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-pp38-pypy38_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 992ed387dc4a562daf51045da1a41b43742e80e0284e602823f0c780fa188d76
MD5 2d8c5f60128d01050f77421fdd563105
BLAKE2b-256 178e4c4a4720eee4cd5a803a41dee09c48adb58a40a6661dfdd1152fda926140

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b47c991f002246ed2dfb9c2f973e4e85e5567129274f435a2458c7be7988c22b
MD5 885981bcfb14775f2050a354a0dae335
BLAKE2b-256 b318aee03f48a0b1e5636399693c4f21cfe245165a1ed55fa0efb5257bc3ac9b

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp311-cp311-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0ce8f3832de95026d7f9fa5a20d2cd394d9bc201573529cc142c6b9b4e07b413
MD5 768598b955e92df39a40876b900625b5
BLAKE2b-256 23d0e15a9b3c63ccb029f9c0cf1bbe81074ed617ee911709a8324f63ba621fdf

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 abe6ed5f66e4cd2f6b6aaac1bd35acfb11803488ace617509b60af0dd3f53b0c
MD5 5772fe3b41de429e59aab29b87b5eb52
BLAKE2b-256 4f7c705a8da06e849c0ab05e51925b4a20293071e4daa93442a54858d0bd17d2

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2ccd3b144af2d63f4dd3ad2eefdaeeb020e05e2f2757e76e327d3a40adb30f0f
MD5 4cd4ebd7c66a1ab251658cb5226b11b0
BLAKE2b-256 250257f1cf5f196d37eebf090adc00c0311015bc13f8b256c7555c95e9414dc4

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b917c4c765fd76573998ed799db6de6fc48453ba8a594e12e7f77b5290b3ab18
MD5 358b0b29805983bd025251b743e381f0
BLAKE2b-256 9efa274c1d11b176cd768c9dfa9b8d9029b79abd7335181595889ba2a8708f2e

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 39f69c1d96aca17b53af895ccd7b906c441e986d28ff2ae68c2f7f2e778d93d1
MD5 54a9f5c3901534ffb43e70754625a66f
BLAKE2b-256 1421f10f2504f0bd970e18652cfe405a1d94cc9d4f4c674847fd7170265d603b

See more details on using hashes here.

File details

Details for the file fnfqueue-1.1.2-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fnfqueue-1.1.2-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9330c8d8ec801f2d30fdcb8613a794dc7442d36503e5ea9f6f5c15e568c2356
MD5 271cdc9a8f29faf03803c934600d207e
BLAKE2b-256 4593cc377e1bc3977640c346d5733a19749c8c6604cda4f0eedd65de90cc4f14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page