• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python policies.WrappingFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.protocols.policies.WrappingFactory的典型用法代码示例。如果您正苦于以下问题:Python WrappingFactory类的具体用法?Python WrappingFactory怎么用?Python WrappingFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WrappingFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, wrappedFactory):
        """Constructor.

        See WrappingFactory.__init__.
        """
        WrappingFactory.__init__(self, wrappedFactory)
        self.allConnectionsGone = None
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:7,代码来源:gracefulshutdown.py


示例2: __init__

    def __init__(self, wrappedFactory, maxConnectionCount=sys.maxint):
        WrappingFactory.__init__(self, wrappedFactory)
        self.connectionCount = 0
        self.maxConnectionCount = maxConnectionCount

        self.ht = Hellanzb.ht
        self.ht.factories.append(self)
开发者ID:myusuf3,项目名称:hellanzb,代码行数:7,代码来源:NZBLeecherUtil.py


示例3: __init__

    def __init__(self, contextFactory, isClient, wrappedFactory):
        WrappingFactory.__init__(self, wrappedFactory)
        self._contextFactory = contextFactory
        self._isClient = isClient

        # Force some parameter checking in pyOpenSSL.  It's better to fail now
        # than after we've set up the transport.
        contextFactory.getContext()
开发者ID:AmirKhooj,项目名称:VTK,代码行数:8,代码来源:tls.py


示例4: unregisterProtocol

 def unregisterProtocol(self, p):
     WrappingFactory.unregisterProtocol(self, p)
     self.connectionCount -= 1
     self.ht.connectionCount -= 1
     
     if self.ht.connectionCount == 0:
         for name in ('unthrottleReadsID', 'checkReadBandwidthID',
                      'unthrottleWritesID', 'checkWriteBandwidthID'):
             self.cancelScheduled(getattr(self.ht, name))
开发者ID:myusuf3,项目名称:hellanzb,代码行数:9,代码来源:NZBLeecherUtil.py


示例5: __init__

    def __init__(self, contextFactory, isClient, wrappedFactory):
        """
        Create a L{TLSMemoryBIOFactory}.

        @param contextFactory: Configuration parameters used to create an
            OpenSSL connection.  In order of preference, what you should pass
            here should be:

                1. L{twisted.internet.ssl.CertificateOptions} (if you're
                   writing a server) or the result of
                   L{twisted.internet.ssl.optionsForClientTLS} (if you're
                   writing a client).  If you want security you should really
                   use one of these.

                2. If you really want to implement something yourself, supply a
                   provider of L{IOpenSSLClientConnectionCreator} or
                   L{IOpenSSLServerConnectionCreator}.

                3. If you really have to, supply a
                   L{twisted.internet.ssl.ContextFactory}.  This will likely be
                   deprecated at some point so please upgrade to the new
                   interfaces.

        @type contextFactory: L{IOpenSSLClientConnectionCreator} or
            L{IOpenSSLServerConnectionCreator}, or, for compatibility with
            older code, anything implementing
            L{twisted.internet.interfaces.IOpenSSLContextFactory}.  See
            U{https://twistedmatrix.com/trac/ticket/7215} for information on
            the upcoming deprecation of passing a
            L{twisted.internet.ssl.ContextFactory} here.

        @param isClient: Is this a factory for TLS client connections; in other
            words, those that will send a C{ClientHello} greeting?  L{True} if
            so, L{False} otherwise.  This flag determines what interface is
            expected of C{contextFactory}.  If L{True}, C{contextFactory}
            should provide L{IOpenSSLClientConnectionCreator}; otherwise it
            should provide L{IOpenSSLServerConnectionCreator}.
        @type isClient: L{bool}

        @param wrappedFactory: A factory which will create the
            application-level protocol.
        @type wrappedFactory: L{twisted.internet.interfaces.IProtocolFactory}
        """
        WrappingFactory.__init__(self, wrappedFactory)
        if isClient:
            creatorInterface = IOpenSSLClientConnectionCreator
        else:
            creatorInterface = IOpenSSLServerConnectionCreator
        self._creatorInterface = creatorInterface
        if not creatorInterface.providedBy(contextFactory):
            contextFactory = _ContextFactoryToConnectionFactory(contextFactory)
        self._connectionCreator = contextFactory
开发者ID:esabelhaus,项目名称:secret-octo-dubstep,代码行数:52,代码来源:tls.py


示例6: buildProtocol

 def buildProtocol(self, addr):
     remote_ip = ip_address(addr.host)
     if any(remote_ip in network for network in self.whitelist):
         return WrappingFactory.buildProtocol(self, addr)
     else:
         log.info("Attempted submission from non-whitelisted %s" % str(addr))
         return None
开发者ID:timstaley,项目名称:Comet,代码行数:7,代码来源:whitelist.py


示例7: buildProtocol

 def buildProtocol(self, addr):
     try:
         remote_ip = ip_address(addr.host)
         if not any(remote_ip in network for network in self.whitelist):
             log.info(f"Attempted {self.connection_type} from "
                      f"non-whitelisted {addr}")
             return None
     except AttributeError:
         log.warn(f"Bypassing whitelist for {self.connection_type} "
                  f"from {addr}")
     return WrappingFactory.buildProtocol(self, addr)
开发者ID:jdswinbank,项目名称:Comet,代码行数:11,代码来源:whitelist.py


示例8: registerProtocol

    def registerProtocol(self, p):
        """
        Called by protocol to register itself.
        """
        WrappingFactory.registerProtocol(self, p)

        if self.requests_countdown > 0:
            self.requests_countdown -= 1

        if self.requests_countdown == 0:
            # bai bai mai friend
            #
            # known bug: currently when the limit is reached all
            #            the active requests are trashed.
            #            this simple solution is used to achieve
            #            stronger stability.
            try:
                reactor.stop()
            except Exception:
                pass
开发者ID:Acidburn0zzz,项目名称:Tor2web-3.0,代码行数:20,代码来源:t2w.py


示例9: buildProtocol

    def buildProtocol(self, addr):
        if self.ht.connectionCount == 0:
            if self.ht.readLimit is not None:
                self.ht.checkReadBandwidth()
            if self.ht.writeLimit is not None:
                self.ht.checkWriteBandwidth()

        if self.connectionCount < self.maxConnectionCount:
            self.connectionCount += 1
            self.ht.connectionCount += 1
            return WrappingFactory.buildProtocol(self, addr)
        else:
            log.msg("Max connection count reached!")
            return None
开发者ID:myusuf3,项目名称:hellanzb,代码行数:14,代码来源:NZBLeecherUtil.py


示例10: __init__

 def __init__(self, wrappedFactory, whitelist, connection_type="connection"):
     self.whitelist = whitelist
     self.connection_type = connection_type
     WrappingFactory.__init__(self, wrappedFactory)
开发者ID:jdswinbank,项目名称:Comet,代码行数:4,代码来源:whitelist.py


示例11: __init__

 def __init__(self, wrappedFactory, jsonEncoder=None, jsonDecoder=None):
     WrappingFactory.__init__(self, wrappedFactory)
     self.jsonEncoder = jsonEncoder
     self.jsonDecoder = jsonDecoder
开发者ID:hhco,项目名称:txdarn,代码行数:4,代码来源:protocol.py


示例12: __init__

 def __init__(self, wrappedFactory, allowedRequests):
     WrappingFactory.__init__(self, wrappedFactory)
     self.requests_countdown = allowedRequests
开发者ID:Acidburn0zzz,项目名称:Tor2web-3.0,代码行数:3,代码来源:t2w.py


示例13: connectionLost

                                              privateKey=privateKey,
                                              verifierDB=verifierDB)
      else:
          Echo.connectionMade(self)

  def connectionLost(self, reason):
      pass #Handle any TLS exceptions here

class Echo2(Echo):
  def lineReceived(self, data):
      if data == "STARTTLS":
          self.transport.setServerHandshakeOp(certChain=certChain,
                                              privateKey=privateKey,
                                              verifierDB=verifierDB)
      else:
          Echo.lineReceived(self, data)

  def connectionLost(self, reason):
      pass #Handle any TLS exceptions here

factory = Factory()
factory.protocol = Echo1
#factory.protocol = Echo2

wrappingFactory = WrappingFactory(factory)
wrappingFactory.protocol = TLSTwistedProtocolWrapper

log.startLogging(sys.stdout)
reactor.listenTCP(1079, wrappingFactory)
reactor.run()
开发者ID:AchironOS,项目名称:chromium.src,代码行数:30,代码来源:twistedserver.py


示例14: __init__

 def __init__(self, wrappedFactory):
     WrappingFactory.__init__(self, wrappedFactory)
     self.logs = []
     self.finishedLogs = []
开发者ID:eventable,项目名称:CalendarServer,代码行数:4,代码来源:trafficlogger.py


示例15: __init__

 def __init__(self, wrappedFactory, host, port, optimistic):
     WrappingFactory.__init__(self, wrappedFactory)
     self._host = host
     self._port = port
     self._optimistic = optimistic
     self._onConnection = defer.Deferred()
开发者ID:Acidburn0zzz,项目名称:Tor2web-3.0,代码行数:6,代码来源:socks.py


示例16: stopFactory

 def stopFactory(self):
     """See WrappingFactory.stopFactory."""
     WrappingFactory.stopFactory(self)
     self.allConnectionsGone = Deferred()
     if len(self.protocols) == 0:
         self.allConnectionsGone.callback(None)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:6,代码来源:gracefulshutdown.py


示例17: buildProtocol

 def buildProtocol(self, addr):
     protocol = WrappingFactory.buildProtocol(self, addr)
     protocol.setWriteLimit(self.writeLimit)
     return protocol
开发者ID:inglesp,项目名称:async-intro,代码行数:4,代码来源:slowserver.py


示例18: __init__

 def __init__(self, wrappedFactory, writeLimit):
     WrappingFactory.__init__(self, wrappedFactory)
     self.writeLimit = writeLimit
开发者ID:inglesp,项目名称:async-intro,代码行数:3,代码来源:slowserver.py


示例19: unregisterProtocol

 def unregisterProtocol(self, p):
     """See WrappingFactory.unregisterProtocol."""
     WrappingFactory.unregisterProtocol(self, p)
     if len(self.protocols) == 0:
         if self.allConnectionsGone is not None:
             self.allConnectionsGone.callback(None)
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:6,代码来源:gracefulshutdown.py


示例20: unregisterProtocol

 def unregisterProtocol(self, protocol):
     WrappingFactory.unregisterProtocol(self, protocol)
     self.logs.remove(protocol.logfile)
     self.finishedLogs.append(protocol.logfile)
     del self.finishedLogs[:-self.LOGFILE_LIMIT]
开发者ID:eventable,项目名称:CalendarServer,代码行数:5,代码来源:trafficlogger.py



注:本文中的twisted.protocols.policies.WrappingFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sip.parseViaHeader函数代码示例发布时间:2022-05-27
下一篇:
Python policies.ProtocolWrapper类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap