Skip to content

Instantly share code, notes, and snippets.

@mattfox
Created June 29, 2016 03:42
Show Gist options
  • Save mattfox/46b6b6da081f4cb065f0e40e49cd783f to your computer and use it in GitHub Desktop.
Save mattfox/46b6b6da081f4cb065f0e40e49cd783f to your computer and use it in GitHub Desktop.
python-netfilterqueue run2
def run2(self):
"Version of the run method which uses normal socket.recv so that gevent can monkeypatch it"
import socket
cdef int fd = nfq_fd(self.h)
s = socket.fromfd(fd, socket.AF_UNIX, socket.SOCK_STREAM)
while True:
d = s.recv(BufferSize)
d_len = len(d)
if d_len >= 0:
nfq_handle_packet(self.h, d, d_len)
else:
break
s.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment