Hacked By AnonymousFox

Current Path : /opt/alt/python38/lib/python3.8/site-packages/urllib3/util/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib/python3.8/site-packages/urllib3/util/__pycache__/ssltransport.cpython-38.pyc

U

��`��@sFddlZddlZddlZddlmZddlmZdZGdd�d�ZdS)�N)�ProxySchemeUnsupported)�sixi@c@s�eZdZdZedd��Zd:dd�Zdd	�Zd
d�Zdd
�Z	d;dd�Z
d<dd�Zd=dd�Zd>dd�Z
d?dd�Zd@dd�Zdd�Zdd �ZdAd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdBd6d7�Zd8d9�ZdS)C�SSLTransportaL
    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.
    cCs&t|d�s"tjrtd��ntd��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_biozKTLS in TLS requires SSLContext.wrap_bio() which isn't supported on Python 2zXTLS in TLS requires SSLContext.wrap_bio() which isn't available on non-native SSLContextN)�hasattrr�PY2r)�ssl_context�r	�J/opt/alt/python38/lib/python3.8/site-packages/urllib3/util/ssltransport.py�$_validate_ssl_context_for_tls_in_tlss

��z1SSLTransport._validate_ssl_context_for_tls_in_tlsNTcCsHt��|_t��|_||_||_|j|j|j|d�|_|�|jj	�dS)zV
        Create an SSLTransport around socket using the provided ssl_context.
        )�server_hostnameN)
�sslZ	MemoryBIO�incoming�outgoing�suppress_ragged_eofs�socketr�sslobj�_ssl_io_loopZdo_handshake)�selfrrrrr	r	r
�__init__,s

�zSSLTransport.__init__cCs|S�Nr	�rr	r	r
�	__enter__?szSSLTransport.__enter__cGs|��dSr)�close)r�_r	r	r
�__exit__BszSSLTransport.__exit__cCs
|j��Sr)r�filenorr	r	r
rEszSSLTransport.fileno�cCs|�||�Sr)�_wrap_ssl_read)r�len�bufferr	r	r
�readHszSSLTransport.readrcCs|dkrtd��|�|�S)Nrz+non-zero flags not allowed in calls to recv)�
ValueErrorr)rr�flagsr	r	r
�recvKszSSLTransport.recvcCs>|dkrtd��|r&|dkr&t|�}n|dkr2d}|�||�S)Nrz0non-zero flags not allowed in calls to recv_intor)r"rr!)rr �nbytesr#r	r	r
�	recv_intoPs
zSSLTransport.recv_intoc
Csn|dkrtd��d}t|��H}|�d��2}t|�}||krV|�||d��}||7}q2W5QRXW5QRXdS)Nrz.non-zero flags not allowed in calls to sendall�B)r"�
memoryview�castr�send)r�datar#�count�view�	byte_view�amount�vr	r	r
�sendallYszSSLTransport.sendallcCs$|dkrtd��|�|jj|�}|S)Nrz+non-zero flags not allowed in calls to send)r"rr�write)rr+r#�responser	r	r
r*cszSSLTransport.send�rc
Cst|�dddhks td|f��d|k}d|kp4|}|sB|sBt�d|k}d}	|rZ|	d7}	|rf|	d7}	t�||	�}
|jjd7_|dkr�d}|d	kr�tj}|d	kr�|s�td
��|
S|r�|r�t�|
|
|�}n&|r�t�	|
|�}n|s�t�t�
|
|�}|r�|St�||||�}||_|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.
        r4�w�bz&invalid mode %r (only r, w, b allowed)��N���rz!unbuffered streams must be binary)
�setr"�AssertionErrorr�SocketIO�_io_refs�io�DEFAULT_BUFFER_SIZE�BufferedRWPair�BufferedReader�BufferedWriter�
TextIOWrapper�mode)
rrD�	buffering�encoding�errors�newline�writing�reading�binary�rawmode�rawr �textr	r	r
�makefileis@
zSSLTransport.makefilecCs|�|jj�dSr)rr�unwraprr	r	r
rP�szSSLTransport.unwrapcCs|j��dSr)rrrr	r	r
r�szSSLTransport.closeFcCs|j�|�Sr)r�getpeercert)rZbinary_formr	r	r
rQ�szSSLTransport.getpeercertcCs
|j��Sr)r�versionrr	r	r
rR�szSSLTransport.versioncCs
|j��Sr)r�cipherrr	r	r
rS�szSSLTransport.ciphercCs
|j��Sr)r�selected_alpn_protocolrr	r	r
rT�sz#SSLTransport.selected_alpn_protocolcCs
|j��Sr)r�selected_npn_protocolrr	r	r
rU�sz"SSLTransport.selected_npn_protocolcCs
|j��Sr)r�shared_ciphersrr	r	r
rV�szSSLTransport.shared_cipherscCs
|j��Sr)r�compressionrr	r	r
rW�szSSLTransport.compressioncCs|j�|�dSr)r�
settimeout)r�valuer	r	r
rX�szSSLTransport.settimeoutcCs
|j��Sr)r�
gettimeoutrr	r	r
rZ�szSSLTransport.gettimeoutcCs|j��dSr)r�_decref_socketiosrr	r	r
r[�szSSLTransport._decref_socketiosc
Cs\z|�|jj||�WStjk
rV}z"|jtjkrD|jrDWY�
dS�W5d}~XYnXdS)Nr)rrr!r
�SSLError�errnoZ
SSL_ERROR_EOFr)rrr �er	r	r
r�s
zSSLTransport._wrap_ssl_readc
Gs�d}d}|r�d}z||�}Wn@tjk
r\}z |jtjtjfkrF|�|j}W5d}~XYnX|j��}|j�|�|dkr�d}q|tjkr|j�	t
�}|r�|j�|�q|j�
�q|S)z>Performs an I/O loop between incoming/outgoing and the socket.TNF)r
r\r]ZSSL_ERROR_WANT_READZSSL_ERROR_WANT_WRITErr!rr1r$�
SSL_BLOCKSIZErr2Z	write_eof)r�func�argsZshould_loop�retr]r^�bufr	r	r
r�s(

zSSLTransport._ssl_io_loop)NT)rN)rr)Nr)r)r)r4NNNN)F)N)�__name__�
__module__�__qualname__�__doc__�staticmethodrrrrrr!r$r&r1r*rOrPrrQrRrSrTrUrVrWrXrZr[rrr	r	r	r
rsD

�



	


�
-

	r)	r>rr
Zurllib3.exceptionsrZurllib3.packagesrr_rr	r	r	r
�<module>s

Hacked By AnonymousFox1.0, Coded By AnonymousFox