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) |
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
#!/usr/bin/env python | |
from gevent.server import StreamServer | |
from netfilterqueue import NetfilterQueue | |
from gevent import monkey; monkey.patch_socket() | |
def print_and_accept(pkt): | |
print(pkt) | |
pkt.accept() | |
def echo(socket, address): |