nflog
nflog
¶
Read denied packets via AF_NETLINK NFLOG and emit watch events.
Subscribes to the kernel's nflog group to receive copies of packets that
matched log group rules in the nft ruleset. Extracts destination IP,
port, and log prefix from each message.
Optional — NflogWatcher.create() returns None if netlink is
unavailable (missing kernel module, insufficient permissions).
NflogWatcher(sock, container)
¶
Read NFLOG messages via AF_NETLINK and yield events for denied packets.
Wrap an already-bound NFLOG netlink socket.
Use :meth:create instead of calling this directly.
Source code in src/terok_shield/lib/watchers/nflog.py
create(container, group=NFLOG_GROUP)
classmethod
¶
Create and bind an NFLOG watcher, or return None on failure.
Failure is expected in environments without AF_NETLINK support,
unprivileged containers, or missing kernel modules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
str
|
Container name (for event metadata). |
required |
group
|
int
|
NFLOG group number to subscribe to. |
NFLOG_GROUP
|
Source code in src/terok_shield/lib/watchers/nflog.py
fileno()
¶
close()
¶
poll()
¶
Read pending NFLOG messages and return watch events.