<!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>
3
2ae                 @   s   d dl Z d dlZyd dlZW n ek
r4   dZY nX ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dd	 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   )base_events)compat)	protocols)
transports)loggerc             C   sj   | rt dttdr*tj }|sfd|_n<tjtj}| jtjO  _| jtj	O  _|j
  tj|_|S )Nz(Server side SSL needs a valid SSLContextcreate_default_contextF)
ValueErrorhasattrsslr   check_hostnameZ
SSLContextZPROTOCOL_SSLv23optionsZOP_NO_SSLv2ZOP_NO_SSLv3Zset_default_verify_pathsZCERT_REQUIREDverify_mode)server_sideserver_hostname
sslcontext r   -/opt/alt/python36/lib64/python3.6/sslproto.py_create_transport_context   s    
r   c               C   s
   t tdS )N	MemoryBIO)r
   r   r   r   r   r   _is_sslproto_available%   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 ) _SSLPipe   i   Nc             C   sH   || _ || _|| _t| _tj | _tj | _d | _	d| _
d | _d | _d S )NF)_context_server_side_server_hostname
_UNWRAPPED_stater   r   	_incoming	_outgoing_sslobj_need_ssldata_handshake_cb_shutdown_cb)selfcontextr   r   r   r   r   __init__D   s    

z_SSLPipe.__init__c             C   s   | j S )N)r   )r$   r   r   r   r%   Z   s    z_SSLPipe.contextc             C   s   | j S )N)r    )r$   r   r   r   
ssl_object_   s    z_SSLPipe.ssl_objectc             C   s   | j S )N)r!   )r$   r   r   r   need_ssldatag   s    z_SSLPipe.need_ssldatac             C   s
   | j tkS )N)r   _WRAPPED)r$   r   r   r   wrappedm   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_handshakev   s    	
z_SSLPipe.do_handshakec             C   sB   | j tkrtd| j tkr$tdt| _ || _| jd\}}|S )Nzno security layer presentzshutdown in progressr+   )r   r   r-   	_SHUTDOWNr#   r/   )r$   r0   r1   r2   r   r   r   shutdown   s    	

z_SSLPipe.shutdownc             C   s   | j j  | jd\}}d S )Nr+   )r   Z	write_eofr/   )r$   r1   r2   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j| g }g }y| j tkrx| jj  t| _ | j	rl| j	d  |rx||fS | j tkrxn| jj
| j}|j| |sP qW nJ| j tkr| jj  d | _t| _ | jr| j  n| j tkr|j| jj
  W nx tjtjfk
rl } zRt|dd tjtjtjfkrN| j tkrL| j	rL| j	|  |jtjk| _W Y d d }~X nX | jjr|j| jj
  ||fS )NFerrno)r   r   r!   r   writer.   r    r3   r)   r"   readmax_sizeappendr4   Zunwrapr#   r   SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLr7   r   pending)r$   datar,   r2   r1   chunkexcr   r   r   r/      sV    











 
z_SSLPipe.feed_ssldatar   c             C   s  | j tkr6|t|k r&||d  g}ng }|t|fS g }t|}xd| _y(|t|k rp|| jj||d  7 }W n\ tjk
r } z>|j	dkrtj
|_|jtj
tjtjfkr |jtj
k| _W Y d d }~X nX | jjr|j| jj  |t|ks| jrDP qDW ||fS )NFZPROTOCOL_IS_SHUTDOWN)r   r   len
memoryviewr!   r    r8   r   r<   reasonr?   r7   r@   rA   r   rB   r;   r9   )r$   rC   offsetr1   ZviewrE   r   r   r   feed_appdata   s2    


 z_SSLPipe.feed_appdatai   )N)N)N)F)r   )__name__
__module____qualname__r:   r&   propertyr%   r'   r(   r*   r3   r5   r6   r/   rJ   r   r   r   r   r   0   s   
	



Jr   c               @   s   e Zd Zdd ZdddZdd Zdd	 Zd
d Zdd Ze	j
rHd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S ) _SSLProtocolTransportc             C   s   || _ || _d| _d S )NF)_loop_ssl_protocol_closed)r$   loopZssl_protocolr   r   r   r&   )  s    z_SSLProtocolTransport.__init__Nc             C   s   | j j||S )N)rQ   _get_extra_info)r$   namedefaultr   r   r   get_extra_info/  s    z$_SSLProtocolTransport.get_extra_infoc             C   s   || j _d S )N)rQ   _app_protocol)r$   protocolr   r   r   set_protocol3  s    z"_SSLProtocolTransport.set_protocolc             C   s   | j jS )N)rQ   rX   )r$   r   r   r   get_protocol6  s    z"_SSLProtocolTransport.get_protocolc             C   s   | j S )N)rR   )r$   r   r   r   
is_closing9  s    z _SSLProtocolTransport.is_closingc             C   s   d| _ | jj  d S )NT)rR   rQ   _start_shutdown)r$   r   r   r   close<  s    z_SSLProtocolTransport.closec             C   s&   | j s"tjd|  t| d | j  d S )Nzunclosed transport %r)source)rR   warningswarnResourceWarningr^   )r$   r   r   r   __del__K  s    z_SSLProtocolTransport.__del__c             C   s   | j jj  d S )N)rQ   
_transportpause_reading)r$   r   r   r   re   Q  s    z#_SSLProtocolTransport.pause_readingc             C   s   | j jj  d S )N)rQ   rd   resume_reading)r$   r   r   r   rf   Y  s    z$_SSLProtocolTransport.resume_readingc             C   s   | j jj|| d S )N)rQ   rd   set_write_buffer_limits)r$   ZhighZlowr   r   r   rg   a  s    z-_SSLProtocolTransport.set_write_buffer_limitsc             C   s   | j jj S )N)rQ   rd   get_write_buffer_size)r$   r   r   r   rh   v  s    z+_SSLProtocolTransport.get_write_buffer_sizec             C   s<   t |tttfs$tdjt|j|s,d S | jj	| d S )Nz/data: expecting a bytes-like instance, got {!r})

isinstancebytes	bytearrayrG   	TypeErrorformattyperK   rQ   _write_appdata)r$   rC   r   r   r   r8   z  s    z_SSLProtocolTransport.writec             C   s   dS )NFr   )r$   r   r   r   can_write_eof  s    z#_SSLProtocolTransport.can_write_eofc             C   s   | j j  d S )N)rQ   _abort)r$   r   r   r   abort  s    z_SSLProtocolTransport.abort)N)NN)rK   rL   rM   r&   rW   rZ   r[   r\   r^   r   ZPY34rc   re   rf   rg   rh   r8   rp   rr   r   r   r   r   rO   &  s   

rO   c               @   s   e Zd Zd'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!d"Zd#d$ Zd%d& ZdS )+SSLProtocolFNTc             C   s   t d krtd|st||}|| _|r6| r6|| _nd | _|| _t|d| _tj	 | _
d| _|| _|| _|| _t| j| | _d | _d| _d| _d| _d | _|| _d S )Nzstdlib ssl module not available)r   r   F)r   r-   r   r   r   _sslcontextdict_extracollectionsdeque_write_backlog_write_buffer_size_waiterrP   rX   rO   _app_transport_sslpipe_session_established_in_handshake_in_shutdownrd   _call_connection_made)r$   rS   Zapp_protocolr   Zwaiterr   r   Zcall_connection_mader   r   r   r&     s,    


zSSLProtocol.__init__c             C   sD   | j d krd S | j j s:|d k	r.| j j| n| j jd  d | _ d S )N)r{   Z	cancelledZset_exceptionZ
set_result)r$   rE   r   r   r   _wakeup_waiter  s    

zSSLProtocol._wakeup_waiterc             C   s&   || _ t| j| j| j| _| j  d S )N)rd   r   rt   r   r   r}   _start_handshake)r$   	transportr   r   r   connection_made  s
    
zSSLProtocol.connection_madec             C   s8   | j rd| _ | jj| jj| d | _d | _| j| d S )NF)r~   rP   	call_soonrX   connection_lostrd   r|   r   )r$   rE   r   r   r   r     s    zSSLProtocol.connection_lostc             C   s   | j j  d S )N)rX   pause_writing)r$   r   r   r   r     s    zSSLProtocol.pause_writingc             C   s   | j j  d S )N)rX   resume_writing)r$   r   r   r   r     s    zSSLProtocol.resume_writingc             C   s   | j d krd S y| j j|\}}W nH tjk
rj } z*| jj rTtjd| |j|j	 | j
  d S d }~X nX x|D ]}| jj| qrW x(|D ] }|r| jj| q| j  P qW d S )Nz%r: SSL error %s (reason %s))r}   r/   r   r<   rP   	get_debugr   warningr7   rH   rq   rd   r8   rX   data_receivedr]   )r$   rC   r1   r2   erD   r   r   r   r     s"    



zSSLProtocol.data_receivedc          
   C   sT   zB| j j rtjd|  | jt | js@| jj }|r@tj	d W d | j
j  X d S )Nz%r received EOFz?returning true from eof_received() has no effect when using ssl)rP   r   r   debugr   ConnectionResetErrorr   rX   eof_receivedr   rd   r^   )r$   Z	keep_openr   r   r   r     s    


zSSLProtocol.eof_receivedc             C   s4   || j kr| j | S | jd k	r,| jj||S |S d S )N)rv   rd   rW   )r$   rU   rV   r   r   r   rT   !  s
    


zSSLProtocol._get_extra_infoc             C   s.   | j r
d S | jr| j  nd| _ | jd d S )NTr+   )r   r   rq   ro   )r$   r   r   r   r]   )  s    
zSSLProtocol._start_shutdownc             C   s.   | j j|df |  jt|7  _| j  d S )Nr   )ry   r;   rz   rF   _process_write_backlog)r$   rC   r   r   r   ro   2  s    zSSLProtocol._write_appdatac             C   sH   | j j r$tjd|  | j j | _nd | _d| _| jjd | j	  d S )Nz%r starts SSL handshakeTr+   r   )r+   r   )
rP   r   r   r   time_handshake_start_timer   ry   r;   r   )r$   r   r   r   r   7  s    
zSSLProtocol._start_handshakec             C   sT  d| _ | jj}yF|d k	r||j }t| jdsR| jrR| jjtj	krRtj
|| j W n~ tk
r } zb| jj rt|tjrtjd| dd ntjd| dd | jj  t|tr| j| d S  W Y d d }~X nX | jj r| jj | j }tjd| |d  | jj||j |j |d	 | jr4| jj| j  | j  d| _!| jj"| j# d S )
NFr   z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg     @@)peercertciphercompressionr'   )$r   r}   r'   Zgetpeercertr
   rt   r   r   r   Z	CERT_NONEZmatch_hostnameBaseExceptionrP   r   ri   r=   r   r   rd   r^   	Exceptionr   r   r   r   rv   updater   r   r   rX   r   r|   r~   r   r   )r$   Zhandshake_excZsslobjr   rE   Zdtr   r   r   _on_handshake_completeC  sD    




z"SSLProtocol._on_handshake_completec             C   s>  | j d ks| jd krd S yxtt| jD ]}| jd \}}|rT| jj||\}}n*|rl| jj| j}d}n| jj| j	}d}x|D ]}| j j
| qW |t|k r||f| jd< | j jr| j j  P | jd= |  jt|8  _q*W W nR tk
r8 } z4| jr| j| n| j|d t|ts( W Y d d }~X nX d S )Nr   r   zFatal error on SSL transport)rd   r}   rangerF   ry   rJ   r3   r   r5   	_finalizer8   Z_pausedrf   rz   r   r   _fatal_errorri   r   )r$   irC   rI   r1   rD   rE   r   r   r   r   w  s8    

z"SSLProtocol._process_write_backlogFatal error on transportc             C   sX   t |tjr*| jj rBtjd| |dd n| jj||| j| d | jrT| jj	| d S )Nz%r: %sT)r   )messageZ	exceptionr   rY   )
ri   r   Z_FATAL_ERROR_IGNORErP   r   r   r   Zcall_exception_handlerrd   Z_force_close)r$   rE   r   r   r   r   r     s    

zSSLProtocol._fatal_errorc             C   s   d | _ | jd k	r| jj  d S )N)r}   rd   r^   )r$   r   r   r   r     s    
zSSLProtocol._finalizec          
   C   s(   z| j d k	r| j j  W d | j  X d S )N)rd   rr   r   )r$   r   r   r   rq     s    
zSSLProtocol._abort)FNT)N)N)r   )rK   rL   rM   r&   r   r   r   r   r   r   r   rT   r]   ro   r   r   r   r   r   rq   r   r   r   r   rs     s$    
"


	4,
rs   )rw   r`   r   ImportError r   r   r   r   logr   r   r   r   r.   r)   r4   objectr   Z_FlowControlMixinZ	TransportrO   ZProtocolrs   r   r   r   r   <module>   s*   
 wn