AlkantarClanX12

Your IP : 3.133.138.129


Current Path : /opt/alt/python39/lib64/python3.9/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/asyncio/__pycache__/sslproto.cpython-39.opt-2.pyc

a

R�fCk�@s�ddlZddlZzddlZWney2dZYn0ddlmZddlmZddlmZddlm	Z	dd�Z
d	Zd
ZdZ
dZGd
d�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�	constants)�	protocols)�
transports)�loggercCs"|rtd��t��}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF)�
ValueError�sslZcreate_default_contextZcheck_hostname)�server_side�server_hostname�
sslcontext�r�5/opt/alt/python39/lib64/python3.9/asyncio/sslproto.py�_create_transport_contextsrZ	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc@szeZdZdZddd�Zedd��Zedd��Zed	d
��Zedd��Z	dd
d�Z
ddd�Zdd�Zddd�Z
ddd�ZdS)�_SSLPipeiNcCsH||_||_||_t|_t��|_t��|_d|_	d|_
d|_d|_dS�NF)
�_context�_server_side�_server_hostname�
_UNWRAPPED�_staterZ	MemoryBIO�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextr	r
rrr
�__init__7s

z_SSLPipe.__init__cCs|jS�N)r�rrrr
rMsz_SSLPipe.contextcCs|jSr)rr rrr
�
ssl_objectRsz_SSLPipe.ssl_objectcCs|jSr)rr rrr
�need_ssldataZsz_SSLPipe.need_ssldatacCs
|jtkSr)r�_WRAPPEDr rrr
�wrapped`sz_SSLPipe.wrappedcCsR|jtkrtd��|jj|j|j|j|jd�|_	t
|_||_|jddd�\}}|S)Nz"handshake in progress or completed)r	r
�T)�only_handshake)
rr�RuntimeErrorrZwrap_biorrrrr�
_DO_HANDSHAKEr�feed_ssldata�r�callback�ssldata�appdatarrr
�do_handshakeis	
�z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|�d�\}}|S)Nzno security layer presentzshutdown in progressr%)rrr'�	_SHUTDOWNrr)r*rrr
�shutdown~s	

z_SSLPipe.shutdowncCs|j��|�d�\}}dS)Nr%)rZ	write_eofr))rr,r-rrr
�feed_eof�s
z_SSLPipe.feed_eofFc
Cs�|jtkr"|r|g}ng}g|fSd|_|r8|j�|�g}g}z�|jtkrz|j��t|_|j	rl|�	d�|rz||fWS|jtkr�|j�
|j�}|�|�|s�q�q�nJ|jt
kr�|j��d|_t|_|jr�|��n|jtkr�|�|j�
��Wn|tjtjf�yn}zZt|dd�}|tjtjtjfv�rN|jtk�rL|j	�rL|�	|��|tjk|_WYd}~n
d}~00|jj�r�|�|j�
��||fS)NF�errno)rrrr�writer(rr.r#r�read�max_size�appendr/Zunwraprr�SSLError�CertificateError�getattr�SSL_ERROR_WANT_READ�SSL_ERROR_WANT_WRITE�SSL_ERROR_SYSCALLr�pending)r�datar&r-r,�chunk�exc�	exc_errnorrr
r)�sX










�
"
z_SSLPipe.feed_ssldatarc
Cs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}d|_z(|t|�krn||j�||d��7}Wnjtjy�}zPt	|dd�}|j
dkr�tj}|_|tjtj
tjfvr��|tjk|_WYd}~n
d}~00|jjr�|�|j���|t|�k�s|jrB�qqB||fS)NFr2ZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewrrr3rr7r9�reasonr:r2r;r<rr=r6r4)rr>�offsetr,Zviewr@rArrr
�feed_appdata�s4

�"z_SSLPipe.feed_appdata)N)N)N)F)r)�__name__�
__module__�__qualname__r5r�propertyrr!r"r$r.r0r1r)rFrrrr
r#s








Krc@s�eZdZejjZdd�Zd$dd�Zdd�Z	dd	�Z
d
d�Zdd
�Ze
jfdd�Zdd�Zdd�Zdd�Zd%dd�Zdd�Zdd�Zedd��Zdd�Zd d!�Zd"d#�ZdS)&�_SSLProtocolTransportcCs||_||_d|_dSr)�_loop�
_ssl_protocol�_closed)r�loopZssl_protocolrrr
r sz_SSLProtocolTransport.__init__NcCs|j�||�Sr)rM�_get_extra_info�r�name�defaultrrr
�get_extra_info&sz$_SSLProtocolTransport.get_extra_infocCs|j�|�dSr)rM�_set_app_protocol)r�protocolrrr
�set_protocol*sz"_SSLProtocolTransport.set_protocolcCs|jjSr)rM�
_app_protocolr rrr
�get_protocol-sz"_SSLProtocolTransport.get_protocolcCs|jSr)rNr rrr
�
is_closing0sz _SSLProtocolTransport.is_closingcCsd|_|j��dS�NT)rNrM�_start_shutdownr rrr
�close3sz_SSLProtocolTransport.closecCs&|js"|d|��t|d�|��dS)Nzunclosed transport )�source)rN�ResourceWarningr])rZ_warnrrr
�__del__>sz_SSLProtocolTransport.__del__cCs |jj}|durtd��|��S)Nz*SSL transport has not been initialized yet)rM�
_transportr'�
is_reading)rZtrrrr
rbCsz _SSLProtocolTransport.is_readingcCs|jj��dSr)rMra�
pause_readingr rrr
rcIsz#_SSLProtocolTransport.pause_readingcCs|jj��dSr)rMra�resume_readingr rrr
rdQsz$_SSLProtocolTransport.resume_readingcCs|jj�||�dSr)rMra�set_write_buffer_limits)rZhighZlowrrr
reYsz-_SSLProtocolTransport.set_write_buffer_limitscCs|jj��Sr)rMra�get_write_buffer_sizer rrr
rfnsz+_SSLProtocolTransport.get_write_buffer_sizecCs|jj��Sr)rMra�get_write_buffer_limitsr rrr
rgrsz-_SSLProtocolTransport.get_write_buffer_limitscCs
|jjjSr)rMra�_protocol_pausedr rrr
rhxsz&_SSLProtocolTransport._protocol_pausedcCs<t|tttf�s$tdt|�j����|s,dS|j�|�dS)Nz+data: expecting a bytes-like instance, got )	�
isinstance�bytes�	bytearrayrC�	TypeError�typerGrM�_write_appdata�rr>rrr
r3}s�z_SSLProtocolTransport.writecCsdSrrr rrr
�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|j��d|_dSr[)rM�_abortrNr rrr
�abort�s
z_SSLProtocolTransport.abort)N)NN)rGrHrIrZ
_SendfileModeZFALLBACKZ_sendfile_compatiblerrTrWrYrZr]�warnings�warnr`rbrcrdrerfrgrJrhr3rprrrrrr
rKs&



rKc@s�eZdZd+dd�Zdd�Zd,dd	�Zd
d�Zdd
�Zdd�Zdd�Z	dd�Z
dd�Zd-dd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zd.d%d&�Zd'd(�Zd)d*�ZdS)/�SSLProtocolFNTc		Cs�tdurtd��|dur tj}n|dkr6td|����|sDt||�}||_|rZ|sZ||_nd|_||_t	|d�|_
t��|_
d|_||_||_|�|�t|j|�|_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )rF)rr'rZSSL_HANDSHAKE_TIMEOUTrrrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrLrUrK�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownra�_call_connection_made�_ssl_handshake_timeout)	rrO�app_protocolrZwaiterr	r
Zcall_connection_madeZssl_handshake_timeoutrrr
r�sB���

zSSLProtocol.__init__cCs||_t|tj�|_dSr)rXrirZBufferedProtocol�_app_protocol_is_buffer)rr�rrr
rU�s
�zSSLProtocol._set_app_protocolcCsD|jdurdS|j��s:|dur.|j�|�n|j�d�d|_dSr)r}Z	cancelledZ
set_exceptionZ
set_result�rr@rrr
�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|��dSr)rarrvrrr�_start_handshake)r�	transportrrr
�connection_made�s�zSSLProtocol.connection_madecCsn|jr d|_|j�|jj|�n|jdur2d|j_d|_d|_t|dd�rT|j	�
�|�|�d|_d|_dS)NFT�_handshake_timeout_handle)
r�rL�	call_soonrX�connection_lostr~rNrar9r��cancelr�rr�rrr
r��s


zSSLProtocol.connection_lostcCs|j��dSr)rX�
pause_writingr rrr
r�szSSLProtocol.pause_writingcCs|j��dSr)rX�resume_writingr rrr
r�szSSLProtocol.resume_writingcCs|jdurdSz|j�|�\}}WnHttfy:�Yn2tyj}z|�|d�WYd}~dSd}~00|D]}|j�|�qp|D]�}|�rz&|jr�t	�
|j|�n|j�|�WnLttfy��Yn6t�y}z|�|d�WYd}~dSd}~00q�|�
��qq�dS)NzSSL error in data receivedz/application protocol failed to receive SSL data)rr)�
SystemExit�KeyboardInterrupt�
BaseException�_fatal_errorrar3r�rZ_feed_data_to_buffered_protorX�
data_receivedr\)rr>r,r-�er?Zexrrr
r�s8
��zSSLProtocol.data_receivedcCs^zL|j��rt�d|�|�t�|js@|j��}|r@t�	d�W|j
��n|j
��0dS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rL�	get_debugr�debugr��ConnectionResetErrorr�rX�eof_receivedZwarningrar])rZ	keep_openrrr
r�2s


zSSLProtocol.eof_receivedcCs4||jvr|j|S|jdur,|j�||�S|SdSr)rxrarTrQrrr
rPHs



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|��nd|_|�d�dS)NTr%)r�r�rqrnr rrr
r\Ps
zSSLProtocol._start_shutdowncCs.|j�|df�|jt|�7_|��dS)Nr)r{r6r|rB�_process_write_backlogrorrr
rnYszSSLProtocol._write_appdatacCs\|j��r$t�d|�|j��|_nd|_d|_|j�d�|j�	|j
|j�|_|�
�dS)Nz%r starts SSL handshakeT)r%r)rLr�rr��time�_handshake_start_timer�r{r6Z
call_laterr��_check_handshake_timeoutr�r�r rrr
r�^s

��zSSLProtocol._start_handshakecCs*|jdur&d|j�d�}|�t|��dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r�r�r��ConnectionAbortedError)r�msgrrr
r�ms
��z$SSLProtocol._check_handshake_timeoutc
Csd|_|j��|jj}z|dur&|�|��}Wn^ttfyH�YnHty�}z0t	|t
j�rhd}nd}|�||�WYd}~dSd}~00|j
��r�|j
��|j}t�d||d�|jj||��|��|d�|jr�|j�|j�|��d|_|j
�|j�dS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@�@)�peercert�cipher�compressionr!T)r�r�r�rr!Zgetpeercertr�r�r�rirr8r�rLr�r�r�rr�rx�updater�r�r�rXr�r~r�r�r�r�)rZ
handshake_excZsslobjr�r@r�Zdtrrr
�_on_handshake_completevs8

�z"SSLProtocol._on_handshake_completec
CsB|jdus|jdurdSz�tt|j��D]�}|jd\}}|rR|j�||�\}}n*|rj|j�|j�}d}n|j�|j	�}d}|D]}|j�
|�q�|t|�kr�||f|jd<|jjr�|j��q�|jd=|j
t|�8_
q(Wn\ttfy��YnFt�y<}z,|j�r|�|�n|�|d�WYd}~n
d}~00dS)NrrzFatal error on SSL transport)rar�rangerBr{rFr.r�r0�	_finalizer3Z_pausedrdr|r�r�r�r�r�)r�ir>rEr,r?r@rrr
r��s:�
z"SSLProtocol._process_write_backlog�Fatal error on transportcCsVt|t�r(|j��r@tjd||dd�n|j�|||j|d��|jrR|j�|�dS)Nz%r: %sT)�exc_info)�messageZ	exceptionr�rV)	ri�OSErrorrLr�rr�Zcall_exception_handlerraZ_force_close)rr@r�rrr
r��s

�zSSLProtocol._fatal_errorcCsd|_|jdur|j��dSr)rrar]r rrr
r��s
zSSLProtocol._finalizecCs0z |jdur|j��W|��n
|��0dSr)rarrr�r rrr
rq�s
zSSLProtocol._abort)FNTN)N)N)r�)rGrHrIrrUr�r�r�r�r�r�r�rPr\rnr�r�r�r�r�r�rqrrrr
ru�s,�
.

&
		)+
ru)ryrsr�ImportError�rrr�logrrrr(r#r/�objectrZ_FlowControlMixinZ	TransportrK�Protocolrurrrr
�<module>s(
y�~