當前位置: 首頁>>代碼示例>>Python>>正文


Python policies.WrappingFactory類代碼示例

本文整理匯總了Python中twisted.protocols.policies.WrappingFactory的典型用法代碼示例。如果您正苦於以下問題:Python WrappingFactory類的具體用法?Python WrappingFactory怎麽用?Python WrappingFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WrappingFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的twisted.protocols.policies.WrappingFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。