Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/__pycache__/ssltransport.cpython-311.pyc

�

�܋fU#����ddlmZddlZddlZddlZddlZddlmZejrddl	m
Z
ddlmZm
Z
ejdd	�
��ZejeefZejd��ZdZGd
�d	��ZdS)�)�annotationsN�)�ProxySchemeUnsupported)�Literal�)�_TYPE_PEER_CERT_RET�_TYPE_PEER_CERT_RET_DICT�_SelfT�SSLTransport)�bound�_ReturnValuei@c���eZdZdZed]d���Z		d^d_d�Zd`d�Zdad�Zdbd�Z	dcddd�Z
dedfd!�Z		dgdhd&�Zdidjd)�Z
didkd*�Z	dldddd+�dmd3�Zdnd4�Zdnd5�Zej	dodpd:���Zejdqd=���Zdrdsd@�ZdtdA�ZdudC�ZdtdD�ZdtdE�ZdvdG�ZdtdH�ZdwdK�ZdxdL�ZdndM�ZdldydO�ZejdzdR���Zejd{dU���Zejd|dX���Z		d}d~d\�ZdS)raL
    The SSLTransport wraps an existing socket and establishes an SSL connection.

    Contrary to Python's implementation of SSLSocket, it allows you to chain
    multiple TLS connections together. It's particularly useful if you need to
    implement TLS within TLS.

    The class supports most of the socket API operations.
    �ssl_context�ssl.SSLContext�return�Nonec�D�t|d��std���dS)z�
        Raises a ProxySchemeUnsupported if the provided ssl_context can't be used
        for TLS in TLS.

        The only requirement is that the ssl_context provides the 'wrap_bio'
        methods.
        �wrap_biozXTLS in TLS requires SSLContext.wrap_bio() which isn't available on non-native SSLContextN)�hasattrr)rs �P/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/util/ssltransport.py�$_validate_ssl_context_for_tls_in_tlsz1SSLTransport._validate_ssl_context_for_tls_in_tls"s7���{�J�/�/�	�(�5���
�	�	�NT�socket�
socket.socket�server_hostname�
str | None�suppress_ragged_eofs�boolc��tj��|_tj��|_||_||_|�|j|j|���|_|�|jj	��dS)zV
        Create an SSLTransport around socket using the provided ssl_context.
        )rN)
�ssl�	MemoryBIO�incoming�outgoingrrr�sslobj�_ssl_io_loop�do_handshake)�selfrrrrs     r�__init__zSSLTransport.__init__2su���
����
��
����
�$8��!����!�*�*��M�4�=�/�+�
�
���
	
���$�+�2�3�3�3�3�3rr'r
c��|S�N��r's r�	__enter__zSSLTransport.__enter__Is���r�_�
typing.Anyc�.�|���dSr*)�close)r'r.s  r�__exit__zSSLTransport.__exit__Ls���
�
�����r�intc�4�|j���Sr*)r�filenor,s rr5zSSLTransport.filenoO����{�!�!�#�#�#r��len�buffer�typing.Any | None�int | bytesc�.�|�||��Sr*)�_wrap_ssl_read)r'r8r9s   r�readzSSLTransport.readRs���"�"�3��/�/�/rr�buflen�flagsc�V�|dkrtd���|�|��S)Nrz+non-zero flags not allowed in calls to recv)�
ValueErrorr=)r'r?r@s   r�recvzSSLTransport.recvUs.���A�:�:��J�K�K�K��"�"�6�*�*�*r�_WriteBuffer�nbytes�
int | None�None | int | bytesc�z�|dkrtd���|�t|��}|�||��S)Nrz0non-zero flags not allowed in calls to recv_into)rBr8r>)r'r9rEr@s    r�	recv_intozSSLTransport.recv_intoZs@���A�:�:��O�P�P�P��>���[�[�F��y�y���(�(�(r�data�bytesc�X�|dkrtd���d}t|��5}|�d��5}t|��}||kr(|�||d���}||z
}||k�(ddd��n#1swxYwYddd��dS#1swxYwYdS)Nrz.non-zero flags not allowed in calls to sendall�B)rB�
memoryview�castr8�send)r'rJr@�count�view�	byte_view�amount�vs        r�sendallzSSLTransport.sendallfs1���A�:�:��M�N�N�N���
��
�
�	��t�y�y��~�~�	����^�^�F��&�.�.��I�I�i����/�0�0����
���&�.�.�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s4�B�>B�;B�B	�B�B	�B�B#�&B#c�l�|dkrtd���|�|jj|��S)Nrz+non-zero flags not allowed in calls to send)rBr%r$�write)r'rJr@s   rrPzSSLTransport.sendps5���A�:�:��J�K�K�K�� � ���!2�D�9�9�9r)�encoding�errors�newline�mode�str�	bufferingrYrZr[�1typing.BinaryIO | typing.TextIO | socket.SocketIOc�.�t|��hd�kstd|�d����d|v}d|vp|}|s|sJ�d|v}d}	|r|	dz
}	|r|	dz
}	tj||	��}
|jxjdz
c_|�d
}|dkrt
j}|dkr|std���|
S|r|rtj|
|
|��}n1|rtj|
|��}n|sJ�tj	|
|��}|r|Stj
||||��}||_|S)
a
        Python's httpclient uses makefile and buffered io when reading HTTP
        messages and we need to support it.

        This is unfortunately a copy and paste of socket.py makefile with small
        changes to point to the socket directly.
        >�b�r�wz
invalid mode z (only r, w, b allowed)rcrbra�rN���rz!unbuffered streams must be binary)�setrBr�SocketIO�_io_refs�io�DEFAULT_BUFFER_SIZE�BufferedRWPair�BufferedReader�BufferedWriter�
TextIOWrapperr\)
r'r\r^rYrZr[�writing�reading�binary�rawmode�rawr9�texts
             r�makefilezSSLTransport.makefileus��� �4�y�y�O�O�O�+�+��L�T�L�L�L�M�M�M���+����+�,�W����!�'�!�!�!��������	��s�N�G��	��s�N�G��o�d�G�,�,�������!������I��q�=�=��.�I���>�>��
F� �!D�E�E�E��J��	7�w�	7��&�s�C��;�;�F�F�
�	7��&�s�I�6�6�F�F��N�N�7��&�s�I�6�6�F��	��M�����&�'�B�B����	��rc�D�|�|jj��dSr*)r%r$�unwrapr,s rrwzSSLTransport.unwrap�s!�����$�+�,�-�-�-�-�-rc�8�|j���dSr*)rr1r,s rr1zSSLTransport.close�s����������r.�binary_form�Literal[False]�_TYPE_PEER_CERT_RET_DICT | Nonec��dSr*r+�r'rys  r�getpeercertzSSLTransport.getpeercert�s	��	�r�
Literal[True]�bytes | Nonec��dSr*r+r}s  rr~zSSLTransport.getpeercert�����rFrc�6�|j�|��Sr*)r$r~r}s  rr~zSSLTransport.getpeercert�s���{�&�&�{�3�3�3rc�4�|j���Sr*)r$�versionr,s rr�zSSLTransport.version�s���{�"�"�$�$�$r�tuple[str, str, int] | Nonec�4�|j���Sr*)r$�cipherr,s rr�zSSLTransport.cipher�r6rc�4�|j���Sr*)r$�selected_alpn_protocolr,s rr�z#SSLTransport.selected_alpn_protocol�s���{�1�1�3�3�3rc�4�|j���Sr*)r$�selected_npn_protocolr,s rr�z"SSLTransport.selected_npn_protocol�s���{�0�0�2�2�2r�!list[tuple[str, str, int]] | Nonec�4�|j���Sr*)r$�shared_ciphersr,s rr�zSSLTransport.shared_ciphers�s���{�)�)�+�+�+rc�4�|j���Sr*)r$�compressionr,s rr�zSSLTransport.compression�s���{�&�&�(�(�(r�value�float | Nonec�:�|j�|��dSr*)r�
settimeout)r'r�s  rr�zSSLTransport.settimeout�s������u�%�%�%�%�%rc�4�|j���Sr*)r�
gettimeoutr,s rr�zSSLTransport.gettimeout�s���{�%�%�'�'�'rc�8�|j���dSr*)r�_decref_socketiosr,s rr�zSSLTransport._decref_socketios�s����%�%�'�'�'�'�'r�bytearray | Nonec��	|�|jj||��S#tj$r(}|jtjkr
|jrYd}~dS�d}~wwxYw�Nr)r%r$r>r �SSLError�errno�
SSL_ERROR_EOFr)r'r8r9�es    rr=zSSLTransport._wrap_ssl_read�sm��	��$�$�T�[�%5�s�F�C�C�C���|�	�	�	��w�#�+�+�+��0I�+��q�q�q�q�q������		���s� #�A�A�A�A�func�typing.Callable[[], None]c��dSr*r+)r'r�s  rr%zSSLTransport._ssl_io_loop�r�r�typing.Callable[[bytes], int]�arg1c��dSr*r+)r'r�r�s   rr%zSSLTransport._ssl_io_loop�r�r�/typing.Callable[[int, bytearray | None], bytes]�arg2c��dSr*r+)r'r�r�r�s    rr%zSSLTransport._ssl_io_loop�s	��	�r�"typing.Callable[..., _ReturnValue]�None | bytes | intr
c�f�d}d}|�rd}	|�
|�|��}n|�||��}n|||��}nD#tj$r2}|jtjtjfvr|�|j}Yd}~nd}~wwxYw|j���}|j�|��|�d}ne|tjkrU|j�	t��}|r|j�|��n|j�
��|��tjt |��S)z>Performs an I/O loop between incoming/outgoing and the socket.TNF)r r�r��SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITEr#r>rrVrC�
SSL_BLOCKSIZEr"rX�	write_eof�typingrOr
)	r'r�r�r��should_loop�retr�r��bufs	         rr%zSSLTransport._ssl_io_loop�sX�������	.��E�
 ��<�D�L��$�&�&�C�C��\��$�t�*�*�C�C��$�t�T�*�*�C����<�
 �
 �
 ��7�3�#:�C�<T�"U�U�U��G�������������	
 �����-�$�$�&�&�C��K����$�$�$��}�#����#�1�1�1��k�&�&�}�5�5���.��M�'�'��,�,�,�,��M�+�+�-�-�-�3�	.�4�{�<��-�-�-s�)5�A6�(A1�1A6)rrrr)NT)
rrrrrrrrrr)r'r
rr
)r.r/rr)rr3)r7N)r8r3r9r:rr;)r7r)r?r3r@r3rr;r�)r9rDrErFr@r3rrG)r)rJrKr@r3rr)rJrKr@r3rr3r*)r\r]r^rFrYrrZrr[rrr_)rr).)ryrzrr{)ryrrr�)F)ryrrr)rr)rr�)rr�)r�r�rr)rr�)r8r3r9r�rr;)r�r�rr)r�r�r�rKrr3)r�r�r�r3r�r�rrK)NN)r�r�r�r�r�r�rr
) �__name__�
__module__�__qualname__�__doc__�staticmethodrr(r-r2r5r>rCrIrVrPrurwr1r��overloadr~r�r�r�r�r�r�r�r�r�r=r%r+rrrrs5���������
�
�
��\�
�&'+�%)�4�4�4�4�4�.��������$�$�$�$�0�0�0�0�0�+�+�+�+�+�"��	
)�
)�
)�
)�
)������:�:�:�:�:�!%�2�
 $�!�"�2�2�2�2�2�2�h.�.�.�.������_�,/������_��
�_�����_��4�4�4�4�4�%�%�%�%�$�$�$�$�4�4�4�4�3�3�3�3�,�,�,�,�)�)�)�)�&�&�&�&�(�(�(�(�(�(�(�(�������_�����_���_�����_���_�����_��$(�!%�	$.�$.�$.�$.�$.�$.�$.r)�
__future__rrirr r��
exceptionsr�
TYPE_CHECKING�typing_extensionsr�ssl_rr	�TypeVarr
�Union�	bytearrayrNrDr
r�rr+rr�<module>r�s���"�"�"�"�"�"�	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�/�/�/�/�/�/�	��D�)�)�)�)�)�)�C�C�C�C�C�C�C�C�
�����	7�	7�	7���|�I�z�1�2���v�~�n�-�-���
�A.�A.�A.�A.�A.�A.�A.�A.�A.�A.r

Hacked By AnonymousFox1.0, Coded By AnonymousFox