Created
June 29, 2016 03:42
-
-
Save mattfox/46b6b6da081f4cb065f0e40e49cd783f to your computer and use it in GitHub Desktop.
python-netfilterqueue run2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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