%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/_newtls.cpython-312.pyc

�

Ϫ�f�#���dZddlmZddlmZddlmZddlmZGd�d�Z	d�Z
Gd	�d
�ZGd�d�ZGd
�d�Z
y)z�
This module implements memory BIO based TLS support.  It is the preferred
implementation and will be used whenever pyOpenSSL 0.10 or newer is installed
(whenever L{twisted.protocols.tls} is importable).

@since: 11.1
�)�directlyProvides)�FileDescriptor)�
ISSLTransport)�TLSMemoryBIOFactoryc�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�
_BypassTLSa
    L{_BypassTLS} is used as the transport object for the TLS protocol object
    used to implement C{startTLS}.  Its methods skip any TLS logic which
    C{startTLS} enables.

    @ivar _base: A transport class L{_BypassTLS} has been mixed in with to which
        methods will be forwarded.  This class is only responsible for sending
        bytes over the connection, not doing TLS.

    @ivar _connection: A L{Connection} which TLS has been started on which will
        be proxied to by this object.  Any method which has its behavior
        altered after C{startTLS} will be skipped in favor of the base class's
        implementation.  This allows the TLS protocol object to have direct
        access to the transport, necessary to actually implement TLS.
    c� �||_||_y)N)�_base�_connection)�self�base�
connections   �:/usr/lib/python3/dist-packages/twisted/internet/_newtls.py�__init__z_BypassTLS.__init__&s����
�%���c�.�t|j|�S)z�
        Forward any extra attribute access to the original transport object.
        For example, this exposes C{getHost}, the behavior of which does not
        change after TLS is enabled.
        )�getattrr)r�names  r�__getattr__z_BypassTLS.__getattr__*s���t�'�'��.�.rc�N�|jj|j|�S)z>
        Write some bytes directly to the connection.
        )r
�writer)r�datas  rrz_BypassTLS.write2s!���z�z���� 0� 0�$�7�7rc�N�|jj|j|�S)z@
        Write a some bytes directly to the connection.
        )r
�
writeSequencer�r�iovecs  rrz_BypassTLS.writeSequence8s!���z�z�'�'��(8�(8�%�@�@rc�V�|jj|jg|��i|��S)z2
        Close the underlying connection.
        )r
�loseConnectionr)r�args�kwargss   rrz_BypassTLS.loseConnection>s+��)�t�z�z�(�(��)9�)9�K�D�K�F�K�Krc�P�|jj|j||�S)zE
        Register a producer with the underlying connection.
        )r
�registerProducerr�r�producer�	streamings   rr"z_BypassTLS.registerProducerDs#���z�z�*�*�4�+;�+;�X�y�Q�Qrc�L�|jj|j�S)zG
        Unregister a producer with the underlying connection.
        )r
�unregisterProducerr�rs rr'z_BypassTLS.unregisterProducerJs���z�z�,�,�T�-=�-=�>�>rN)�__name__�
__module__�__qualname__�__doc__rrrrrr"r'�rrrrs-��� &�/�8�A�L�R�?rrc��|r
|j}n
|j}d\}}|j�(|j|j}}|j�t	||d�}|j||j
d�}||_|j|_|j|_t|t�d|_
|j
jt||��|r|j||�yy)a`
    Add a layer of SSL to a transport.

    @param transport: The transport which will be modified.  This can either by
        a L{FileDescriptor<twisted.internet.abstract.FileDescriptor>} or a
        L{FileHandle<twisted.internet.iocpreactor.abstract.FileHandle>}.  The
        actual requirements of this instance are that it have:

          - a C{_tlsClientDefault} attribute indicating whether the transport is
            a client (C{True}) or a server (C{False})
          - a settable C{TLS} attribute which can be used to mark the fact
            that SSL has been started
          - settable C{getHandle} and C{getPeerCertificate} attributes so
            these L{ISSLTransport} methods can be added to it
          - a C{protocol} attribute referring to the L{IProtocol} currently
            connected to the transport, which can also be set to a new
            L{IProtocol} for the transport to deliver data to

    @param contextFactory: An SSL context factory defining SSL parameters for
        the new SSL layer.
    @type contextFactory: L{twisted.internet.interfaces.IOpenSSLContextFactory}

    @param normal: A flag indicating whether SSL will go in the same direction
        as the underlying transport goes.  That is, if the SSL client will be
        the underlying client and the SSL server will be the underlying server.
        C{True} means it is the same, C{False} means they are switched.
    @type normal: L{bool}

    @param bypass: A transport base class to call methods on to bypass the new
        SSL layer (so that the SSL layer itself can send its bytes).
    @type bypass: L{type}
    )NNNFT)�_tlsClientDefaultr$�streamingProducerr'r�protocol�	getHandle�getPeerCertificaterr�TLS�makeConnectionrr")	�	transport�contextFactory�normal�bypass�clientr$r%�
tlsFactory�tlsProtocols	         r�startTLSr=Qs���J��,�,���0�0�0��%��H�i����%�'�0�0�)�2M�2M�)���$�$�&�$�^�V�T�B�J��%�%�j�)�2D�2D�e�L�K�$�I��%�/�/�I��#.�#A�#A�I� ��Y�
�.��I�M����%�%�j���&C�D���"�"�8�Y�7�rc�:�eZdZdZdZd
d�Zd�Zd�Zd�Zd�Z	d�Z
y	)�ConnectionMixinaN
    A mixin for L{twisted.internet.abstract.FileDescriptor} which adds an
    L{ITLSTransport} implementation.

    @ivar TLS: A flag indicating whether TLS is currently in use on this
        transport.  This is not a good way for applications to check for TLS,
        instead use L{twisted.internet.interfaces.ISSLTransport}.
    Fc�(�t|||t�y)z1
        @see: L{ITLSTransport.startTLS}
        N)r=r)r�ctxr8s   rr=zConnectionMixin.startTLS�s��	��s�F�N�3rc��|jr)|jr|jj|�yyt	j||�y)z�
        Write some bytes to this connection, passing them through a TLS layer if
        necessary, or discarding them if the connection has already been lost.
        N)r4�	connectedr1rr)r�bytess  rrzConnectionMixin.write�s;��
�8�8��~�~��
�
�#�#�E�*��
� � ��u�-rc��|jr)|jr|jj|�yyt	j||�y)z�
        Write some bytes to this connection, scatter/gather-style, passing them
        through a TLS layer if necessary, or discarding them if the connection
        has already been lost.
        N)r4rCr1rrrs  rrzConnectionMixin.writeSequence�s;���8�8��~�~��
�
�+�+�E�2��
�(�(��u�5rc��|jr5|jr(|js|jj	�yyytj|�y)z�
        Close this connection after writing all pending data.

        If TLS has been negotiated, perform a TLS shutdown.
        N)r4rC�
disconnectingr1rrr(s rrzConnectionMixin.loseConnection�sA���8�8��~�~�d�&8�&8��
�
�,�,�.�'9�~�
�)�)�$�/rc��|jr|jj||�ytj|||�y)zc
        Register a producer.

        If TLS is enabled, the TLS connection handles this.
        N)r4r1r"rr#s   rr"z ConnectionMixin.registerProducer�s3���8�8�

�M�M�*�*�8�Y�?��+�+�D�(�I�Frc�|�|jr|jj�ytj|�y)ze
        Unregister a producer.

        If TLS is enabled, the TLS connection handles this.
        N)r4r1r'rr(s rr'z"ConnectionMixin.unregisterProducer�s)���8�8��M�M�,�,�.��-�-�d�3rN)T)r)r*r+r,r4r=rrrr"r'r-rrr?r?�s-����C�4�	.�
6�
0�
G�	4rr?c��eZdZdZdZy)�ClientMixina=
    A mixin for L{twisted.internet.tcp.Client} which just marks it as a client
    for the purposes of the default TLS handshake.

    @ivar _tlsClientDefault: Always C{True}, indicating that this is a client
        connection, and by default when TLS is negotiated this class will act as
        a TLS client.
    TN�r)r*r+r,r/r-rrrKrK�s����rrKc��eZdZdZdZy)�ServerMixina>
    A mixin for L{twisted.internet.tcp.Server} which just marks it as a server
    for the purposes of the default TLS handshake.

    @ivar _tlsClientDefault: Always C{False}, indicating that this is a server
        connection, and by default when TLS is negotiated this class will act as
        a TLS server.
    FNrLr-rrrNrN�s����rrNN)r,�zope.interfacer�twisted.internet.abstractr�twisted.internet.interfacesr�twisted.protocols.tlsrrr=r?rKrNr-rr�<module>rSsK��
�,�4�5�5�9?�9?�xE8�PM4�M4�`
�
�
�
r

Zerion Mini Shell 1.0