<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
a
    XC?hCk                     @   s   d dl Z d dlZzd dlZW n ey2   dZY n0 ddlmZ ddlmZ ddlmZ ddlm	Z	 dd Z
d	Zd
ZdZdZG dd deZG dd dejejZG dd dejZdS )    N   )	constants)	protocols)
transports)loggerc                 C   s"   | rt dt }|sd|_|S )Nz(Server side SSL needs a valid SSLContextF)
ValueErrorsslZcreate_default_contextZcheck_hostname)server_sideserver_hostname
sslcontext r   5/opt/alt/python39/lib64/python3.9/asyncio/sslproto.py_create_transport_context   s    r   Z	UNWRAPPEDZDO_HANDSHAKEZWRAPPEDZSHUTDOWNc                   @   sz   e Zd ZdZdddZedd Zedd Zed	d
 Zedd Z	dddZ
dddZdd ZdddZdddZdS )_SSLPipei   Nc                 C   sH   || _ || _|| _t| _t | _t | _d | _	d| _
d | _d | _d S NF)_context_server_side_server_hostname
_UNWRAPPED_stater   Z	MemoryBIO	_incoming	_outgoing_sslobj_need_ssldata_handshake_cb_shutdown_cb)selfcontextr	   r
   r   r   r   __init__7   s    

z_SSLPipe.__init__c                 C   s   | j S N)r   r   r   r   r   r   M   s    z_SSLPipe.contextc                 C   s   | j S r   )r   r    r   r   r   
ssl_objectR   s    z_SSLPipe.ssl_objectc                 C   s   | j S r   )r   r    r   r   r   need_ssldataZ   s    z_SSLPipe.need_ssldatac                 C   s
   | j tkS r   )r   _WRAPPEDr    r   r   r   wrapped`   s    z_SSLPipe.wrappedc                 C   sR   | j tkrtd| jj| j| j| j| jd| _	t
| _ || _| jddd\}}|S )Nz"handshake in progress or completed)r	   r
       T)only_handshake)r   r   RuntimeErrorr   Zwrap_bior   r   r   r   r   _DO_HANDSHAKEr   feed_ssldatar   callbackssldataappdatar   r   r   do_handshakei   s    	
z_SSLPipe.do_handshakec                 C   sB   | j tkrtd| j tkr$tdt| _ || _| d\}}|S )Nzno security layer presentzshutdown in progressr%   )r   r   r'   	_SHUTDOWNr   r)   r*   r   r   r   shutdown~   s    	

z_SSLPipe.shutdownc                 C   s   | j   | d\}}d S )Nr%   )r   Z	write_eofr)   )r   r,   r-   r   r   r   feed_eof   s    
z_SSLPipe.feed_eofFc              
   C   s  | j tkr"|r|g}ng }g |fS d| _|r8| j| g }g }z| j tkrz| j  t| _ | j	rl| 	d  |rz||fW S | j tkr| j
| j}|| |sqqnJ| j tkr| j  d | _t| _ | jr|   n| j tkr|| j
  W n| tjtjfyn } zZt|dd }|tjtjtjfvrN| j tkrL| j	rL| 	|  |tjk| _W Y d }~n
d }~0 0 | jjr|| j
  ||fS )NFerrno)r   r   r   r   writer(   r   r.   r#   r   readmax_sizeappendr/   Zunwrapr   r   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_ssldatar   c              
   C   s  | j tkr6|t|k r&||d  g}ng }|t|fS g }t|}d| _z(|t|k rn|| j||d  7 }W nj tjy } zPt	|dd }|j
dkrtj }|_|tjtjtjfvr |tjk| _W Y d }~n
d }~0 0 | jjr|| j  |t|ks| jrBqqB||fS )NFr2   ZPROTOCOL_IS_SHUTDOWN)r   r   len
memoryviewr   r   r3   r   r7   r9   reasonr:   r2   r;   r<   r   r=   r6   r4   )r   r>   offsetr,   Zviewr@   rA   r   r   r   feed_appdata   s4    

"z_SSLPipe.feed_appdata)N)N)N)F)r   )__name__
__module____qualname__r5   r   propertyr   r!   r"   r$   r.   r0   r1   r)   rF   r   r   r   r   r   #   s   








Kr   c                   @   s   e Zd ZejjZdd Zd$ddZdd Z	dd	 Z
d
d Zdd ZejfddZdd Zdd Zdd Zd%ddZdd Zdd Zedd Zdd Zd d! Zd"d# ZdS )&_SSLProtocolTransportc                 C   s   || _ || _d| _d S r   )_loop_ssl_protocol_closed)r   loopZssl_protocolr   r   r   r      s    z_SSLProtocolTransport.__init__Nc                 C   s   | j ||S r   )rM   _get_extra_infor   namedefaultr   r   r   get_extra_info&  s    z$_SSLProtocolTransport.get_extra_infoc                 C   s   | j | d S r   )rM   _set_app_protocol)r   protocolr   r   r   set_protocol*  s    z"_SSLProtocolTransport.set_protocolc                 C   s   | j jS r   )rM   _app_protocolr    r   r   r   get_protocol-  s    z"_SSLProtocolTransport.get_protocolc                 C   s   | j S r   )rN   r    r   r   r   
is_closing0  s    z _SSLProtocolTransport.is_closingc                 C   s   d| _ | j  d S NT)rN   rM   _start_shutdownr    r   r   r   close3  s    z_SSLProtocolTransport.closec                 C   s&   | j s"|d| t| d |   d S )Nzunclosed transport )source)rN   ResourceWarningr]   )r   Z_warnr   r   r   __del__>  s    z_SSLProtocolTransport.__del__c                 C   s    | j j}|d u rtd| S )Nz*SSL transport has not been initialized yet)rM   
_transportr'   
is_reading)r   Ztrr   r   r   rb   C  s    z _SSLProtocolTransport.is_readingc                 C   s   | j j  d S r   )rM   ra   pause_readingr    r   r   r   rc   I  s    z#_SSLProtocolTransport.pause_readingc                 C   s   | j j  d S r   )rM   ra   resume_readingr    r   r   r   rd   Q  s    z$_SSLProtocolTransport.resume_readingc                 C   s   | j j|| d S r   )rM   ra   set_write_buffer_limits)r   ZhighZlowr   r   r   re   Y  s    z-_SSLProtocolTransport.set_write_buffer_limitsc                 C   s   | j j S r   )rM   ra   get_write_buffer_sizer    r   r   r   rf   n  s    z+_SSLProtocolTransport.get_write_buffer_sizec                 C   s   | j j S r   )rM   ra   get_write_buffer_limitsr    r   r   r   rg   r  s    z-_SSLProtocolTransport.get_write_buffer_limitsc                 C   s
   | j jjS r   )rM   ra   _protocol_pausedr    r   r   r   rh   x  s    z&_SSLProtocolTransport._protocol_pausedc                 C   s<   t |tttfs$tdt|j |s,d S | j| d S )Nz+data: expecting a bytes-like instance, got )	
isinstancebytes	bytearrayrC   	TypeErrortyperG   rM   _write_appdatar   r>   r   r   r   r3   }  s    z_SSLProtocolTransport.writec                 C   s   dS r   r   r    r   r   r   can_write_eof  s    z#_SSLProtocolTransport.can_write_eofc                 C   s   | j   d| _d S r[   )rM   _abortrN   r    r   r   r   abort  s    
z_SSLProtocolTransport.abort)N)NN)rG   rH   rI   r   Z_SendfileModeZFALLBACKZ_sendfile_compatibler   rT   rW   rY   rZ   r]   warningswarnr`   rb   rc   rd   re   rf   rg   rJ   rh   r3   rp   rr   r   r   r   r   rK     s&   


rK   c                   @   s   e Zd Zd+ddZdd Zd,dd	Zd
d Zdd Zdd Zdd Z	dd Z
dd Zd-ddZdd Zdd Zdd Zdd Zd d! Zd"d# Zd.d%d&Zd'd( Zd)d* ZdS )/SSLProtocolFNTc	           	      C   s   t d u rtd|d u r tj}n|dkr6td| |sDt||}|| _|rZ|sZ|| _nd | _|| _t	|d| _
t | _d| _|| _|| _| | t| j| | _d | _d| _d| _d| _d | _|| _|| _d S )Nzstdlib ssl module not availabler   z7ssl_handshake_timeout should be a positive number, got )r   F)r   r'   r   ZSSL_HANDSHAKE_TIMEOUTr   r   r   r   _sslcontextdict_extracollectionsdeque_write_backlog_write_buffer_size_waiterrL   rU   rK   _app_transport_sslpipe_session_established_in_handshake_in_shutdownra   _call_connection_made_ssl_handshake_timeout)	r   rO   app_protocolr   Zwaiterr	   r
   Zcall_connection_madeZssl_handshake_timeoutr   r   r   r     sB    

zSSLProtocol.__init__c                 C   s   || _ t|tj| _d S r   )rX   ri   r   ZBufferedProtocol_app_protocol_is_buffer)r   r   r   r   r   rU     s    
zSSLProtocol._set_app_protocolc                 C   sD   | j d u rd S | j  s:|d ur.| j | n| j d  d | _ d S r   )r}   Z	cancelledZset_exceptionZ
set_resultr   r@   r   r   r   _wakeup_waiter  s    

zSSLProtocol._wakeup_waiterc                 C   s&   || _ t| j| j| j| _|   d S r   )ra   r   rv   r   r   r   _start_handshake)r   	transportr   r   r   connection_made  s    zSSLProtocol.connection_madec                 C   sn   | j r d| _ | j| jj| n| jd ur2d| j_d | _d | _t| dd rT| j	
  | | d | _d | _d S )NFT_handshake_timeout_handle)r   rL   	call_soonrX   connection_lostr~   rN   ra   r9   r   cancelr   r   r   r   r   r   r     s    


zSSLProtocol.connection_lostc                 C   s   | j   d S r   )rX   pause_writingr    r   r   r   r      s    zSSLProtocol.pause_writingc                 C   s   | j   d S r   )rX   resume_writingr    r   r   r   r     s    zSSLProtocol.resume_writingc                 C   s  | j d u rd S z| j |\}}W nH ttfy:    Y n2 tyj } z| |d W Y d }~d S d }~0 0 |D ]}| j| qp|D ]}|rz&| jrt	
| j| n| j| W nL ttfy    Y n6 ty } z| |d W Y d }~ d S d }~0 0 q|    qqd S )NzSSL error in data receivedz/application protocol failed to receive SSL data)r   r)   
SystemExitKeyboardInterruptBaseException_fatal_errorra   r3   r   r   Z_feed_data_to_buffered_protorX   data_receivedr\   )r   r>   r,   r-   er?   Zexr   r   r   r     s8    
zSSLProtocol.data_receivedc                 C   s^   zL| j  rtd|  | t | js@| j }|r@t	d W | j
  n| j
  0 d S )Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rL   	get_debugr   debugr   ConnectionResetErrorr   rX   eof_receivedZwarningra   r]   )r   Z	keep_openr   r   r   r   2  s    


zSSLProtocol.eof_receivedc                 C   s4   || j v r| j | S | jd ur,| j||S |S d S r   )rx   ra   rT   rQ   r   r   r   rP   H  s
    


zSSLProtocol._get_extra_infoc                 C   s.   | j r
d S | jr|   nd| _ | d d S )NTr%   )r   r   rq   rn   r    r   r   r   r\   P  s    
zSSLProtocol._start_shutdownc                 C   s.   | j |df |  jt|7  _|   d S )Nr   )r{   r6   r|   rB   _process_write_backlogro   r   r   r   rn   Y  s    zSSLProtocol._write_appdatac                 C   s\   | j  r$td|  | j  | _nd | _d| _| jd | j 	| j
| j| _|   d S )Nz%r starts SSL handshakeT)r%   r   )rL   r   r   r   time_handshake_start_timer   r{   r6   Z
call_laterr   _check_handshake_timeoutr   r   r    r   r   r   r   ^  s    

zSSLProtocol._start_handshakec                 C   s*   | j du r&d| j d}| t| d S )NTz$SSL handshake is taking longer than z! seconds: aborting the connection)r   r   r   ConnectionAbortedError)r   msgr   r   r   r   m  s    
z$SSLProtocol._check_handshake_timeoutc              
   C   s  d| _ | j  | jj}z|d ur&|| }W n^ ttfyH    Y nH ty } z0t	|t
jrhd}nd}| || W Y d }~d S d }~0 0 | j r| j | j }td| |d  | jj|| | |d | jr| j| j |   d| _| j| j d S )NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg     @@)peercertciphercompressionr!   T)r   r   r   r   r!   Zgetpeercertr   r   r   ri   r   r8   r   rL   r   r   r   r   r   rx   updater   r   r   rX   r   r~   r   r   r   r   )r   Zhandshake_excZsslobjr   r@   r   Zdtr   r   r   _on_handshake_completev  s8    

z"SSLProtocol._on_handshake_completec              
   C   sB  | j d u s| jd u rd S ztt| jD ]}| jd \}}|rR| j||\}}n*|rj| j| j}d}n| j| j	}d}|D ]}| j 
| q|t|k r||f| jd< | j jr| j    q| jd= |  jt|8  _q(W n\ ttfy    Y nF ty< } z,| jr| | n| |d W Y d }~n
d }~0 0 d S )Nr   r   zFatal error on SSL transport)ra   r   rangerB   r{   rF   r.   r   r0   	_finalizer3   Z_pausedrd   r|   r   r   r   r   r   )r   ir>   rE   r,   r?   r@   r   r   r   r     s:    
z"SSLProtocol._process_write_backlogFatal error on transportc                 C   sV   t |tr(| j r@tjd| |dd n| j||| j| d | jrR| j| d S )Nz%r: %sT)exc_info)messageZ	exceptionr   rV   )	ri   OSErrorrL   r   r   r   Zcall_exception_handlerra   Z_force_close)r   r@   r   r   r   r   r     s    

zSSLProtocol._fatal_errorc                 C   s   d | _ | jd ur| j  d S r   )r   ra   r]   r    r   r   r   r     s    
zSSLProtocol._finalizec                 C   s0   z | j d ur| j   W |   n
|   0 d S r   )ra   rr   r   r    r   r   r   rq     s    
zSSLProtocol._abort)FNTN)N)N)r   )rG   rH   rI   r   rU   r   r   r   r   r   r   r   rP   r\   rn   r   r   r   r   r   r   rq   r   r   r   r   ru     s,      
.

&
		)+
ru   )ry   rs   r   ImportError r   r   r   logr   r   r   r(   r#   r/   objectr   Z_FlowControlMixinZ	TransportrK   Protocolru   r   r   r   r   <module>   s(   
 y~