%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/protocols/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/protocols/__pycache__/tls.cpython-312.pyc |
� Ϫ�f� � � � d Z ddlmZ ddlmZmZmZmZ ddlm Z m Z mZ ddlm Z mZmZmZmZ ddlmZ ddlmZ ddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z" dd l#m$Z$ dd l%m&Z& ddl'm(Z(m)Z) ddl*m+Z+ e e� G d � d� � Z,dd�Z- e e!ee"� G d� de(� � Z. e ee� G d� d� � Z/ G d� d� Z0dd�Z1 G d� de.� Z2 G d� de)� Z3y)a� Implementation of a TLS transport (L{ISSLTransport}) as an L{IProtocol<twisted.internet.interfaces.IProtocol>} layered on top of any L{ITransport<twisted.internet.interfaces.ITransport>} implementation, based on U{OpenSSL<http://www.openssl.org>}'s memory BIO features. L{TLSMemoryBIOFactory} is a L{WrappingFactory} which wraps protocols created by the factory it wraps with L{TLSMemoryBIOProtocol}. L{TLSMemoryBIOProtocol} intercedes between the underlying transport and the wrapped protocol to implement SSL and TLS. Typical usage of this module looks like this:: from twisted.protocols.tls import TLSMemoryBIOFactory from twisted.internet.protocol import ServerFactory from twisted.internet.ssl import PrivateCertificate from twisted.internet import reactor from someapplication import ApplicationProtocol serverFactory = ServerFactory() serverFactory.protocol = ApplicationProtocol certificate = PrivateCertificate.loadPEM(certPEMData) contextFactory = certificate.options() tlsFactory = TLSMemoryBIOFactory(contextFactory, False, serverFactory) reactor.listenTCP(12345, tlsFactory) reactor.run() This API offers somewhat more flexibility than L{twisted.internet.interfaces.IReactorSSL}; for example, a L{TLSMemoryBIOProtocol} instance can use another instance of L{TLSMemoryBIOProtocol} as its transport, yielding TLS over TLS - useful to implement onion routing. It can also be used to run TLS over unusual transports, such as UNIX sockets and stdio. � )�annotations)�Callable�Iterable�Optional�cast)�directlyProvides�implementer� providedBy)� Connection�Error�SysCallError� WantReadError�ZeroReturnError)�_PullToPush)�_setAcceptableProtocols)�IDelayedCall�IHandshakeListener�ILoggingContext�INegotiated�IOpenSSLClientConnectionCreator�IOpenSSLServerConnectionCreator� IProtocol�IProtocolNegotiationFactory� IPushProducer�IReactorTime� ISystemHandle� ITransport)�CONNECTION_LOST)�Protocol)�ProtocolWrapper�WrappingFactory)�Failurec �, � e Zd ZdZdZd� Zd� Zd� Zd� Zy)�_ProducerMembranea Stand-in for producer registered with a L{TLSMemoryBIOProtocol} transport. Ensures that producer pause/resume events from the undelying transport are coordinated with pause/resume events from the TLS layer. @ivar _producer: The application-layer producer. Fc � � || _ y �N)� _producer)�self�producers �7/usr/lib/python3/dist-packages/twisted/protocols/tls.py�__init__z_ProducerMembrane.__init__R s � �!��� c �` � | j ryd| _ | j j � y)zP C{pauseProducing} the underlying producer, if it's not paused. NT)�_producerPausedr'