python类addReader()的实例源码

nfqueue.py 文件源码 项目:packet-queue 作者: google 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def configure(protocol, port, pipes, interface):
  remove_all()
  reactor.addSystemEventTrigger('after', 'shutdown', remove_all)

  # gets default (outward-facing) network interface (e.g. deciding which of
  # eth0, eth1, wlan0 is being used by the system to connect to the internet)
  if interface == "auto":
    interface = netifaces.gateways()['default'][netifaces.AF_INET][1]
  else:
    if interface not in netifaces.interfaces():
      raise ValueError("Given interface does not exist.", interface)

  add(protocol, port, interface)
  manager = libnetfilter_queue.Manager()

  manager.bind(UP_QUEUE, packet_handler(manager, pipes.up))
  manager.bind(DOWN_QUEUE, packet_handler(manager, pipes.down))

  reader = abstract.FileDescriptor()
  reader.doRead = manager.process
  reader.fileno = lambda: manager.fileno
  reactor.addReader(reader)
InputHotplug.py 文件源码 项目:enigma2 作者: OpenLD 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        from twisted.internet import reactor
        self.nls = Netlink.NetlinkSocket()
        reactor.addReader(self)
python_reader.py 文件源码 项目:pyrepl 作者: dajose 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def twistedinteract(self):
        from twisted.internet import reactor
        from twisted.internet.abstract import FileDescriptor
        import signal
        outerself = self
        class Me(FileDescriptor):
            def fileno(self):
                """ We want to select on FD 0 """
                return 0

            def doRead(self):
                """called when input is ready"""
                try:
                    outerself.handle1()
                except EOFError:
                    reactor.stop()

        reactor.addReader(Me())
        reactor.callWhenRunning(signal.signal,
                                signal.SIGINT,
                                signal.default_int_handler)
        self.prepare()
        try:
            reactor.run()
        finally:
            self.restore()
InputHotplug.py 文件源码 项目:enigma2 作者: Openeight 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self):
        from twisted.internet import reactor
        self.nls = Netlink.NetlinkSocket()
        reactor.addReader(self)
InputHotplug.py 文件源码 项目:enigma2 作者: BlackHole 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        from twisted.internet import reactor
        self.nls = Netlink.NetlinkSocket()
        reactor.addReader(self)
Spoof.py 文件源码 项目:SEF 作者: ahmadnourallah 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start_dns_queue(self):
        self.q = nfqueue.queue()
        self.q.set_callback(self.nfqueue_callback)
        self.q.fast_open(0, socket.AF_INET)
        self.q.set_queue_maxlen(5000)
        reactor.addReader(self)
        self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
python_reader.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def twistedinteract(self):
        from twisted.internet import reactor
        from twisted.internet.abstract import FileDescriptor
        import signal
        outerself = self
        class Me(FileDescriptor):
            def fileno(self):
                """ We want to select on FD 0 """
                return 0

            def doRead(self):
                """called when input is ready"""
                try:
                    outerself.handle1()
                except EOFError:
                    reactor.stop()

        reactor.addReader(Me())
        reactor.callWhenRunning(signal.signal,
                                signal.SIGINT,
                                signal.default_int_handler)
        self.prepare()
        try:
            reactor.run()
        finally:
            self.restore()
test_posixbase.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def addReader(self, reader):
        self._readers[reader] = True
test_posixbase.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_removeAllSkipsInternalReaders(self):
        """
        Any L{IReadDescriptors} in L{PosixReactorBase._internalReaders} are
        left alone by L{PosixReactorBase._removeAll}.
        """
        reactor = TrivialReactor()
        extra = object()
        reactor._internalReaders.add(extra)
        reactor.addReader(extra)
        reactor._removeAll(reactor._readers, reactor._writers)
        self._checkWaker(reactor)
        self.assertIn(extra, reactor._internalReaders)
        self.assertIn(extra, reactor._readers)
test_posixbase.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_removeAllReturnsRemovedDescriptors(self):
        """
        L{PosixReactorBase._removeAll} returns a list of removed
        L{IReadDescriptor} and L{IWriteDescriptor} objects.
        """
        reactor = TrivialReactor()
        reader = object()
        writer = object()
        reactor.addReader(reader)
        reactor.addWriter(writer)
        removed = reactor._removeAll(
            reactor._readers, reactor._writers)
        self.assertEqual(set(removed), set([reader, writer]))
        self.assertNotIn(reader, reactor._readers)
        self.assertNotIn(writer, reactor._writers)
test_posixbase.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def addReader(self, reader):
        """
        Ignore the reader.  This is necessary because the waker will be
        added.  However, we won't actually monitor it for any events.
        """
Spoof.py 文件源码 项目:SEF 作者: hossamhasanin 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start_dns_queue(self):
        self.q = nfqueue.queue()
        self.q.set_callback(self.nfqueue_callback)
        self.q.fast_open(0, socket.AF_INET)
        self.q.set_queue_maxlen(5000)
        reactor.addReader(self)
        self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
LANs.py 文件源码 项目:LANs.py 作者: wi-fi-analyzer 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, args):
        self.q = nfqueue.queue()
        self.q.set_callback(Parser(args).start)
        self.q.fast_open(0, socket.AF_INET)
        self.q.set_queue_maxlen(5000)
        reactor.addReader(self)
        self.q.set_mode(nfqueue.NFQNL_COPY_PACKET)
        print '[*] Flushed firewall and forwarded traffic to the queue; waiting for data'
InputHotplug.py 文件源码 项目:enigma2-openpli-fulan 作者: Taapat 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self):
        from twisted.internet import reactor
        self.nls = Netlink.NetlinkSocket()
        reactor.addReader(self)


问题


面经


文章

微信
公众号

扫码关注公众号