Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/asyncio/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/asyncio/__pycache__/sslproto.cpython-37.opt-2.pyc

B

YI~d/i�@s�ddlZddlZyddlZWnek
r4dZYnXddlmZddlmZddlmZddlmZddl	m
Z
dd	�Zd
ZdZ
dZd
ZGdd�de�ZGdd�dejej�ZGdd�dej�ZdS)�N�)�base_events)�	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/python37/lib64/python3.7/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�_stater	Z	MemoryBIO�	_incoming�	_outgoing�_sslobj�
_need_ssldata�
_handshake_cb�_shutdown_cb)�self�contextr
rr
r
r�__init__8s

z_SSLPipe.__init__cCs|jS)N)r)rr
r
rrNsz_SSLPipe.contextcCs|jS)N)r)rr
r
r�
ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)N)r)rr
r
r�need_ssldata[sz_SSLPipe.need_ssldatacCs
|jtkS)N)r�_WRAPPED)rr
r
r�wrappedasz_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_handshakejs	
z_SSLPipe.do_handshakecCsB|jtkrtd��|jtkr$td��t|_||_|�d�\}}|S)Nzno security layer presentzshutdown in progressr#)rrr%�	_SHUTDOWNrr')rr(r)r*r
r
r�shutdowns	

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}y�|jtkrx|j��t|_|j	rl|�	d�|rx||fS|jtkr�xn|j�
|j�}|�|�|s�Pq�WnJ|jt
kr�|j��d|_t|_|jr�|��n|jtkr�|�|j�
��Wnztjtjfk
�rn}zRt|dd�}|tjtjtjfk�rR|jtk�rP|j	�rP|�	|��|tjk|_Wdd}~XYnX|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
rr'�sX











z_SSLPipe.feed_ssldatarc
Cs|jtkr6|t|�kr&||d�g}ng}|t|�fSg}t|�}x�d|_y(|t|�krp||j�||d��7}Wnhtjk
r�}zHt	|dd�}|j
dkr�tj}|_|tjtj
tjfkr��|tjk|_Wdd}~XYnX|jjr�|�|j���|t|�k�s|jrDPqDW||fS)NFr/ZPROTOCOL_IS_SHUTDOWN)rr�len�
memoryviewrrr0r	r4r6�reasonr7r/r8r9rr:r3r1)rr;�offsetr)Zviewr=r>r
r
r�feed_appdata�s4


z_SSLPipe.feed_appdata)N)N)N)F)r)�__name__�
__module__�__qualname__r2r�propertyrrr r"r+r-r.r'rCr
r
r
rr$s
	



Krc@s�eZdZejjZdd�Zd"dd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zd#dd�Zdd�Zedd��Zdd�Zdd�Zd d!�ZdS)$�_SSLProtocolTransportcCs||_||_d|_dS)NF)�_loop�
_ssl_protocol�_closed)r�loopZssl_protocolr
r
rr!sz_SSLProtocolTransport.__init__NcCs|j�||�S)N)rJ�_get_extra_info)r�name�defaultr
r
r�get_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j�|�dS)N)rJ�_set_app_protocol)r�protocolr
r
r�set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rJ�
_app_protocol)rr
r
r�get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rK)rr
r
r�
is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|j��dS)NT)rKrJ�_start_shutdown)rr
r
r�close4sz_SSLProtocolTransport.closecCs(|js$tjd|��t|d�|��dS)Nzunclosed transport )�source)rK�warnings�warn�ResourceWarningrX)rr
r
r�__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd��|��S)Nz*SSL transport has not been initialized yet)rJ�
_transportr%�
is_reading)r�trr
r
rr_Esz _SSLProtocolTransport.is_readingcCs|jj��dS)N)rJr^�
pause_reading)rr
r
rraKsz#_SSLProtocolTransport.pause_readingcCs|jj��dS)N)rJr^�resume_reading)rr
r
rrbSsz$_SSLProtocolTransport.resume_readingcCs|jj�||�dS)N)rJr^�set_write_buffer_limits)rZhighZlowr
r
rrc[sz-_SSLProtocolTransport.set_write_buffer_limitscCs|jj��S)N)rJr^�get_write_buffer_size)rr
r
rrdpsz+_SSLProtocolTransport.get_write_buffer_sizecCs
|jjjS)N)rJr^�_protocol_paused)rr
r
rretsz&_SSLProtocolTransport._protocol_pausedcCs<t|tttf�s$tdt|�j����|s,dS|j�|�dS)Nz+data: expecting a bytes-like instance, got )	�
isinstance�bytes�	bytearrayr@�	TypeError�typerDrJ�_write_appdata)rr;r
r
rr0ys
z_SSLProtocolTransport.writecCsdS)NFr
)rr
r
r�
can_write_eof�sz#_SSLProtocolTransport.can_write_eofcCs|j��d|_dS)NT)rJ�_abortrK)rr
r
r�abort�s
z_SSLProtocolTransport.abort)N)NN)rDrErFrZ
_SendfileModeZFALLBACKZ_sendfile_compatiblerrPrSrUrVrXr]r_rarbrcrdrGrer0rlrnr
r
r
rrHs"


rHc@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�tdkrtd��|dkr 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 )rF)r	r%rZSSL_HANDSHAKE_TIMEOUTrrrr�_sslcontext�dict�_extra�collections�deque�_write_backlog�_write_buffer_size�_waiterrIrQrH�_app_transport�_sslpipe�_session_established�
_in_handshake�_in_shutdownr^�_call_connection_made�_ssl_handshake_timeout)	rrL�app_protocolrZwaiterr
rZcall_connection_madeZssl_handshake_timeoutr
r
rr�s:

zSSLProtocol.__init__cCs||_t|tj�|_dS)N)rTrfrZBufferedProtocol�_app_protocol_is_buffer)rrr
r
rrQ�szSSLProtocol._set_app_protocolcCsD|jdkrdS|j��s:|dk	r.|j�|�n|j�d�d|_dS)N)rwZ	cancelledZ
set_exceptionZ
set_result)rr=r
r
r�_wakeup_waiter�s

zSSLProtocol._wakeup_waitercCs&||_t|j|j|j�|_|��dS)N)r^rrprrry�_start_handshake)r�	transportr
r
r�connection_made�s

zSSLProtocol.connection_madecCsn|jr d|_|j�|jj|�n|jdk	r2d|j_d|_d|_t|dd�rT|j	�
�|�|�d|_d|_dS)NFT�_handshake_timeout_handle)
rzrI�	call_soonrT�connection_lostrxrKr^r6r��cancelr�ry)rr=r
r
rr��s


zSSLProtocol.connection_lostcCs|j��dS)N)rT�
pause_writing)rr
r
rr��szSSLProtocol.pause_writingcCs|j��dS)N)rT�resume_writing)rr
r
rr�szSSLProtocol.resume_writingcCs�|jdkrdSy|j�|�\}}Wn.tk
rP}z|�|d�dSd}~XYnXx|D]}|j�|�qXWxr|D]j}|r�y&|jr�t�|j	|�n|j	�
|�Wq�tk
r�}z|�|d�dSd}~XYq�Xqr|��PqrWdS)NzSSL error in data receivedz/application protocol failed to receive SSL data)ryr'�	Exception�_fatal_errorr^r0r�rZ_feed_data_to_buffered_protorT�
data_receivedrW)rr;r)r*�er<Zexr
r
rr�s,


zSSLProtocol.data_receivedcCsTzB|j��rt�d|�|�t�|js@|j��}|r@t�	d�Wd|j
��XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rI�	get_debugr�debugr��ConnectionResetErrorr{rT�eof_receivedZwarningr^rX)rZ	keep_openr
r
rr�*s


zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk	r,|j�||�S|SdS)N)rrr^rP)rrNrOr
r
rrM@s



zSSLProtocol._get_extra_infocCs.|jr
dS|jr|��nd|_|�d�dS)NTr#)r|r{rmrk)rr
r
rrWHs
zSSLProtocol._start_shutdowncCs.|j�|df�|jt|�7_|��dS)Nr)rur3rvr?�_process_write_backlog)rr;r
r
rrkQszSSLProtocol._write_appdatacCs\|j��r$t�d|�|j��|_nd|_d|_|j�d�|j�	|j
|j�|_|�
�dS)Nz%r starts SSL handshakeT)r#r)rIr�rr��time�_handshake_start_timer{rur3Z
call_laterr~�_check_handshake_timeoutr�r�)rr
r
rr�Vs


zSSLProtocol._start_handshakecCs*|jdkr&d|j�d�}|�t|��dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r{r~r��ConnectionAbortedError)r�msgr
r
rr�es
z$SSLProtocol._check_handshake_timeoutc
Cs�d|_|j��|jj}y|dk	r&|�|��}WnDtk
rt}z&t|tj	�rTd}nd}|�
||�dSd}~XYnX|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�compressionrT)r{r�r�ryrZgetpeercertr�rfr	r5r�rIr�r�r�rr�rr�updater�r�r}rTr�rxr�rzr�r�)rZ
handshake_excZsslobjr�r=r�Zdtr
r
r�_on_handshake_completens2

z"SSLProtocol._on_handshake_completec
Cs0|jdks|jdkrdSy�x�tt|j��D]�}|jd\}}|rT|j�||�\}}n*|rl|j�|j�}d}n|j�|j	�}d}x|D]}|j�
|�q�W|t|�kr�||f|jd<|jjr�|j��P|jd=|j
t|�8_
q*WWnDtk
�r*}z$|j�r|�|�n|�|d�Wdd}~XYnXdS)NrrzFatal error on SSL transport)r^ry�ranger?rurCr+r�r-�	_finalizer0Z_pausedrbrvr�r{r�)r�ir;rBr)r<r=r
r
rr��s4

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�rR)	rf�OSErrorrIr�rr�Zcall_exception_handlerr^Z_force_close)rr=r�r
r
rr��s


zSSLProtocol._fatal_errorcCsd|_|jdk	r|j��dS)N)ryr^rX)rr
r
rr��s
zSSLProtocol._finalizecCs(z|jdk	r|j��Wd|��XdS)N)r^rnr�)rr
r
rrm�s
zSSLProtocol._abort)FNTN)N)N)r�)rDrErFrrQr�r�r�r�r�r�r�rMrWrkr�r�r�r�r�r�rmr
r
r
rro�s*
+

"
		')
ro)rsrZr	�ImportError�rrrr�logrrrr&r!r,�objectrZ_FlowControlMixinZ	TransportrHZProtocolror
r
r
r�<module>s(
yx

Hacked By AnonymousFox1.0, Coded By AnonymousFox